dev
liuwf 1 year ago
parent c387512c5a
commit 57507f4dfc

@ -326,20 +326,23 @@ namespace Aucma.Core.BoxFoam.ViewModels
public async void RealTimeFoamingTask(object? sender, ElapsedEventArgs e) public async void RealTimeFoamingTask(object? sender, ElapsedEventArgs e)
{ {
semaphore.WaitOne(); semaphore.WaitOne();
try try
{ {
string productLineCode = Appsettings.app("StationInfo", "ProductLineCode"); string productLineCode = Appsettings.app("StationInfo", "ProductLineCode");
DateTime now = DateTime.Now; DateTime now = DateTime.Now;
List<CurrentTeamTime> timeList = await _currentTeamTimeServices.QueryAsync(d => d.StartTime <= now && d.EndTime >= now); CurrentTeamTime currentTeamTime = await _currentTeamTimeServices.FirstAsync(d => d.StartTime <= now && d.EndTime >= now);
if (timeList.Count>0) if (currentTeamTime!=null)
{ {
//比较计划更新数据
ExecHourDataAsync(productLineCode); ExecHourDataAsync(productLineCode);
} }
else else
{ {
ShiftChangeAsync(productLineCode); // 白夜班切换
ShiftChangeAsync(productLineCode, currentTeamTime);
} }
} }
@ -371,7 +374,6 @@ namespace Aucma.Core.BoxFoam.ViewModels
BoxFoamDataRealTime bfd = bfds.SingleOrDefault(d => d.FixtureBoxtype == bLis[j].FixtureBoxType && d.SerialNumber == bLis[j].ObjId); BoxFoamDataRealTime bfd = bfds.SingleOrDefault(d => d.FixtureBoxtype == bLis[j].FixtureBoxType && d.SerialNumber == bLis[j].ObjId);
if (bfd != null) if (bfd != null)
{ {
//更新计划数量 //更新计划数量
complateAmount = bLis[j].Yield - bfd.FixtureProductioncapacity; complateAmount = bLis[j].Yield - bfd.FixtureProductioncapacity;
UpdateClampData(bLis[j], bfd); UpdateClampData(bLis[j], bfd);
@ -420,29 +422,29 @@ namespace Aucma.Core.BoxFoam.ViewModels
} }
} }
private async void ShiftChangeAsync(string productLineCode) private async void ShiftChangeAsync(string productLineCode, CurrentTeamTime currentTeamTime)
{ {
try try
{ {
//切换班组计划 //切换班组计划
var currentTeamTimeList = await _sysUserInfoServices.GetTeamData(); var currentTeamTimeList = await _sysUserInfoServices.GetTeamData();
if (currentTeamTimeList.Count == 0) return; if (currentTeamTimeList.Count == 0) return;
// 夹具
var list = await _boxFoamDataRealTimeServices.QueryAsync(d => d.ProductlineCode == productLineCode); var list = await _boxFoamDataRealTimeServices.QueryAsync(d => d.ProductlineCode == productLineCode);
//更新计划表操作 //更新计划表操作
CurrentTeamTime currentTeamTime = await _currentTeamTimeServices.FirstAsync();
//CurrentTeamTime currentTeamTime = await _currentTeamTimeServices.FirstAsync();
// 更新当班时间
currentTeamTime.TeamName = currentTeamTimeList.FirstOrDefault().TeamName; currentTeamTime.TeamName = currentTeamTimeList.FirstOrDefault().TeamName;
currentTeamTime.StartTime = currentTeamTimeList.Min(d => d.StartTime); currentTeamTime.StartTime = currentTeamTimeList.Min(d => d.StartTime);
currentTeamTime.EndTime = currentTeamTimeList.Max(d => d.EndTime); currentTeamTime.EndTime = currentTeamTimeList.Max(d => d.EndTime);
bool result = await _currentTeamTimeServices.UpdateAsync(currentTeamTime); bool result = await _currentTeamTimeServices.UpdateAsync(currentTeamTime);
if (result) if (result)
{ {
var obj2 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc"));
if (obj2 == null) { return; }
//清空 当班计划 //清空 当班计划
var realTimeList = await _boxFoamDataRealTimeHistoryServices.QueryAsync(d => d.ProductlineCode == productLineCode); // var realTimeList = await _boxFoamDataRealTimeHistoryServices.QueryAsync(d => d.ProductlineCode == productLineCode);
await _boxFoamDataRealTimeHistoryServices.DeletesAsync(realTimeList);
var plan = await _boxFoamPlanServices.QueryAsync(d => d.ProductLineCode == productLineCode); var plan = await _boxFoamPlanServices.QueryAsync(d => d.ProductLineCode == productLineCode);
await _boxFoamPlanServices.DeletesAsync(plan); await _boxFoamPlanServices.DeletesAsync(plan);
@ -458,7 +460,6 @@ namespace Aucma.Core.BoxFoam.ViewModels
/// </summary> /// </summary>
public async void UpdateClampData(FixtureStatus fixtureStatus, BoxFoamDataRealTime bfd) public async void UpdateClampData(FixtureStatus fixtureStatus, BoxFoamDataRealTime bfd)
{ {
try try
{ {
bfd.FixtureBoxtype = fixtureStatus.FixtureBoxType; bfd.FixtureBoxtype = fixtureStatus.FixtureBoxType;

Loading…
Cancel
Save