wenjy 1 year ago
commit 72acbbf30a

@ -4621,6 +4621,36 @@
工位
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.StationHourAmountView.RowNum">
<summary>
产线编码
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.StationHourAmountView.ProductlineCode">
<summary>
产线编码
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.StationHourAmountView.ProductDate">
<summary>
时间
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.StationHourAmountView.ProductHour">
<summary>
小时
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.StationHourAmountView.BackPanelHourAmount">
<summary>
背板数量
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.StationHourAmountView.SidPanelHourAmount">
<summary>
前板数量
</summary>
</member>
<member name="T:Admin.Core.Model.ViewModels.WorkTime">
<summary>
条码绑定扫描类型统计

@ -12,5 +12,7 @@ namespace Admin.Core.IRepository
{
Task<List<dynamic>> GetStationMaterialStats(string stationCode);
Task<List<dynamic>> GetStationHourAmount(string stationCode);
Task<List<dynamic>> GetStationSheetMetalHourAmountAsync(string stationCode);
}
}

@ -27,11 +27,6 @@ namespace Admin.Core.IRepository
/// <param name="productLineCode"></param>
/// <returns></returns>
Task<List<ProductLineInfoView>> GetProductLineInfo(string productLineCode);
/// <summary>
/// 根据工位查询时间
/// </summary>
/// <param name="stationCode"></param>
/// <returns></returns>
List<dynamic> GetStationHourAmountAsync(string stationCode);
}
}

@ -107,6 +107,10 @@ namespace Admin.Core.IService
/// <param name="stationCode"></param>
/// <returns></returns>
Task<List<dynamic>> GetStationMaterialStats(string stationCode);
Task<List<dynamic>> GetStationSheetMetalHourAmountAsync(string stationCode);
#endregion
}
}

@ -36,11 +36,6 @@ namespace Admin.Core.IService
/// <param name="productLineCode"></param>
/// <returns></returns>
Task<ProductLineInfoView> GetProductLineInfo(string productLineCode);
/// <summary>
/// 根据工位查询小时
/// </summary>
/// <param name="stationCode"></param>
/// <returns></returns>
List<dynamic> GetStationHourAmountAsync(string stationCode);
}
}

@ -0,0 +1,44 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.Model.ViewModels
{
public class StationHourAmountView
{
/// <summary>
/// 产线编码
/// </summary>
[SugarColumn(ColumnName = "ROWNUM")]
public string RowNum { get; set; }
/// <summary>
/// 产线编码
/// </summary>
[SugarColumn(ColumnName = "PRODUCTLINE_CODE")]
public string ProductlineCode { get; set; }
/// <summary>
/// 时间
/// </summary>
[SugarColumn(ColumnName = "PRODUCT_DATE")]
public string ProductDate { get; set; }
/// <summary>
/// 小时
/// </summary>
[SugarColumn(ColumnName = "PRODUCT_HOUR")]
public string ProductHour { get; set; }
/// <summary>
/// 背板数量
/// </summary>
[SugarColumn(ColumnName = "BACKPANELHOURAMOUNT")]
public string BackPanelHourAmount { get; set; }
/// <summary>
/// 前板数量
/// </summary>
[SugarColumn(ColumnName = "SIDPANELHOURAMOUNT")]
public string SidPanelHourAmount { get; set; }
}
}

@ -2,6 +2,7 @@
using Admin.Core.Model;
using SqlSugar;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Admin.Core.Repository
@ -24,5 +25,15 @@ namespace Admin.Core.Repository
{
return await Db.Queryable<dynamic>().AS("GET_STATION_HOURAMOUNT").Where("PRODUCTLINE_CODE = @stationCode", new { stationCode = stationCode }).ToListAsync();
}
/// <summary>
/// 获取钣金生产小时数
/// </summary>
/// <param name="stationCode"></param>
/// <returns></returns>
public async Task<List<dynamic>> GetStationSheetMetalHourAmountAsync(string stationCode)
{
return await Db.Queryable<dynamic>().AS("GET_STATION_SHEETMETALHOURAMOUNT").ToListAsync();
}
}
}

@ -6,6 +6,7 @@ using Admin.Core.Model.Model_New;
using System.Collections.Generic;
using System;
using Microsoft.IdentityModel.Logging;
using System.Linq;
namespace Admin.Core.Repository
{
@ -56,24 +57,6 @@ namespace Admin.Core.Repository
#endregion
/// <summary>
/// 获取班组小时数
/// </summary>
/// <param name="stationCode"></param>
/// <returns></returns>
public List<dynamic> GetStationHourAmountAsync(string stationCode)
{
List<dynamic> result = null;
try
{
result = Db.Queryable<dynamic>().AS("GET_STATION_HOURAMOUNT").Where("PRODUCTLINE_CODE = @stationCode", new { stationCode = stationCode }).ToList();
}
catch (Exception ex)
{
}
return result;
}
}
}

@ -23,12 +23,13 @@ namespace Admin.Core.Service
private readonly IProductPlanInfoServices _productPlanInfoServices;
public ExecutePlanInfoServices(IBaseRepository<ExecutePlanInfo> dal, IProductOrderInfoServices productOrderInfoServices,
IProductPlanInfoServices productPlanInfoServices)
IProductPlanInfoServices productPlanInfoServices, IExecutePlanInfoRepository executePlanInfoRepository)
{
this._dal = dal;
base.BaseDal = dal;
_productOrderInfoServices = productOrderInfoServices;
_productPlanInfoServices = productPlanInfoServices;
_executePlanInfoRepository = executePlanInfoRepository;
}
#region 计划删除
@ -385,5 +386,15 @@ namespace Admin.Core.Service
}
return planInfos;
}
/// <summary>
/// 获取钣金生产小时数
/// </summary>
/// <param name="stationCode"></param>
/// <returns></returns>
public async Task<List<dynamic>> GetStationSheetMetalHourAmountAsync(string stationCode)
{
return await _executePlanInfoRepository.GetStationSheetMetalHourAmountAsync(stationCode);
}
}
}

@ -29,14 +29,14 @@ namespace Admin.Core.IService
public async Task<List<CurrentTeamTimeView>> GetTeamData()
{
return await _sysUserInfoRepository.GetTeamData();
}
public async Task<CurrentTeamTimeView> GetTeamData(DateTime nowDate)
{
var list= await _sysUserInfoRepository.GetTeamData();
var list = await _sysUserInfoRepository.GetTeamData();
if (list.Count() == 0) return null;
CurrentTeamTimeView view = list.SingleOrDefault(d=>d.StartTime<= nowDate && nowDate <= d.EndTime);
CurrentTeamTimeView view = list.SingleOrDefault(d => d.StartTime <= nowDate && nowDate <= d.EndTime);
if (view != null)
return view;
else
@ -67,14 +67,7 @@ namespace Admin.Core.IService
var obj = list.SingleOrDefault(d => d.ProductlineCode == productLineCode);
return obj;
}
/// <summary>
/// 根据工位查询小时
/// </summary>
/// <param name="stationCode"></param>
/// <returns></returns>
public List<dynamic> GetStationHourAmountAsync(string stationCode)
{
return _sysUserInfoRepository.GetStationHourAmountAsync(stationCode);
}
}
}

@ -1,247 +0,0 @@
using Admin.Core.Common.Helper;
using Admin.Core.IRepository;
using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using Admin.Core.Repository;
using Admin.Core.Service;
using Aucma.Core.HwPLc;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aucam.Core.PerfusionService.Business
{
/// <summary>
/// 采集灌注数据
/// </summary>
public class PerfusionCollection
{
Semaphore semaphore = new Semaphore(1, 1);
protected readonly IPerfusionRecordServices? _perfusionRecordServices ;
protected readonly IPerfusionAlarmServices ?_perfusionAlarmServices;
protected readonly IPerfusionDeviceStatusServices? _perfusionDeviceStatusServices;
private static System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
private Perfusion_Record record = new Perfusion_Record();
private Perfusion_Record temprRecord;
private Perfusion_DeviceStatus perfusion_DeviceStatus = new Perfusion_DeviceStatus();
private Perfusion_Alarm perfusion_Alarm = new Perfusion_Alarm();
public PerfusionCollection(PerfusionRecordServices perfusionRecordServices, IPerfusionAlarmServices perfusionAlarmServices, IPerfusionDeviceStatusServices perfusionDeviceStatusServices)
{
_perfusionRecordServices = perfusionRecordServices;
_perfusionAlarmServices = perfusionAlarmServices;
_perfusionDeviceStatusServices = perfusionDeviceStatusServices;
startCollect();
}
public void startCollect()
{
Task.Run(() =>
{
while (true)
{
semaphore.WaitOne();
try
{
Thread.Sleep(3000);
var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("PerfusionPlc"));
if (obj != null && obj.plc.IsConnected)
{
//采集数据
ReadEquipSystem(obj,record, perfusion_DeviceStatus, perfusion_Alarm);
//更新设备状态
// _perfusionDeviceStatusServices.UpdateAsync;
// 更新报警信息
//充注结束
if (record.PerfusionFinishStatus == "1")
{
//缓存没数据查数据库
if(temprRecord == null)
{
Perfusion_Record lastRecord = _perfusionRecordServices.Query(d => d.PerfusionBoxCode.Equals(record.PerfusionBoxCode)).FirstOrDefault();
// 数据库没有数据
if (lastRecord == null)
{
_= _perfusionRecordServices.AddAsync(record).Result;
return;
}
}
// 箱体码和上次不一样,或者箱体码一样但是充铸结果不一样
else if(temprRecord.PerfusionBoxCode!=record.PerfusionBoxCode || (temprRecord.PerfusionBoxCode == record.PerfusionBoxCode && temprRecord.PerfusionResult!=record.PerfusionResult) )
{
_ = _perfusionRecordServices.AddAsync(record).Result;
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
finally
{
temprRecord = record;
semaphore.Release();
}
}
});
}
/// <summary>
/// 采集灌注参数
/// </summary>
/// <returns></returns>
static void ReadEquipSystem(Aucma.Core.HwPLc.PlcModel obj, Perfusion_Record record, Perfusion_DeviceStatus deviceStatus, Perfusion_Alarm alarmInfo)
{
byte[] info = obj.plc.Read("DB55.0", 84);
if (info == null) return;
#region 灌注记录赋值
record.PerfusionActualVolume=byteToDouble(info.Skip(0).Take(8).ToArray()).ToString();
record.PerfusionR = byteToDouble(info.Skip(8).Take(4).ToArray()).ToString().ToString();
record.PerfusionL = byteToFloat(info.Skip(55).Take(4).ToArray()).ToString();
record.PerfusionDuration = int.Parse(StringChange.bytesToHexStr(info.Skip(12).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber).ToString();
record.Yield = int.Parse(StringChange.bytesToHexStr(info.Skip(16).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber).ToString();
record.PerfusionBoxCode = asciiEncoding.GetString(info.Skip(20).Take(24).ToArray()).Replace("\0", "").Trim('\n');
record.PerfusionRefrigerantTypeLeft = asciiEncoding.GetString(info.Skip(58).Take(7).ToArray()).Trim('\n');
record.PerfusionRefrigerantTypeRight = asciiEncoding.GetString(info.Skip(68).Take(7).ToArray()).Trim('\n');
record.PerfusionSetVolume = byteToFloat(info.Skip(78).Take(4).ToArray()).ToString();
record.PerfusionSystem =short.Parse(StringChange.bytesToHexStr(info.Skip(82).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
///灌注完成状态字
record.PerfusionFinishStatus = short.Parse(StringChange.bytesToHexStr(info.Skip(46).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
record.PerfusionResult = short.Parse(StringChange.bytesToHexStr(info.Skip(48).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
record.CreatedBy = "equip";
record.CreatedTime = DateTime.Now;
record.UpdatedBy = "equip";
record.UpdatedTime = DateTime.Now;
#endregion
#region 设备状态赋值
deviceStatus.PerfusionDevicetype = "灌注";
deviceStatus.PerfusionStatus = short.Parse(StringChange.bytesToHexStr(info.Skip(50).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
deviceStatus.CreatedBy = "equip";
deviceStatus.CreatedTime = DateTime.Now;
deviceStatus.UpdatedBy = "equip";
deviceStatus.UpdatedTime = DateTime.Now;
#endregion
#region 设备报警赋值
alarmInfo.PerfusionBoxcode = record.PerfusionBoxCode;
alarmInfo.PerfusionStatus = short.Parse(StringChange.bytesToHexStr(info.Skip(52).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
alarmInfo.PerfusionAlarm = AlarmTrans(alarmInfo.PerfusionStatus);
alarmInfo.PerfusionCompleted = "1";
alarmInfo.CreatedBy = "equip";
alarmInfo.CreatedTime = DateTime.Now;
alarmInfo.UpdatedBy = "equip";
alarmInfo.UpdatedTime = DateTime.Now;
#endregion
}
static string AlarmTrans(short code)
{
string result = "";
switch (code)
{
case 2: result = "充注枪真空不合格"; break;
case 4: result = "充注故障"; break;
case 8: result = "充注时真空度超限定"; break;
case 16: result = "回升检测不合格"; break;
case 32: result = "工件真空不合格"; break;
case 64: result = "平衡缸接近开关异常"; break;
case 128: result = "增压超时"; break;
case 256: result = "风压不足"; break;
}
return result;
}
#region 字符工具转换方法
/// byte[]转十进制ascii码
/// </summary>
/// <param name="bytes"></param>
static string ByteArrayToString(byte[] bytes)
{
string result = string.Empty;
foreach (byte b in bytes)
{
int decimalValue = Convert.ToInt32(b); // 将字节转换为十进制值
result += decimalValue;
}
return result;
}
/// <summary>
/// byte[]转二进制
/// </summary>
/// <param name="bytes"></param>
static string ByteArrayToBinary(byte[] bytes)
{
StringBuilder binaryString = new StringBuilder();
foreach (byte b in bytes)
{
binaryString.Append(Convert.ToString(b, 2).PadLeft(8, '0'));
}
// Console.WriteLine(binaryString);
string reversedStr = new string(binaryString.ToString().Reverse().ToArray());
// Console.WriteLine(reversedStr);
return reversedStr;
}
/// <summary>
/// 根据二进制字符串确定夹具状态 1正常生产 2暂停生产
/// </summary>
static int judgeStatus(string str1)
{
int item1 = 0;
if (str1.Substring(0, 1) == "1")
{
item1 = 1; //
}
else if (str1.Substring(1, 1) == "1")
{
item1 = 2; //
}
return item1;
}
/// <summary>
/// byte数组转换为float
/// </summary>
static float byteToFloat(byte[] list)
{
float result = 0.00f;
Array.Reverse(list);
result = BitConverter.ToSingle(list, 0);
return result;
}
/// <summary>
/// byte数组转换为float
/// </summary>
static double byteToDouble(byte[] list)
{
double result = 0;
Array.Reverse(list);
result = BitConverter.ToDouble(list, 0);
return result;
}
#endregion
}
}

@ -4,7 +4,7 @@ using Admin.Core.Model;
using Aucma.Core.BoxFoam.Models;
using Aucma.Core.BoxFoam.ViewModels;
using Aucma.Core.HwPLc;
using Microsoft.Extensions.DependencyInjection;
using NetTaste;
using NPOI.Util;
using System;
@ -15,6 +15,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Documents;
using System.Windows.Forms;
namespace Aucma.Core.BoxFoam.Business
{
@ -23,29 +24,116 @@ namespace Aucma.Core.BoxFoam.Business
/// </summary>
public class CollectionFoamMachine
{
/// <summary>
/// 刷新最后一枪DATAGRID
/// </summary>
public delegate void RefreshLastShotDataDelegate(BoxLastShotRecord record);
public static event RefreshLastShotDataDelegate RefreshLastShotDataDelegateEvent;
/// <summary>
/// 刷新每一枪数据
/// </summary>
public delegate void RefreshGunDataDelegate(Dictionary<string, BoxLastShotRecord> keys);
public static event RefreshGunDataDelegate RefreshGunDataDelegateEvent;
/// <summary>
/// 刷新系统数据
/// </summary>
public delegate void RefreshSystemDataDelegate(Dictionary<string, FoamMachinesModel> keys);
public static event RefreshSystemDataDelegate RefreshSystemDataDelegateEvent;
private static System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
List<FoamMachinesModel> foamMachinesList = new List<FoamMachinesModel>();
private static BoxLastShotRecord tempLastRecord = null;
public void startCollect()
Dictionary<string, BoxLastShotRecord> gunKeys = new Dictionary<string, BoxLastShotRecord>();
Dictionary<string, BoxLastShotRecord> tempKeys = new Dictionary<string, BoxLastShotRecord>();
// 系统参数
Dictionary<string, FoamMachinesModel> systemKeys = new Dictionary<string, FoamMachinesModel>();
Semaphore semaphore = new Semaphore(1, 1);
private readonly IBoxLastShotRecordServices? _lastShotRecordServices = App.ServiceProvider.GetService<IBoxLastShotRecordServices>();
public CollectionFoamMachine()
{
startCollect();
}
public void startCollect()
{
Task.Run( () =>
Task.Run(() =>
{
Task.Delay(2000);
//Thread.Sleep(6000);
var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamMachinePlc"));
if (obj != null)
while (true)
{
ReadEquipSystem(obj, "DB50.388"); //采集1系统
//ReadEquipSystem(obj, "DB50.642"); //采集2系统
//ReadGunData(obj, "DB50.896"); //A1枪数据
//ReadGunData(obj, "DB50.1084"); //A1枪数据
//ReadGunData(obj, "DB50.1272"); //A1枪数据
//ReadGunData(obj, "DB50.1460"); //A1枪数据
semaphore.WaitOne();
try
{
Thread.Sleep(3000);
var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamMachinePlc"));
if (obj != null)
{
ReadEquipSystem(obj, "DB50.388", systemKeys, "1"); //采集1系统
ReadEquipSystem(obj, "DB50.642", systemKeys, "2"); //采集2系统
ReadGunData(obj, "DB50.896", gunKeys, "A1"); //A1枪数据
ReadGunData(obj, "DB50.1084", gunKeys, "B1"); //B1枪数据
ReadGunData(obj, "DB50.1272", gunKeys, "A2"); //A2枪数据
ReadGunData(obj, "DB50.1460", gunKeys, "B2"); //A2枪数据
RefreshSystemDataDelegateEvent?.Invoke(systemKeys);
RefreshGunDataDelegateEvent?.Invoke(gunKeys);
foreach (KeyValuePair<string, BoxLastShotRecord> kvPair in gunKeys)
{
//程序启动缓存没数据查数据库
if (!tempKeys.ContainsKey(kvPair.Key))
{
BoxLastShotRecord record = _lastShotRecordServices.Query(x => x.System == kvPair.Value.System && x.ProductLineCode == kvPair.Value.ProductLineCode && x.GunCode == kvPair.Value.GunCode).OrderByDescending(x => x.CreateTime).FirstOrDefault();
if (record == null)
{
// 数据库也没数据
int a = _lastShotRecordServices.AddAsync(kvPair.Value).Result;
RefreshLastShotDataDelegateEvent?.Invoke(kvPair.Value);
continue;
}
tempKeys.Add(kvPair.Key, record);
}
if (!kvPair.Value.MixpistOff.Equals(tempKeys[kvPair.Key].MixpistOff))
{
int b = _lastShotRecordServices.AddAsync(kvPair.Value).Result;
RefreshLastShotDataDelegateEvent?.Invoke(kvPair.Value);
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
finally
{
foreach (KeyValuePair<string, BoxLastShotRecord> kvp in gunKeys)
{
if (tempKeys.ContainsKey(kvp.Key))
{
// 键已存在,更新值
tempKeys[kvp.Key] = kvp.Value;
}
else
{
// 键不存在,添加键值对
tempKeys.Add(kvp.Key, kvp.Value);
}
}
// tempKeys = gunKeys;
semaphore.Release();
}
}
});
}
@ -53,38 +141,54 @@ namespace Aucma.Core.BoxFoam.Business
/// 采集设备系统参数
/// </summary>
/// <returns></returns>
static void ReadEquipSystem(HwPLc.PlcModel obj, string startStr)
static void ReadEquipSystem(HwPLc.PlcModel obj, string startStr, Dictionary<string, FoamMachinesModel> keys, string systemId)
{
if (obj == null && !obj.plc.IsConnected) return;
if (obj == null || !obj.plc.IsConnected) return;
if (obj.plc.IsConnected)
{
FoamMachinesModel mode=new FoamMachinesModel();
byte[] info = obj.plc.Read(startStr, 170);
int temp1 = judgeStatus(ByteArrayToBinary(info.Skip(0).Take(1).ToArray()));
int temp2 = judgeStatus(ByteArrayToBinary(info.Skip(1).Take(1).ToArray()));
float temp3 = byteToFloat(info.Skip(2).Take(4).ToArray());
float temp4 = byteToFloat(info.Skip(14).Take(4).ToArray());
float temp5 = byteToFloat(info.Skip(18).Take(4).ToArray());
float temp6 = byteToFloat(info.Skip(22).Take(4).ToArray());
if (info == null) return;
FoamMachinesModel model = new FoamMachinesModel();
model.systemId = systemId;
model.Machine_Status_0 = judgeStatus(ByteArrayToBinary(info.Skip(0).Take(1).ToArray())).ToString();
model.Machine_Status_1 = judgeStatus(ByteArrayToBinary(info.Skip(1).Take(1).ToArray())).ToString();
model.POL_Level = byteToFloat(info.Skip(2).Take(4).ToArray()).ToString();
float temp7 = byteToFloat(info.Skip(34).Take(4).ToArray());
float temp8 = byteToFloat(info.Skip(38).Take(4).ToArray());
float temp9 = byteToFloat(info.Skip(42).Take(4).ToArray());
model.POL_Temp = byteToFloat(info.Skip(14).Take(4).ToArray()).ToString();
model.POL_LP = byteToFloat(info.Skip(18).Take(4).ToArray()).ToString();
model.POL_HP = byteToFloat(info.Skip(22).Take(4).ToArray()).ToString();
float temp10 = byteToFloat(info.Skip(82).Take(4).ToArray());
model.POL_Vol = byteToFloat(info.Skip(34).Take(4).ToArray()).ToString();
model.POL_Usage = byteToFloat(info.Skip(38).Take(4).ToArray()).ToString();
model.POL_Freq_Speed = byteToFloat(info.Skip(42).Take(4).ToArray()).ToString();
float temp11 = byteToFloat(info.Skip(94).Take(4).ToArray());
float temp12 = byteToFloat(info.Skip(98).Take(4).ToArray());
float temp13 = byteToFloat(info.Skip(102).Take(4).ToArray());
model.ISO_Level = byteToFloat(info.Skip(82).Take(4).ToArray()).ToString();
float temp14 = byteToFloat(info.Skip(114).Take(4).ToArray());
float temp15 = byteToFloat(info.Skip(118).Take(4).ToArray());
float temp16 = byteToFloat(info.Skip(122).Take(4).ToArray());
model.ISO_Temp = byteToFloat(info.Skip(94).Take(4).ToArray()).ToString();
model.ISO_LP = byteToFloat(info.Skip(98).Take(4).ToArray()).ToString();
model.ISO_HP = byteToFloat(info.Skip(102).Take(4).ToArray()).ToString();
float temp17 = byteToFloat(info.Skip(162).Take(4).ToArray());
float temp18 = byteToFloat(info.Skip(166).Take(4).ToArray());
model.ISO_Vol = byteToFloat(info.Skip(114).Take(4).ToArray()).ToString();
model.ISO_Usage = byteToFloat(info.Skip(118).Take(4).ToArray()).ToString();
model.ISO_Freq_Speed = byteToFloat(info.Skip(122).Take(4).ToArray()).ToString();
model.Hydr_Press = byteToFloat(info.Skip(162).Take(4).ToArray()).ToString();
model.Hydr_Temp = byteToFloat(info.Skip(166).Take(4).ToArray()).ToString();
model.collectTime = DateTime.Now;
if (keys.ContainsKey(systemId))
{
// 键已存在,更新值
keys[systemId] = model;
}
else
{
// 键不存在,添加键值对
keys.Add(systemId, model);
}
}
}
@ -92,98 +196,57 @@ namespace Aucma.Core.BoxFoam.Business
/// 每一枪数据 ---A1,B1,A2,B2
/// </summary>
/// <returns></returns>
static void ReadGunData(HwPLc.PlcModel obj, string startStr)
static void ReadGunData(HwPLc.PlcModel obj, string startStr, Dictionary<string, BoxLastShotRecord> keys, string gunCode)
{
if (obj == null && !obj.plc.IsConnected) return;
if (obj == null || !obj.plc.IsConnected) return;
if (obj.plc.IsConnected)
{
byte[] info = obj.plc.Read(startStr, 88);
float temp1 = byteToFloat(info.Skip(0).Take(4).ToArray());
float temp2 = byteToFloat(info.Skip(4).Take(4).ToArray());
float temp3 = byteToFloat(info.Skip(8).Take(4).ToArray());
float temp4 = byteToFloat(info.Skip(12).Take(4).ToArray());
float temp5 = byteToFloat(info.Skip(16).Take(4).ToArray());
float temp6 = byteToFloat(info.Skip(20).Take(4).ToArray());
float temp7 = byteToFloat(info.Skip(24).Take(4).ToArray());
float temp8 = byteToFloat(info.Skip(28).Take(4).ToArray());
short temp9 = short.Parse(StringChange.bytesToHexStr(info.Skip(36).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
int temp10 = int.Parse(StringChange.bytesToHexStr(info.Skip(38).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
float temp11 = byteToFloat(info.Skip(42).Take(4).ToArray());
float temp12 = byteToFloat(info.Skip(46).Take(4).ToArray());
float temp13 = byteToFloat(info.Skip(50).Take(4).ToArray());
float temp14 = byteToFloat(info.Skip(54).Take(4).ToArray());
int temp15 = int.Parse(StringChange.bytesToHexStr(info.Skip(58).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
int temp16 = int.Parse(StringChange.bytesToHexStr(info.Skip(62).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
float temp17 = byteToFloat(info.Skip(66).Take(4).ToArray());
float temp18 = byteToFloat(info.Skip(70).Take(4).ToArray());
int temp19 = int.Parse(StringChange.bytesToHexStr(info.Skip(74).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
int temp20 = int.Parse(StringChange.bytesToHexStr(info.Skip(78).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
int temp21 = int.Parse(StringChange.bytesToHexStr(info.Skip(82).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
int temp22 = judgeStatus(ByteArrayToBinary(info.Skip(87).Take(1).ToArray()));
if (info == null) return;
BoxLastShotRecord lastShotRecord = new BoxLastShotRecord();
lastShotRecord.System = gunCode.Substring(1, 1);
lastShotRecord.GunCode = gunCode;
lastShotRecord.ProductLineCode = "CX_02";
lastShotRecord.PolTemp = byteToFloat(info.Skip(0).Take(4).ToArray()).ToString();
lastShotRecord.PolHp = byteToFloat(info.Skip(4).Take(4).ToArray()).ToString();
lastShotRecord.PolVol = byteToFloat(info.Skip(8).Take(4).ToArray()).ToString();
lastShotRecord.PolUsage = byteToFloat(info.Skip(12).Take(4).ToArray()).ToString();
lastShotRecord.IsoTemp = byteToFloat(info.Skip(16).Take(4).ToArray()).ToString();
lastShotRecord.IsoHp = byteToFloat(info.Skip(20).Take(4).ToArray()).ToString();
lastShotRecord.IsoVol = byteToFloat(info.Skip(24).Take(4).ToArray()).ToString();
lastShotRecord.IsoUsage = byteToFloat(info.Skip(28).Take(4).ToArray()).ToString();
lastShotRecord.PourNu = short.Parse(StringChange.bytesToHexStr(info.Skip(36).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
lastShotRecord.SetTime = int.Parse(StringChange.bytesToHexStr(info.Skip(38).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber).ToString();
lastShotRecord.SetWeight = byteToFloat(info.Skip(42).Take(4).ToArray()).ToString();
lastShotRecord.SetRatio = byteToFloat(info.Skip(46).Take(4).ToArray()).ToString(); ;
lastShotRecord.PourWeight = byteToFloat(info.Skip(50).Take(4).ToArray()).ToString();
lastShotRecord.PourRatio = byteToFloat(info.Skip(54).Take(4).ToArray()).ToString();
lastShotRecord.MpTime = int.Parse(StringChange.bytesToHexStr(info.Skip(58).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber).ToString();
lastShotRecord.HpTime = int.Parse(StringChange.bytesToHexStr(info.Skip(62).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber).ToString();
lastShotRecord.HydrPress = byteToFloat(info.Skip(66).Take(4).ToArray()).ToString();
lastShotRecord.HydrTemp = byteToFloat(info.Skip(70).Take(4).ToArray()).ToString();
lastShotRecord.MixpistOn = int.Parse(StringChange.bytesToHexStr(info.Skip(74).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber).ToString();
lastShotRecord.MixpistOff = int.Parse(StringChange.bytesToHexStr(info.Skip(78).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber).ToString(); ;
lastShotRecord.TotalYield = int.Parse(StringChange.bytesToHexStr(info.Skip(82).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber).ToString(); ;
lastShotRecord.PourEnd = judgeStatus(ByteArrayToBinary(info.Skip(87).Take(1).ToArray())).ToString();
lastShotRecord.CreateTime = DateTime.Now;
if (keys.ContainsKey(gunCode))
{
// 键已存在,更新值
keys[gunCode] = lastShotRecord;
}
else
{
// 键不存在,添加键值对
keys.Add(gunCode, lastShotRecord);
}
}
}
///// <summary>
///// 采集最后一枪数据
///// </summary>
///// <returns></returns>
//public async Task CollectLast()
//{
// var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("Plc1"));
// if (obj != null && obj.plc.IsConnected)
// {
// BoxLastShotRecord lastShotRecord = new BoxLastShotRecord();
// byte[] info = obj.plc.ReadBytes("DB50.896", (ushort)88);
// IByteTransform byteTransform = new RegularByteTransform();
// lastShotRecord.System = "1";
// lastShotRecord.GunCode = "A1";
// lastShotRecord.GunCode = "A1";
// #region 赋值
// lastShotRecord.PolTemp = Encoding.ASCII.GetString(info.Skip(0).Take(4).ToArray());
// lastShotRecord.PolHp = StringChange.bytesToHexStr(info.Skip(4).Take(4).ToArray(), 4);
// lastShotRecord.PolVol = StringChange.bytesToHexStr(info.Skip(8).Take(4).ToArray(), 4);
// lastShotRecord.PolUsage = StringChange.bytesToHexStr(info.Skip(12).Take(4).ToArray(), 4);
// lastShotRecord.IsoTemp = StringChange.bytesToHexStr(info.Skip(16).Take(4).ToArray(), 4);
// lastShotRecord.IsoHp = StringChange.bytesToHexStr(info.Skip(20).Take(4).ToArray(), 4);
// lastShotRecord.IsoVol = StringChange.bytesToHexStr(info.Skip(24).Take(4).ToArray(), 4);
// lastShotRecord.IsoUsage = StringChange.bytesToHexStr(info.Skip(28).Take(4).ToArray(), 4);
// lastShotRecord.PourNu = StringChange.bytesToHexStr(info.Skip(36).Take(2).ToArray(), 2);
// lastShotRecord.SetTime = StringChange.bytesToHexStr(info.Skip(38).Take(4).ToArray(), 4);
// lastShotRecord.SetWeight = StringChange.bytesToHexStr(info.Skip(42).Take(4).ToArray(), 4);
// lastShotRecord.SetRatio = StringChange.bytesToHexStr(info.Skip(46).Take(4).ToArray(), 4);
// lastShotRecord.PourWeight = StringChange.bytesToHexStr(info.Skip(50).Take(4).ToArray(), 4);
// lastShotRecord.PourRatio = StringChange.bytesToHexStr(info.Skip(54).Take(4).ToArray(), 4);
// lastShotRecord.MpTime = StringChange.bytesToHexStr(info.Skip(58).Take(4).ToArray(), 4);
// lastShotRecord.HpTime = StringChange.bytesToHexStr(info.Skip(62).Take(4).ToArray(), 4);
// lastShotRecord.HydrPress = StringChange.bytesToHexStr(info.Skip(66).Take(4).ToArray(), 4);
// lastShotRecord.HydrTemp = StringChange.bytesToHexStr(info.Skip(70).Take(4).ToArray(), 4);
// lastShotRecord.MixpistOn = StringChange.bytesToHexStr(info.Skip(74).Take(4).ToArray(), 4);
// lastShotRecord.MixpistOff = StringChange.bytesToHexStr(info.Skip(78).Take(4).ToArray(), 4);
// lastShotRecord.TotalYield = StringChange.bytesToHexStr(info.Skip(82).Take(4).ToArray(), 4);
// lastShotRecord.PourEnd = StringChange.bytesToHexStr(info.Skip(87).Take(1).ToArray(), 1);
// lastShotRecord.CreateTime = DateTime.Now;
// #endregion
// //if (tempLastRecord == null)
// //{
// // //数据库查
// // tempLastRecord = _lastShotRecordServices.Query(x => x.System == lastShotRecord.System && x.ProductLineCode == lastShotRecord.ProductLineCode && x.GunCode == lastShotRecord.GunCode).OrderByDescending(x => x.CreateTime).FirstOrDefault();
// //}
// //if (tempLastRecord == null || !tempLastRecord.MixpistOff.Equals(lastShotRecord.MixpistOff))
// //{
// // // 刷新页面
// // RefreshLastShotDataDelegateEvent?.Invoke(lastShotRecord);
// // //保存
// // _lastShotRecordServices.AddAsync(lastShotRecord);
// // tempLastRecord = lastShotRecord;
// //}
// }
//}
#region 字符工具转换方法
/// byte[]转十进制ascii码

@ -12,299 +12,104 @@ namespace Aucma.Core.BoxFoam.Models
{
public partial class FoamMachinesModel
{
#region 料位
/// <summary>
/// POL料位
/// 系统编号;1系统 2系统
/// </summary>
public int Syst1_POLMaterialLevel { get; set; }
public string systemId { get; set; }
/// <summary>
/// ISO料位
/// 开关机信号
/// </summary>
public int Syst1_ISOMaterialLevel { get; set; }
#endregion
public string Machine_Status_0 { get; set; }
#region 温度
/// <summary>
/// Plo温度
///运行状态(自/手动)
/// </summary>
public string Syst1_PolTmperature { get; set; }
/// <summary>
/// ISO温度
/// </summary>
public string Syst1_IsoTmperature { get; set; }
#endregion
#region 压力
/// <summary>
/// Pol压力
/// </summary>
public string Syst1_PolPressure { get; set; }
/// <summary>
/// Iso压力
/// </summary>
public string Syst1_IsoPressure { get; set; }
#endregion
public string Machine_Status_1 { get; set; }
#region 温度
/// <summary>
/// Iso温度
///POL料位
/// </summary>
public string Syst1_PolTemperature { get; set; }
/// <summary>
/// Iso温度
/// </summary>
public string Syst1_IsoTemperature { get; set; }
#endregion
public string POL_Level { get; set; }
#region 输出压力
/// <summary>
/// POL输出压力
///POL温度
/// </summary>
public string Syst1_PolOutputPressure { get; set; }
/// <summary>
/// ISO输出压力
/// </summary>
public string Syst1_IsoOutputPressure { get; set; }
#endregion
public string POL_Temp { get; set; }
#region 流量
/// <summary>
/// POL流量
/// </summary>
public string Syst1_PolFlow { get; set; }
/// <summary>
/// ISO流量
///POL输入压力
/// </summary>
public string Syst1_IsoFlow { get; set; }
#endregion
public string POL_LP { get; set; }
#region 原料用量
/// <summary>
/// POL流量
/// </summary>
public string Syst1_PolMaterialLeve { get; set; }
/// <summary>
/// ISO流量
///POL输出压力
/// </summary>
public string Syst1_IsoMaterialLeve { get; set; }
#endregion
public string POL_HP { get; set; }
#region 液压
/// <summary>
/// 液压压力
/// </summary>
public string Syst1_Pressure { get; set; }
/// <summary>
/// 液压
///POL流量
/// </summary>
public string Syst1_Temperature { get; set; }
#endregion
public string POL_Vol { get; set; }
#region 结束信号
/// <summary>
/// A1结束信号
///POL原料用量
/// </summary>
public string Syst1_A1_End { get; set; }
/// <summary>
/// 结束信号
/// </summary>
public string Syst1_B1_End { get; set; }
#endregion
public string POL_Usage { get; set; }
#region A1-B1 POL注料压力
/// <summary>
/// A1 POL注料压力
///POL变频器转速
/// </summary>
public string Syst1_A1_POLPressure { get; set; }
/// <summary>
/// B1 POL注料压力
/// </summary>
public string Syst1_B1_POLPressure { get; set; }
#endregion
public string POL_Freq_Speed { get; set; }
#region A1-B1 POL注料温度
/// <summary>
/// A1 POL注料温度
/// </summary>
public string Syst1_A1_POLTemperature { get; set; }
/// <summary>
/// B1 POL注料温度
///ISO料位
/// </summary>
public string Syst1_B1_POLTemperature { get; set; }
#endregion
public string ISO_Level { get; set; }
#region A1-B1 ISO注料压力
/// <summary>
/// A1 ISO注料压力
/// </summary>
public string Syst1_A1_ISOPressure { get; set; }
/// <summary>
/// B1 ISO注料压力
///ISO温度
/// </summary>
public string Syst1_B1_ISOPressure { get; set; }
#endregion
public string ISO_Temp { get; set; }
#region A1-B1 ISO注料压力
/// <summary>
/// A1 ISO注料压力
/// </summary>
public string Syst1_A1_ISOTemperature { get; set; }
/// <summary>
/// B1 ISO注料压力
///ISO输入压力
/// </summary>
public string Syst1_B1_ISOTemperature { get; set; }
#endregion
public string ISO_LP { get; set; }
#region 系统2料位
/// <summary>
/// POL料位
///ISO输出压力
/// </summary>
public int Syst2_POLMaterialLevel { get; set; }
public string ISO_HP { get; set; }
/// <summary>
/// ISO料位
///ISO流量
/// </summary>
public int Syst2_ISOMaterialLevel { get; set; }
#endregion
public string ISO_Vol { get; set; }
#region 系统2温度
/// <summary>
/// Plo温度
/// </summary>
public string Syst2_PolTmperature { get; set; }
/// <summary>
/// ISO温度
///ISO原料用量
/// </summary>
public string Syst2_IsoTmperature { get; set; }
public string ISO_Usage { get; set; }
#endregion
#region 系统2压力
/// <summary>
/// Pol压力
///ISO变频器转速
/// </summary>
public string Syst2_PolPressure { get; set; }
public string ISO_Freq_Speed { get; set; }
/// <summary>
/// Iso压力
///液压压力
/// </summary>
public string Syst2_IsoPressure { get; set; }
#endregion
public string Hydr_Press { get; set; }
#region 系统2温度
/// <summary>
/// Iso温度
///液压温度
/// </summary>
public string Syst2_PolTemperature { get; set; }
/// <summary>
/// Iso温度
/// </summary>
public string Syst2_IsoTemperature { get; set; }
#endregion
public string Hydr_Temp { get; set; }
#region 系统2输出压力
/// <summary>
/// POL输出压力
/// </summary>
public string Syst2_PolOutputPressure { get; set; }
/// <summary>
/// ISO输出压力
/// </summary>
public string Syst2_IsoOutputPressure { get; set; }
#endregion
#region 系统2流量
/// <summary>
/// POL流量
/// </summary>
public string Syst2_PolFlow { get; set; }
/// <summary>
/// ISO流量
/// </summary>
public string Syst2_IsoFlow { get; set; }
#endregion
#region 系统2原料用量
/// <summary>
/// POL流量
/// </summary>
public string Syst2_PolMaterialLeve { get; set; }
/// <summary>
/// ISO流量
/// </summary>
public string Syst2_IsoMaterialLeve { get; set; }
#endregion
#region 系统2液压
/// <summary>
/// 液压压力
/// </summary>
public string Syst2_Pressure { get; set; }
/// <summary>
/// 液压
/// </summary>
public string Syst2_Temperature { get; set; }
#endregion
#region 系统2结束信号
/// <summary>
/// A1结束信号
/// </summary>
public string Syst2_A1_End { get; set; }
/// <summary>
/// 结束信号
/// </summary>
public string Syst2_B1_End { get; set; }
#endregion
#region 系统2 A1-B1 POL注料压力
/// <summary>
/// A1 POL注料压力
/// </summary>
public string Syst2_A1_POLPressure { get; set; }
/// <summary>
/// B1 POL注料压力
/// </summary>
public string Syst2_B1_POLPressure { get; set; }
#endregion
#region 系统2 A1-B1 POL注料温度
/// <summary>
/// A1 POL注料温度
/// </summary>
public string Syst2_A1_POLTemperature { get; set; }
/// <summary>
/// B1 POL注料温度
/// </summary>
public string Syst2_B1_POLTemperature { get; set; }
#endregion
#region 系统2 A1-B1 ISO注料压力
/// <summary>
/// A1 ISO注料压力
/// </summary>
public string Syst2_A1_ISOPressure { get; set; }
/// <summary>
/// B1 ISO注料压力
/// </summary>
public string Syst2_B1_ISOPressure { get; set; }
#endregion
#region 系统2 A1-B1 ISO注料压力
/// <summary>
/// A1 ISO注料压力
/// </summary>
public string Syst2_A1_ISOTemperature { get; set; }
/// <summary>
/// B1 ISO注料压力
///采集时间
/// </summary>
public string Syst2_B1_ISOTemperature { get; set; }
#endregion
public DateTime collectTime { get; set; }
}
}

@ -4,6 +4,7 @@ using Admin.Core.Model;
using Admin.Core.Model.ViewModels;
using Admin.Core.Service;
using Admin.Core.Tasks;
using Aucma.Core.BoxFoam.Business;
using Aucma.Core.BoxFoam.Models;
using CommunityToolkit.Mvvm.ComponentModel;
using Microsoft.Extensions.DependencyInjection;
@ -22,48 +23,188 @@ namespace Aucma.Core.BoxFoam.ViewModels
public FoamMachinesPageViewModel()
{
Job_BoxFoamLastData_Quartz.RefreshLastShotDataDelegateEvent += RefreshData;
CollectionFoamMachine.RefreshLastShotDataDelegateEvent += RefreshData;
CollectionFoamMachine.RefreshGunDataDelegateEvent += RefreshGunData;
CollectionFoamMachine.RefreshSystemDataDelegateEvent += RefreshSystemData;
_boxLastShotRecordServices = App.ServiceProvider.GetService<IBoxLastShotRecordServices>();
// LoadData();
LoadData();
//Task.WaitAll(LoadData());
}
#region 刷新系统参数---系统1系统2
/// <summary>
/// 系统1系统2数据刷新
/// </summary>
public void RefreshSystemData(Dictionary<string, FoamMachinesModel> keys)
{
foreach (KeyValuePair<string, FoamMachinesModel> kvp in keys)
{
if (kvp.Key.Equals("1"))
{
RefreshSystem1(kvp.Value);
}
else if (kvp.Key.Equals("2"))
{
RefreshSystem2(kvp.Value);
}
}
}
/// <summary>
/// 刷新系统1
/// </summary>
/// <param name="record"></param>
public void RefreshSystem1(FoamMachinesModel record)
{
PolInputPressure1 = record.POL_LP;
IsoInputPressure1 = record.ISO_LP;
PolOutputPressure1 = record.POL_HP;
IsoOutputPressure1 = record.ISO_HP;
PolFlow1 = record.POL_Vol;
IsoFlow1 = record.ISO_Vol;
PoleTmperature1 = record.POL_Temp;
IsoTemperature1 = record.ISO_Temp;
PolMaterialLevel1 = record.POL_Level;
IsoMaterialLevel1 = record.ISO_Level;
Pressure1 = record.Hydr_Press;
Temperature1 = record.Hydr_Temp;
}
/// <summary>
/// 刷新系统2
/// </summary>
/// <param name="record"></param>
public void RefreshSystem2(FoamMachinesModel record)
{
PolInputPressure2 = record.POL_LP;
IsoInputPressure2 = record.ISO_LP;
PolOutputPressure2 = record.POL_HP;
IsoOutputPressure2 = record.ISO_HP;
PolFlow2 = record.POL_Vol;
IsoFlow2 = record.ISO_Vol;
PoleTmperature2 = record.POL_Temp;
IsoTemperature2 = record.ISO_Temp;
PolMaterialLevel2 = record.POL_Level;
IsoMaterialLevel2 = record.ISO_Level;
Pressure2 = record.Hydr_Press;
Temperature2 = record.Hydr_Temp;
}
#endregion
#region 刷新每一枪数据
/// <summary>
/// A1,B1,A2,B2枪数据刷新
/// </summary>
public void RefreshGunData(Dictionary<string, BoxLastShotRecord> keys)
{
foreach (KeyValuePair<string, BoxLastShotRecord> kvp in keys)
{
if (kvp.Key.Equals("A1"))
{
RefreshA1(kvp.Value);
}
else if (kvp.Key.Equals("B1"))
{
RefreshB1(kvp.Value);
}
else if (kvp.Key.Equals("A2"))
{
RefreshA2(kvp.Value);
}
else if (kvp.Key.Equals("B2"))
{
RefreshB2(kvp.Value);
}
}
}
/// <summary>
/// 刷新A1数据
/// </summary>
/// <param name="record"></param>
public void RefreshA1(BoxLastShotRecord record)
{
POLPressure1a = record.PolHp;
POLTemperature1a = record.PolTemp;
ISOPressure1a = record.IsoHp;
ISOTemperature1a = record.IsoTemp;
}
/// <summary>
/// 刷新B1数据
/// </summary>
/// <param name="record"></param>
public void RefreshB1(BoxLastShotRecord record)
{
POLPressure1b = record.PolHp;
POLTemperature1b = record.PolTemp;
ISOPressure1b = record.IsoHp;
ISOTemperature1b = record.IsoTemp;
}
/// <summary>
/// 刷新A2数据
/// </summary>
/// <param name="record"></param>
public void RefreshA2(BoxLastShotRecord record)
{
POLPressure2a = record.PolHp;
POLTemperature2a = record.PolTemp;
ISOPressure2a = record.IsoHp;
ISOTemperature2a = record.IsoTemp;
}
/// <summary>
/// 刷新B2数据
/// </summary>
/// <param name="record"></param>
public void RefreshB2(BoxLastShotRecord record)
{
POLPressure2b = record.PolHp;
POLTemperature2b = record.PolTemp;
ISOPressure2b = record.IsoHp;
ISOTemperature2b = record.IsoTemp;
}
#endregion
/// <summary>
/// datagrid刷新
/// </summary>
/// <param name="record"></param>
public void RefreshData(BoxLastShotRecord record)
{
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
string system = string.Empty;
if (record.System == "1") {
string system = string.Empty;
if (record.System == "1")
{
system = "1系统";
// PolFlow1 = record.POLInjecFlowRate;
// IsoFlow1 = record.ISOInjecFlowRate;
// PoleTmperature1 = record.POLInjecTemperatureOfGunHead;
// IsoTemperature1 = record.ISOInjecTemperatureOfGunHead;
// PolFlow1 = record.POLInjecFlowRate;
// IsoFlow1 = record.ISOInjecFlowRate;
// PoleTmperature1 = record.POLInjecTemperatureOfGunHead;
// IsoTemperature1 = record.ISOInjecTemperatureOfGunHead;
}
if (record.System == "2") { system = "2系统"; }
LastShotRecordDataGrid.Add(new LastShotRecordModel()
{
No = LastShotRecordDataGrid.Count+1,
System = system,
GunHead = record.GunCode,
// StationNumber = record.StationNumber,
PolInjectionpressure = record.PolHp,
IsoInjectionpressure = record.IsoHp,
PolInjectiontemperature = record.PolTemp,
IsoInjectiontemperature = record.IsoTemp,
LastTime = record.CreateTime,
Createtime = record.CreateTime
});
if (record.System == "2") { system = "2系统"; }
LastShotRecordModel model = new LastShotRecordModel();
model.No = LastShotRecordDataGrid.Count + 1;
model.System = system;
model.GunHead = record.GunCode;
// StationNumber = record.StationNumber,
model.IsoInjectionpressure = record.PolHp;
model.IsoInjectionpressure = record.IsoHp;
model.PolInjectiontemperature = record.PolTemp;
model.IsoInjectiontemperature = record.IsoTemp;
model.PolInjectionpressure = record.PolHp;
model.StationNumber = record.PourNu;
model.LastTime = record.CreateTime;
model.Createtime = record.CreateTime;
LastShotRecordDataGrid.Insert(0, model);
}));
}
#region 加载DataGrid数据
private async Task LoadData()
{
@ -74,29 +215,33 @@ namespace Aucma.Core.BoxFoam.ViewModels
int i = 1;
var list = await _boxLastShotRecordServices.QueryAsync();
if (list == null) return;
list.OrderByDescending(d => d.CreateTime);
foreach (var item in list.Take(50))
list.OrderByDescending(d => d.CreateTime).Take(30);
foreach (var item in list)
{
string system = string.Empty;
if (item.System == "1") { system = "1系统"; }
if (item.System == "2") { system = "2系统"; }
LastShotRecordDataGrid.Add(new LastShotRecordModel()
LastShotRecordModel model = new LastShotRecordModel();
if (LastShotRecordDataGrid.Count() == 0)
{
model.No = 1;
}
else
{
No = i,
System = system,
GunHead=item.GunCode,
// StationNumber=item.StationNumber,
PolInjectionpressure = item.PolHp,
IsoInjectionpressure = item.IsoHp,
PolInjectiontemperature = item.PolTemp,
IsoInjectiontemperature = item.IsoTemp,
LastTime = item.CreateTime,
Createtime = item.CreateTime
});
i++;
};
// Datalist.Insert(0, Datalist[Datalist.Count - 1]);
// Datalist.RemoveAt(Datalist.Count - 1);
model.No = LastShotRecordDataGrid.Count() + 1;
}
model.No = i;
model.System = system;
model.GunHead = item.GunCode;
model.PolInjectionpressure = item.PolHp;
model.IsoInjectionpressure = item.IsoHp;
model.PolInjectiontemperature = item.PolTemp;
model.IsoInjectiontemperature = item.IsoTemp;
model.LastTime = item.CreateTime;
model.Createtime = item.CreateTime;
model.StationNumber = item.PourNu;
LastShotRecordDataGrid.Insert(0, model);
}
}));
}
@ -228,79 +373,103 @@ namespace Aucma.Core.BoxFoam.ViewModels
get => _temperature1;
set => SetProperty(ref _temperature1, value);
}
/// <summary>
/// A枪状态
/// </summary>
private string _status1;
public string Status1
//private string _status1a;
//public string Status1a
//{
// get => _status1a;
// set => SetProperty(ref _status1a, value);
//}
/// <summary>
/// pol压力
/// </summary>
private string _POLPressure1a = "0.00";
public string POLPressure1a
{
get => _status1;
set => SetProperty(ref _status1, value);
get => _POLPressure1a;
set => SetProperty(ref _POLPressure1a, value);
}
/// <summary>
/// B枪状态
/// A枪POL温度
/// </summary>
private string _status11;
public string Status11
private string _POLTemperature1a = "0.00";
public string POLTemperature1a
{
get => _status11;
set => SetProperty(ref _status11, value);
get => _POLTemperature1a;
set => SetProperty(ref _POLTemperature1a, value);
}
/// <summary>
/// 压力
/// iso压力
/// </summary>
private string _POLPressure1 = "0.00";
public string POLPressure1
private string _ISOPressure1a = "0.00";
public string ISOPressure1a
{
get => _POLPressure1;
set => SetProperty(ref _POLPressure1, value);
get => _ISOPressure1a;
set => SetProperty(ref _ISOPressure1a, value);
}
/// <summary>
/// A枪POL温度
/// iso温度
/// </summary>
private string _POLTemperature1 = "0.00";
public string POLTemperature1
private string _ISOTemperature1a = "0.0";
public string ISOTemperature1a
{
get => _POLTemperature1;
set => SetProperty(ref _POLTemperature1, value);
get => _ISOTemperature1a;
set => SetProperty(ref _ISOTemperature1a, value);
}
/// <summary>
/// B枪POL温度
/// B枪状态
/// </summary>
private string _POLTemperature11 = "0.0";
public string POLTemperature11
//private string _status1b;
//public string Status1b
//{
// get => _status1b;
// set => SetProperty(ref _status1b, value);
//}
/// <summary>
/// B枪pol压力
/// </summary>
private string _POLPressure1b = "0.00";
public string POLPressure1b
{
get => _POLTemperature11;
set => SetProperty(ref _POLTemperature11, value);
get => _POLPressure1b;
set => SetProperty(ref _POLPressure1b, value);
}
/// <summary>
/// 压力
/// B枪POL温度
/// </summary>
private string _ISOPressure1 = "0.00";
public string ISOPressure1
private string _POLTemperature1b = "0.00";
public string POLTemperature1b
{
get => _ISOPressure1;
set => SetProperty(ref _ISOPressure1, value);
get => _POLTemperature1b;
set => SetProperty(ref _POLTemperature1b, value);
}
/// <summary>
/// 压力
/// B枪iso压力
/// </summary>
private string _ISOPressure11 = "0.00";
public string ISOPressure11
private string _ISOPressure1b = "0.00";
public string ISOPressure1b
{
get => _ISOPressure11;
set => SetProperty(ref _ISOPressure11, value);
get => _ISOPressure1b;
set => SetProperty(ref _ISOPressure1b, value);
}
/// <summary>
/// 温度
/// B枪iso温度
/// </summary>
private string _ISOTemperature11 = "0.0";
public string ISOTemperature11
private string _ISOTemperature1b = "0.0";
public string ISOTemperature1b
{
get => _ISOTemperature11;
set => SetProperty(ref _ISOTemperature11, value);
get => _ISOTemperature1b;
set => SetProperty(ref _ISOTemperature1b, value);
}
#endregion
#region 2系统属性
@ -415,100 +584,92 @@ namespace Aucma.Core.BoxFoam.ViewModels
get => _temperature2;
set => SetProperty(ref _temperature2, value);
}
/// <summary>
/// A枪状态
/// </summary>
private string _status2 = "";
public string Status2
{
get => _status2;
set => SetProperty(ref _status2, value);
}
/// <summary>
/// B枪状态
/// A枪POL压力
/// </summary>
private string _status12 = "";
public string Status12
private string _POLPressure2a = "0.00";
public string POLPressure2a
{
get => _status12;
set => SetProperty(ref _status12, value);
get => _POLPressure2a;
set => SetProperty(ref _POLPressure2a, value);
}
/// <summary>
/// 压力
/// A枪POL温度
/// </summary>
private string _POLPressure2 = "0.00";
public string POLPressure2
private string _POLTemperature2a = "0.00";
public string POLTemperature2a
{
get => _POLPressure2;
set => SetProperty(ref _POLPressure2, value);
get => _POLTemperature2a;
set => SetProperty(ref _POLTemperature2a, value);
}
/// <summary>
/// 温度
/// iso压力
/// </summary>
private string _POLTemperature2 = "0.00";
public string POLTemperature2
private string _ISOPressure2a = "0.00";
public string ISOPressure2a
{
get => _POLTemperature2;
set => SetProperty(ref _POLTemperature2, value);
get => _ISOPressure2a;
set => SetProperty(ref _ISOPressure2a, value);
}
/// <summary>
/// A枪压力
/// iso温度
/// </summary>
private string _ISOPressure2 = "0.00";
public string ISOPressure2
private string _ISOTemperature2a = "0.0";
public string ISOTemperature2a
{
get => _ISOPressure2;
set => SetProperty(ref _ISOPressure2, value);
get => _ISOTemperature2a;
set => SetProperty(ref _ISOTemperature2a, value);
}
/// <summary>
///A枪温度
/// B枪状态
/// </summary>
private string _ISOTemperature22 = "0.0";
public string ISOTemperature22
{
get => _ISOTemperature22;
set => SetProperty(ref _ISOTemperature22, value);
}
//private string _status2b;
//public string Status2b
//{
// get => _status2b;
// set => SetProperty(ref _status2b, value);
//}
/// <summary>
/// B枪温度
/// B枪pol压力
/// </summary>
private string _ISOTemperature222 = "0.0";
public string ISOTemperature222
private string _POLPressure2b = "0.00";
public string POLPressure2b
{
get => _ISOTemperature222;
set => SetProperty(ref _ISOTemperature222, value);
get => _POLPressure2b;
set => SetProperty(ref _POLPressure2b, value);
}
/// <summary>
/// B枪温度
/// B枪POL温度
/// </summary>
private string _POLPressure22 = "0.0";
public string POLPressure22
private string _POLTemperature2b = "0.00";
public string POLTemperature2b
{
get => _POLPressure22;
set => SetProperty(ref _POLPressure22, value);
get => _POLTemperature2b;
set => SetProperty(ref _POLTemperature2b, value);
}
/// <summary>
/// B枪ISO温度
/// B枪iso压力
/// </summary>
private string _POLTemperature22 = "0.0";
public string POLTemperature22
private string _ISOPressure2b = "0.00";
public string ISOPressure2b
{
get => _POLTemperature22;
set => SetProperty(ref _POLTemperature22, value);
get => _ISOPressure2b;
set => SetProperty(ref _ISOPressure2b, value);
}
/// <summary>
/// B枪ISO压力
/// B枪iso温度
/// </summary>
private string _ISOPressure22 = "0.0";
public string ISOPressure22
private string _ISOTemperature2b = "0.0";
public string ISOTemperature2b
{
get => _ISOPressure22;
set => SetProperty(ref _ISOPressure22, value);
get => _ISOTemperature2b;
set => SetProperty(ref _ISOTemperature2b, value);
}
#endregion
}
}

@ -342,7 +342,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
else
{
// 白夜班切换
ShiftChangeAsync(productLineCode, currentTeamTime);
ShiftChangeAsync(productLineCode);
}
}
@ -422,7 +422,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
}
}
private async void ShiftChangeAsync(string productLineCode, CurrentTeamTime currentTeamTime)
private async void ShiftChangeAsync(string productLineCode)
{
try
{
@ -434,9 +434,11 @@ namespace Aucma.Core.BoxFoam.ViewModels
//更新计划表操作
//CurrentTeamTime currentTeamTime = await _currentTeamTimeServices.FirstAsync();
CurrentTeamTime currentTeamTime = await _currentTeamTimeServices.FirstAsync();
// 更新当班时间
currentTeamTime.TeamName = currentTeamTimeList.FirstOrDefault().TeamName;
currentTeamTime.TeamName = currentTeamTimeList.First().TeamName;
currentTeamTime.StartTime = currentTeamTimeList.Min(d => d.StartTime);
currentTeamTime.EndTime = currentTeamTimeList.Max(d => d.EndTime);
bool result = await _currentTeamTimeServices.UpdateAsync(currentTeamTime);

@ -20,6 +20,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();
public MainWindowViewModel()
{
UserContent = firstPage;

@ -44,7 +44,7 @@
<Setter Property="FontSize" Value="18"/>
<Setter Property="Background" Value="#4285DE"/>
<Setter Property="Foreground" Value="White"/>
</Style>
<!--单元格样式-->
@ -54,7 +54,7 @@
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="Height" Value="40"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
@ -147,7 +147,7 @@
<TextBlock Text="输入压力" FontSize="18" Foreground="White"/>
</StackPanel>
<WrapPanel Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding POPressure}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="{Binding PolInputPressure1}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="MPa" FontSize="18" Foreground="White" />
</WrapPanel>
<WrapPanel Grid.Column="2" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Left">
@ -233,7 +233,7 @@
<TextBlock Text="B枪" FontSize="18" FontWeight="Bold" Foreground="White"/>
</Border>
<WrapPanel Grid.Column="0" Grid.Row="10" VerticalAlignment="Center" HorizontalAlignment="Right">
<TextBlock Text="状态" FontSize="18" Foreground="White"/>
<!--<TextBlock Text="状态" FontSize="18" Foreground="White"/>-->
</WrapPanel>
<WrapPanel Grid.Column="1" Grid.Row="10" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Text="{Binding Status1}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
@ -246,11 +246,11 @@
<TextBlock Text="POL压力" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="1" Grid.Row="11" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding POLPressure1}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="{Binding POLPressure1a}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="MPa" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="2" Grid.Row="11" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding POLPressure1}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="{Binding POLPressure1b}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="MPa" FontSize="18" Foreground="White"/>
</WrapPanel>
@ -258,11 +258,11 @@
<TextBlock Text="POL温度" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="1" Grid.Row="12" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding POLTemperature1}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="{Binding POLTemperature1a}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="℃" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="2" Grid.Row="12" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding POLTemperature11}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="{Binding POLTemperature1b}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="℃" FontSize="18" Foreground="White"/>
</WrapPanel>
@ -270,27 +270,27 @@
<TextBlock Text="ISO压力" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="1" Grid.Row="13" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding ISOPressure1}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="{Binding ISOPressure1a}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="MPa" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="2" Grid.Row="13" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding ISOPressure11}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="{Binding ISOPressure1b}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="℃" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="0" Grid.Row="14" VerticalAlignment="Center" HorizontalAlignment="Right">
<TextBlock Text="ISO温度" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="1" Grid.Row="14" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding ISOTemperature11}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="{Binding ISOTemperature1a}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="℃" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="2" Grid.Row="14" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding ISOTemperature11}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="{Binding ISOTemperature1b}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="℃" FontSize="18" Foreground="White"/>
</WrapPanel>
</Grid>
</Border>
</Grid>
</Grid>
</Border>
</Grid>
</Border>
@ -429,7 +429,7 @@
<TextBlock Text="B枪" FontSize="18" FontWeight="Bold" Foreground="White"/>
</Border>
<WrapPanel Grid.Column="0" Grid.Row="10" VerticalAlignment="Center" HorizontalAlignment="Right">
<TextBlock Text="状态" FontSize="18" Foreground="White"/>
<!--<TextBlock Text="状态" FontSize="18" Foreground="White"/>-->
</WrapPanel>
<WrapPanel Grid.Column="1" Grid.Row="10" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding Status2}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="50"/>
@ -441,16 +441,16 @@
<WrapPanel Grid.Column="0" Grid.Row="11" VerticalAlignment="Center" HorizontalAlignment="Right">
<TextBlock Text="POL压力" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="0" Grid.Row="11" VerticalAlignment="Center" HorizontalAlignment="Right">
<TextBlock Text="POL压力" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="1" Grid.Row="11" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding POLPressure2}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="{Binding POLPressure2a}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="MPa" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="2" Grid.Row="11" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding POLPressure22}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="{Binding POLPressure2b}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="MPa" FontSize="18" Foreground="White"/>
</WrapPanel>
@ -458,11 +458,11 @@
<TextBlock Text="POL温度" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="1" Grid.Row="12" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding POLTemperature2}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="{Binding POLTemperature2a}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="℃" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="2" Grid.Row="12" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding POLTemperature22}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="{Binding POLTemperature2b}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="℃" FontSize="18" Foreground="White"/>
</WrapPanel>
@ -470,11 +470,11 @@
<TextBlock Text="ISO压力" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="1" Grid.Row="13" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding ISOPressure2}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="{Binding ISOPressure2a}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="MPa" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="2" Grid.Row="13" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding ISOPressure22}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="{Binding ISOPressure2b}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="MPa" FontSize="18" Foreground="White"/>
</WrapPanel>
@ -482,11 +482,11 @@
<TextBlock Text="ISO温度" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="1" Grid.Row="14" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding ISOTemperature22}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="{Binding ISOTemperature2a}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="℃" FontSize="18" Foreground="White"/>
</WrapPanel>
<WrapPanel Grid.Column="2" Grid.Row="14" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="{Binding ISOTemperature222}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="{Binding ISOTemperature2b}" FontSize="18" Margin="0 0 18 0" Foreground="White" Width="200" VerticalAlignment="Center" Block.TextAlignment="Center"/>
<TextBlock Text="℃" FontSize="18" Foreground="White"/>
</WrapPanel>
</Grid>

@ -212,6 +212,14 @@
"Enabled": true,
"IP": "10.10.93.1",
"Port": 102
},
{
"Id": 3,
"EquipName": "foamMachinePlc",
"PlcType": "Siemens",
"Enabled": true,
"IP": "10.10.93.180",
"Port": 102
}
],
"StoreInfo": {

@ -2,28 +2,19 @@
using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using Admin.Core.Model.ViewModels;
using Admin.Core.Service;
using Admin.Core.Tasks;
using Aucma.Core.HwPLc;
using Aucma.Core.OldBoxFoam.Business;
using Aucma.Core.OldBoxFoam.Models;
using Aucma.Core.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using log4net;
using Microsoft.Extensions.DependencyInjection;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
using System.Windows.Documents;
/**
* 线
* */
@ -300,7 +291,6 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
BoxFoamDataRealTime bfd = bfds.SingleOrDefault(d => d.FixtureBoxtype == bLis[j].FixtureBoxType && d.SerialNumber == bLis[j].ObjId);
if (bfd != null)
{
//更新计划数量
complateAmount = bLis[j].Yield - bfd.FixtureProductioncapacity;
UpdateClampData(bLis[j], bfd);

@ -11,21 +11,15 @@ using System.Threading.Tasks;
using Admin.Core.IService;
using Microsoft.Extensions.DependencyInjection;
using Aucma.Core.SheetMetal.Common;
using Admin.Core.Tasks;
using CommunityToolkit.Mvvm.Messaging;
using LiveCharts;
using LiveCharts.Wpf;
using Admin.Core.Model;
using System.Windows.Media;
using log4net;
using Admin.Core.Common;
using LiveCharts.Defaults;
using Aucma.Core.SheetMetal.Business;
using static Aucma.Core.SheetMetal.Business.SheetMetalPlanTaskHandle;
using System.Threading;
using NetTaste;
using Aucma.Core.HwPLc;
using Admin.Core.Model.ViewModels;
using Admin.Core.Service;
using NPOI.SS.Formula.Functions;
/*
*
*/
@ -34,9 +28,9 @@ namespace Aucma.Core.SheetMetal.ViewModels
public partial class IndexPageViewModel : ObservableObject
{
protected readonly IExecutePlanInfoServices? _taskExecutionPlanInfoServices;
protected readonly ISysUserInfoServices? _sysUserInfoServices;
//private SheetMetalPlanTaskHandle _taskHandle = new SheetMetalPlanTaskHandle();
protected readonly IRecordBackPanelComplateServices _recordBackPanelComplateServices;
protected readonly IRecordSidePanelComplateServices _recordSidePanelComplateServices;
protected readonly IBaseBomInfoServices _baseBomInfoServices;
private AppConfigHelper appConfig = new AppConfigHelper();
List<SelectModel> list = new List<SelectModel>() { new SelectModel()
{
@ -55,14 +49,16 @@ namespace Aucma.Core.SheetMetal.ViewModels
{
_stationName = Appsettings.app("StationInfo", "StationName");//工位名称
_taskExecutionPlanInfoServices = App.ServiceProvider.GetService<IExecutePlanInfoServices>();
_sysUserInfoServices = App.ServiceProvider.GetService<ISysUserInfoServices>();
_recordBackPanelComplateServices = App.ServiceProvider.GetService<IRecordBackPanelComplateServices>();
_recordSidePanelComplateServices = App.ServiceProvider.GetService<IRecordSidePanelComplateServices>();
_baseBomInfoServices = App.ServiceProvider.GetService<IBaseBomInfoServices>();
//Job_SheetMetalTask_Quartz.SmEverDayDelegateEvent += InitEveryDayMethod;
//Job_SheetMetalTask_Quartz.SmTaskDelegateEvent += UpdatePlanSHow;//计划内容展示
//WeakReferenceMessenger.Default.Register<string>(this, Recive);
Task.WaitAll(LoadData());
//InitEveryDayMethod();
AddSelectData();//添加下拉菜单
//RefreshHourAmount();//小时产量
RefreshHourAmount();//小时产量
//RefreshMaterialStats();//型号产量
SheetMetalPlanTaskHandle.RefreshCurrentPlanInfoEvent += RefreshCurrentPlanInfo;
}
@ -669,17 +665,20 @@ namespace Aucma.Core.SheetMetal.ViewModels
App.Current.Dispatcher.Invoke((Action)(() =>
{
//获取小时产量
string stationCode = Appsettings.app("StoreInfo", "StationCode");
List<dynamic> hourAmount = _sysUserInfoServices.GetStationHourAmountAsync(stationCode);
string stationCode = Appsettings.app("StationInfo", "StationCode");
List<dynamic> hourAmount = _taskExecutionPlanInfoServices.GetStationSheetMetalHourAmountAsync(stationCode).Result;
if (hourAmount != null)
{
Achievement.Clear();
ProductionHourList = new List<string>();
ChartValues<double> hourAchievement = new ChartValues<double>();
//ChartValues<double> hourAchievement = new ChartValues<double>();
ChartValues<ObservablePoint> hourAchievement = new ChartValues<ObservablePoint>();
foreach (var item in hourAmount)
{
ObservablePoint point=new ObservablePoint(Convert.ToInt32(item.SIDPANELHOURAMOUNT), Convert.ToInt32(item.BACKPANELHOURAMOUNT));
ProductionHourList.Add(item.PRODUCT_HOUR);
hourAchievement.Add(Convert.ToDouble(item.PRODUCT_AMOUNT));
hourAchievement.Add(point);
//hourAchievement.Add(Convert.ToDouble(item.PRODUCT_AMOUNT));
}
var houeColumn = new ColumnSeries();
houeColumn.DataLabels = true;
@ -689,7 +688,57 @@ namespace Aucma.Core.SheetMetal.ViewModels
Achievement.Add(houeColumn);
}
}));
}
}
#endregion
#region 刷新物料型号统计
/// <summary>
/// 刷新物料型号统计
/// </summary>
private void RefreshMaterialStats()
{
App.Current.Dispatcher.Invoke((Action)(() =>
{
//获取物料型号统计
string stationCode = Appsettings.app("StationInfo", "StationCode");
List<dynamic> materialStats = _taskExecutionPlanInfoServices.GetStationMaterialStats(stationCode).Result;
var baseBomInfoList = _baseBomInfoServices.QueryAsync().Result;
var taskExecutionPlanInfo=_taskExecutionPlanInfoServices.QueryAsync(d=>d.ProductLineCode== stationCode).Result;
var recordBackPanelList = _recordBackPanelComplateServices.QueryAsync().Result;
//有问题,需要修改才可以
var list = (from d in recordBackPanelList
join t in taskExecutionPlanInfo on d.PlanCode equals t.TaskCode
join b in baseBomInfoList on d.MaterialCode equals b.MaterialCode
select new
{
MaterialCode=b.MaterialCode,
ProductPlanCode=t.ProductPlanCode,
CompleteAmount= t.CompleteAmount
}).ToList();
if (list != null)
{
ModelStatistics.Clear();
MaterialNameList = new List<string>();
ChartValues<double> materialAchievement = new ChartValues<double>();
foreach (var item in materialStats)
{
MaterialNameList.Add(item.MATERIAL_NAME);
materialAchievement.Add(Convert.ToDouble(item.PRODUCT_AMOUNT));
}
var materialColumn = new ColumnSeries();
materialColumn.DataLabels = true;
materialColumn.Title = "型号";
materialColumn.Values = materialAchievement;
materialColumn.Foreground = Brushes.White;
ModelStatistics.Add(materialColumn);
}
}));
#endregion
}
}
}

@ -10,7 +10,7 @@ using System.Windows.Interop;
using System.Collections.ObjectModel;
using Admin.Core.Common;
using System.IO;
using Aucma.Core.PLc;
using Aucma.Core.HwPLc;
using Aucma.Core.Scanner;
using System.Linq;
using System.Threading.Tasks;

@ -44,7 +44,7 @@
"ConnId": "AUCMA_SCADA",
"DBType": 3,
"Enabled": true,
"HitRate": 50,
"HitRate": 30,
//"Connection": "Data Source=localhost;Initial Catalog=Hsdb;User ID=sa;Password=sa;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
"Connection": "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.100.72.20)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ORCLCDB)));User ID=c##aucma_scada;Password=aucma;",
"ProviderName": "System.Data.SqlClient"

@ -46,7 +46,6 @@ namespace Aucma.Core.Tasks.Business
{
while (true)
{
semaphore.WaitOne();
try
{
Thread.Sleep(3000);
@ -56,9 +55,24 @@ namespace Aucma.Core.Tasks.Business
//采集数据
ReadEquipSystem(obj,record, perfusion_DeviceStatus, perfusion_Alarm);
//更新设备状态
// _perfusionDeviceStatusServices.UpdateAsync;
// 更新报警信息
Perfusion_DeviceStatus device = _perfusionDeviceStatusServices.FirstAsync().Result;
if (device == null)
{
_ = _perfusionDeviceStatusServices.AddAsync(perfusion_DeviceStatus).Result;
}
else
{
_perfusionDeviceStatusServices.UpdateAsync(perfusion_DeviceStatus);
}
//// 更新报警信息
_perfusionAlarmServices.AddAsync(perfusion_Alarm);
//Perfusion_Alarm alarmRecord = _perfusionAlarmServices.FirstAsync(x=>x.PerfusionBoxcode==perfusion_Alarm.PerfusionBoxcode).Result;
//if (alarmRecord == null)
//{
//}
//充注结束
if (record.PerfusionFinishStatus == "1")
{
@ -81,7 +95,6 @@ namespace Aucma.Core.Tasks.Business
}
}
}
catch (Exception ex)
{
@ -89,9 +102,7 @@ namespace Aucma.Core.Tasks.Business
}
finally
{
temprRecord = record;
semaphore.Release();
}
}

Loading…
Cancel
Save