| | |
| | | using DocumentFormat.OpenXml.Office.CustomUI; |
| | | using Microsoft.CodeAnalysis.Operations; |
| | | using Admin.NET.Application.Service.WmsTask.WmsRbLineTask.Dto; |
| | | using Admin.NET.Application.Service.WmsCommonnQuery.Dto; |
| | | using System.Collections.Generic; |
| | | |
| | | namespace Admin.NET.Application; |
| | | /// <summary> |
| | | /// 通用查询服务 |
| | | /// </summary> |
| | | [ApiDescriptionSettings(ApplicationConst.WmsCommonnQueryGroupName, Order = 100)] |
| | | [AllowAnonymous] |
| | | public class WmsCommonnQueryService : IDynamicApiController, ITransient |
| | | { |
| | | private readonly SqlSugarRepository<WmsRbLineTask> _rep; |
| | |
| | | private readonly SqlSugarRepository<SysConfig> _sysConfigRep; |
| | | private readonly SqlSugarRepository<Mes_BatchOrderUPI_New> _mesBatchOrderUpiRep; |
| | | private readonly SqlSugarRepository<Mes_Order_Gather> _mesOrderGatherRep; |
| | | private readonly SqlSugarRepository<Mes_Package_UnLine_Record> _mesPackage_UnLine_RecordRep; |
| | | private readonly SqlSugarRepository<Mes_Package_LineQueue> _mesPackage_LineQueueRep; |
| | | |
| | | public WmsCommonnQueryService(SqlSugarRepository<WmsRbLineTask> rep, SqlSugarRepository<WmsStockQuan> wmsStockQuanRep |
| | | , SqlSugarRepository<Mes_Package_Gather> mesPackageGatherRep |
| | | , SqlSugarRepository<SysConfig> sysConfigRep |
| | | , SqlSugarRepository<Mes_BatchOrderUPI_New> mesBatchOrderUpiRep |
| | | , SqlSugarRepository<Mes_Order_Gather> mesOrderGatherRep |
| | | , SqlSugarRepository<Mes_Package_UnLine_Record> mesPackage_UnLine_RecordRep |
| | | , SqlSugarRepository<Mes_Package_LineQueue> mesPackage_LineQueueRep |
| | | ) |
| | | { |
| | | _sysConfigRep = sysConfigRep; |
| | |
| | | _wmsStockQuanRep = wmsStockQuanRep; |
| | | _mesBatchOrderUpiRep = mesBatchOrderUpiRep; |
| | | _mesOrderGatherRep = mesOrderGatherRep; |
| | | _mesPackage_UnLine_RecordRep = mesPackage_UnLine_RecordRep; |
| | | _mesPackage_LineQueueRep = mesPackage_LineQueueRep; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | return list; // 结果 |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 查询 计划生产订单记录 (大屏使用) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | [ApiDescriptionSettings(Name = "QueryPlanOrderList")] |
| | | [Description("WmsCommonnQuery/QueryPlanOrderList")] |
| | | public async Task<List<Mes_Order_Gather>> QueryPlanOrderList() |
| | | { |
| | | var list = await _mesPackage_LineQueueRep.AsQueryable() |
| | | .OrderBy(g => g.Id) |
| | | .ToListAsync(); // 确保获取结果为 List |
| | | List<Mes_Order_Gather> resultList = new List<Mes_Order_Gather>(); |
| | | foreach (var item in list) |
| | | { |
| | | if (resultList.Select(x => x.Info5).ToList().Contains(item.Info5)) |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | var mesOrderGather = await _mesOrderGatherRep.GetFirstAsync(x => x.Info5 == item.Info5); |
| | | if (mesOrderGather != null) |
| | | { |
| | | resultList.Add(mesOrderGather); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return resultList; // 结果 |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 查询 历史生产订单记录 (大屏使用) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | [ApiDescriptionSettings(Name = "QueryHistoryOrderList")] |
| | | [Description("WmsCommonnQuery/QueryHistoryOrderList")] |
| | | public async Task<List<Mes_Order_Gather>> QueryHistoryOrderList() |
| | | { |
| | | //获取上班时间。 |
| | | var sysConfig_wms_unline_time = await _sysConfigRep.GetFirstAsync(x => x.Code == CommonConst.wms_unline_time); |
| | | if (sysConfig_wms_unline_time == null || sysConfig_wms_unline_time.Value == "无") |
| | | { |
| | | return null; |
| | | } |
| | | var unLineTime = Convert.ToDateTime(sysConfig_wms_unline_time.Value); |
| | | |
| | | var list = await _mesOrderGatherRep.AsQueryable() |
| | | .Where(x => x.UnlineTime >= unLineTime) |
| | | .Where(x => x.IsUnline == true) |
| | | .OrderByDescending(g => g.Id) |
| | | .ToListAsync(); // 确保获取结果为 List |
| | | |
| | | return list; // 结果 |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 查询 当前生产订单记录 (大屏使用) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | [ApiDescriptionSettings(Name = "QueryCurrentOrder")] |
| | | [Description("WmsCommonnQuery/QueryCurrentOrder")] |
| | | public async Task<Mes_Order_Gather> QueryCurrentOrder() |
| | | { |
| | | //获取上班时间。 |
| | | var sysConfig_wms_wms_unline_oper = await _sysConfigRep.GetFirstAsync(x => x.Code == CommonConst.wms_unline_oper); |
| | | if (sysConfig_wms_wms_unline_oper == null || sysConfig_wms_wms_unline_oper.Value == "无") |
| | | { |
| | | return null; |
| | | } |
| | | var arr = sysConfig_wms_wms_unline_oper.Value.Split('|'); |
| | | var packagecode = arr[0]; |
| | | var packObj = await _mesPackageGatherRep.AsQueryable().FirstAsync(x => x.PackageCode == packagecode); |
| | | if (packObj == null) |
| | | { |
| | | throw Oops.Oh($"没有找到包{packagecode}的汇总数据"); |
| | | } |
| | | |
| | | var list = await _mesOrderGatherRep.AsQueryable() |
| | | .Where(x => x.Info5 == packObj.Info5) |
| | | .FirstAsync(); // 确保获取结果为 List |
| | | |
| | | return list; // 结果 |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 大屏 - 登录人 登录时间 LS070700117B0005GS |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | [ApiDescriptionSettings(Name = "ScreenLogin")] |
| | | [Description("WmsCommonnQuery/ScreenLogin")] |
| | | [AllowAnonymous] |
| | | public async Task<ScreenLoginUserOutput> ScreenLogin([FromQuery] Mes_Package_LineQueueInput input) |
| | | { |
| | | // 基本查询 |
| | | var list = await _sysConfigRep.AsQueryable() |
| | | .Where(x => x.Code == "wms_bz30_qitao" || x.Code == "wms_unline_oper" || x.Code == "wms_unline_time") |
| | | .ToListAsync(); |
| | | // 检查list是否为空 |
| | | if (list == null || !list.Any()) |
| | | { |
| | | // 返回默认值或者抛出异常 |
| | | return new ScreenLoginUserOutput |
| | | { |
| | | LoginUser = null, |
| | | TimeLogin = null, |
| | | }; |
| | | } |
| | | |
| | | //获取上班时间。 |
| | | DateTime unLineTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")); |
| | | var sysConfig_wms_unline_time = await _sysConfigRep.GetFirstAsync(x => x.Code == CommonConst.wms_unline_time); |
| | | if (sysConfig_wms_unline_time == null || sysConfig_wms_unline_time.Value == "无") |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | unLineTime = Convert.ToDateTime(sysConfig_wms_unline_time.Value); |
| | | } |
| | | |
| | | |
| | | var recordList = await _mesPackage_UnLine_RecordRep.AsQueryable() |
| | | .Where(x => x.CreateTime >= unLineTime) |
| | | .ToListAsync(); // 确保获取结果为 List |
| | | //汇总数据 |
| | | |
| | | |
| | | TimeSpan ts = DateTime.Now - unLineTime; |
| | | |
| | | // 返回结果 |
| | | return new ScreenLoginUserOutput |
| | | { |
| | | LoginUser = list.FirstOrDefault(x => x.Code == "wms_unline_oper")?.Value, |
| | | TimeLogin = list.FirstOrDefault(x => x.Code == "wms_unline_time")?.Value, |
| | | AllOrderNum = recordList.GroupBy(x => x.Info5).Count(), |
| | | AllPackageArea = recordList.Sum(x => Convert.ToDecimal((x.Info13))), |
| | | PackageNum = recordList.GroupBy(x => x.PackageCode).Count(), |
| | | WorkTime = ts.TotalHours |
| | | }; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |