diff --git a/Admin.Core.Repository/Repository_New/SysUserInfoRepository.cs b/Admin.Core.Repository/Repository_New/SysUserInfoRepository.cs new file mode 100644 index 00000000..54f1eafd --- /dev/null +++ b/Admin.Core.Repository/Repository_New/SysUserInfoRepository.cs @@ -0,0 +1,43 @@ +using Admin.Core.Model; +using Admin.Core.IRepository; +using System.Threading.Tasks; +using Admin.Core.Model.ViewModels; +using Admin.Core.Model.Model_New; +using System.Collections.Generic; +using System; + +namespace Admin.Core.Repository +{ + /// + /// SysUserInfoRepository + /// + public class SysUserInfoRepository : BaseRepository, ISysUserInfoRepository + { + public SysUserInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + + public async Task> GetStationData(string code) + { + string sql = @$"SELECT BP.PLANT_CODE PLANT_CODE, BP.PARENT_ID PRODUCT_LINE_CODE, BPS.PROCESS_CODE, BP.PRODUCT_LINE_CODE STATION_CODE + FROM BASE_PRODUCTLINE BP + LEFT JOIN BASE_PROCESS_STATION BPS ON BPS.PARENT_ID LIKE '%' || BP.PRODUCT_LINE_CODE || '%' + WHERE BP.PRODUCT_LINE_CODE = '{code}'"; + return await Db.Ado.SqlQueryAsync(sql); + } + + #region 获取班组数据 + /// + /// 获取班组数据 + /// + /// + /// + public async Task> GetTeamData() + { + string sql = "SELECT * FROM VIEW_CURRENT_TEAM_TIME"; + return await Db.Ado.SqlQueryAsync(sql); + } + + #endregion + } +} \ No newline at end of file diff --git a/Aucma.Core.HwPLc/Impl/MelsecPlc.cs b/Aucma.Core.HwPLc/Impl/MelsecPlc.cs index 4ac238a4..a6648ecc 100644 --- a/Aucma.Core.HwPLc/Impl/MelsecPlc.cs +++ b/Aucma.Core.HwPLc/Impl/MelsecPlc.cs @@ -76,7 +76,7 @@ namespace Aucma.Core.HwPLc /// public bool Connect(string iP, int port) { - melsecMcNet.IpAddress = iP;//正式环境开启 + //melsecMcNet.IpAddress = iP;//正式环境开启 melsecMcNet.Port = port; // 如果网络不太理想,配置了两个端口,一个有问题,立即切换另一个的话,可以配置如下的代码 diff --git a/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs b/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs index 01a85dc7..45ad9d2b 100644 --- a/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs +++ b/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs @@ -18,6 +18,7 @@ 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; @@ -361,37 +362,43 @@ namespace Aucma.Core.OldBoxFoam.ViewModels collection.startCollect(); bLis = collection.listFixtureStatus; if (bLis.Count == 0) return; - + int total = 0; + List bfds = await _oldBoxFoamDataServices.QueryAsync(); + List spaceList = await _oldBoxFoamTypeServices.QueryAsync(); + List < BoxFoamPlan> planList = await _boxFoamPlanServices.QueryAsync(); for (int j = 0; j < bLis.Count; j++) { - OldBoxFoamType space = await _oldBoxFoamTypeServices.FirstAsync(d => d.Boxtype == bLis[j].FixtureBoxType); + OldBoxFoamType space = spaceList.FirstOrDefault(d => d.Boxtype == bLis[j].FixtureBoxType); //根据夹具找货道,根据货道找物料 if (space != null) { - BoxFoamPlan plan = _boxFoamPlanServices.FirstAsync(d => d.MaterialCode == space.MaterialCode).Result; + BoxFoamPlan plan = planList.FirstOrDefault(d => d.MaterialCode == space.MaterialCode && d.PlanAmount > d.CompleteAmount); if (plan != null) { - plan.CompleteAmount = plan.CompleteAmount + 1; - await _boxFoamPlanServices.UpdateAsync(plan); + int complateAmount = 0; //更新小时数据 - BoxFoamData bfd = await _oldBoxFoamDataServices.FirstAsync(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId); + BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId); if (bfd != null) { UpdateBoxData(bLis[j], bfd); + //更新计划数量 + complateAmount = bLis[j].Yield - bfd.Production; } else { SaveBoxData(productLineCode, bLis[j]); } + plan.CompleteAmount = plan.CompleteAmount + complateAmount; + await _boxFoamPlanServices.UpdateAsync(plan); } else { //更新小时数据 - List bfd = await _oldBoxFoamDataServices.QueryAsync(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId); - if (bfd.Count > 0) + //List bfd = await _oldBoxFoamDataServices.QueryAsync(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId); + BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId); + if (bfd!=null) { - var obj = bfd.FirstOrDefault(); - UpdateBoxData(bLis[j], obj); + UpdateBoxData(bLis[j], bfd); } else @@ -403,11 +410,12 @@ namespace Aucma.Core.OldBoxFoam.ViewModels else { //更新小时数据 - List bfd = await _oldBoxFoamDataServices.QueryAsync(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId); - if (bfd.Count > 0) + //List bfd = await _oldBoxFoamDataServices.QueryAsync(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId); + + BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId); + if (bfd != null) { - var obj = bfd.FirstOrDefault(); - UpdateBoxData(bLis[j], obj); + UpdateBoxData(bLis[j], bfd); } else { @@ -420,13 +428,12 @@ namespace Aucma.Core.OldBoxFoam.ViewModels { Console.WriteLine(ex.Message); } - } private async void UpdateBoxData(FixtureStatus item, BoxFoamData bfd) { - - switch (GetTeamHour().Seq) + int hour = GetTeamHour(DateTime.Now).Seq; + switch (hour) { case 1: bfd.AnHour = item.Yield - bfd.Production; @@ -467,7 +474,9 @@ namespace Aucma.Core.OldBoxFoam.ViewModels default: break; } + bfd.Production = item.Yield; + await _oldBoxFoamDataServices.UpdateAsync(bfd); } @@ -481,7 +490,8 @@ namespace Aucma.Core.OldBoxFoam.ViewModels bfdata.Production = item.Yield; bfdata.CuringTimeSettingValue = item.PlanCuringTime.ToString(); bfdata.ActualValue = item.RealCuringTime.ToString(); - switch (GetTeamHour().Seq) + int hour = GetTeamHour(DateTime.Now).Seq; + switch (hour) { case 1: bfdata.AnHour = item.Yield = bfdata.Production; @@ -538,5 +548,15 @@ namespace Aucma.Core.OldBoxFoam.ViewModels } return null; } + + public CurrentTeamTimeView GetTeamHour(DateTime now) + { + var obj = _sysUserInfoServices.GetTeamData(now).Result; + if (obj != null) + { + return obj; + } + return null; + } } }