| | |
| | | using WIDESEA_Core.Const; |
| | | using WIDESEA_DTO.MOM; |
| | | using WIDESEA_DTO.WMS; |
| | | using WIDESEA_Model.Models.Basic; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | |
| | |
| | | |
| | | #region 火警出库 |
| | | |
| | | public WebResponseContent EmergencyTask(object obj) |
| | | public WebResponseContent EmergencyTask(Object obj) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | var emergencyTask = new DTSEmergencyTask(); |
| | | try |
| | | { |
| | | emergencyTask = JsonConvert.DeserializeObject<DTSEmergencyTask>(obj.ToString()); |
| | | |
| | | if (emergencyTask == null) throw new Exception("火警参数为空"); |
| | | |
| | | string[] strings = emergencyTask.LocationCode.Split("-"); |
| | | |
| | | string[] Roadways = strings[0].Select(x => x.ToString()).ToArray(); |
| | | string Roadway = string.Empty; |
| | | switch (Roadways[0]) |
| | | { |
| | | case "J": |
| | | Roadway = "JZSC" + Roadways[1]; |
| | | break; |
| | | case "G": |
| | | Roadway = "GWSC" + Roadways[1]; |
| | | break; |
| | | case "C": |
| | | Roadway = "CWSC" + Roadways[1]; |
| | | break; |
| | | default: throw new Exception("未识别库位编码"); |
| | | } |
| | | |
| | | string Roadway = strings[0]; |
| | | //switch (Roadways[0]) |
| | | //{ |
| | | // case "J": |
| | | // Roadway = "JZSC" + Roadways[1]; |
| | | // break; |
| | | // case "G": |
| | | // Roadway = "GWSC" + Roadways[1]; |
| | | // break; |
| | | // case "C": |
| | | // Roadway = "CWSC" + Roadways[1]; |
| | | // break; |
| | | // default: throw new Exception("未识别库位编码"); |
| | | //} |
| | | int Row = Convert.ToInt16(strings[1]); |
| | | int Column= Convert.ToInt16(strings[2]); |
| | | int Layer= Convert.ToInt16(strings[3]); |
| | | if (!strings[0].Contains("SC")) throw new Exception("未知库区"); |
| | | for (int i = 0; i < 2; i++) |
| | | { |
| | | DtLocationInfo locationInfo = _locationRepository.QueryFirst(x => x.Row == Convert.ToInt16(strings[1]) && x.Column == Convert.ToInt16(strings[2]) && x.Layer == (i == 0 ? Convert.ToInt16(strings[3]) * 2 - 1 : Convert.ToInt16(strings[3]) * 2) && x.RoadwayNo == Roadway); |
| | | DtLocationInfo locationInfo = _locationRepository.QueryFirst(x => x.Row == Row && x.Column == Column && x.Layer == (i == 0 ? Layer - 1 : Layer) && x.RoadwayNo == Roadway); |
| | | if (locationInfo == null) |
| | | { |
| | | throw new Exception("未知库位"); |
| | |
| | | |
| | | } |
| | | #endregion |
| | | } |
| | | public WebResponseContent GetTimeout() |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var now = DateTime.Now; |
| | | // 使用Subtract方法 |
| | | var threeHoursAgo = now.Subtract(TimeSpan.FromHours(3)); |
| | | |
| | | List<DtStockInfo> dtStocks = _stockInfoRepository.Db.Queryable<DtStockInfo>() |
| | | .Where(x => x.OutboundTime < threeHoursAgo).ToList(); |
| | | return content.OK1(total1:dtStocks.Count, data: dtStocks); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | |
| | | } |
| | | public WebResponseContent Getproductionstatistics() |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var now = DateTime.Now; |
| | | var thirtyDaysAgo = now.AddDays(-30); |
| | | var roadwayMappings = new Dictionary<string, string> { |
| | | { "JZ", "静置库" }, |
| | | { "CH", "陈化库" }, |
| | | { "FR", "分容库" }, |
| | | { "GW", "高温库" }, |
| | | { "CW", "常温库" } |
| | | }; |
| | | |
| | | var roadwayKeys = roadwayMappings.Keys.ToArray(); |
| | | |
| | | var taskHty = _task_HtyRepository.Db.Queryable<Dt_Task_Hty>() |
| | | .Where(it => |
| | | it.CreateDate >= thirtyDaysAgo && |
| | | it.CreateDate <= now && |
| | | it.TaskType == 100 && |
| | | roadwayKeys.Any(rk => it.Roadway.Contains(rk))) |
| | | .ToList() |
| | | .Select(t => new { |
| | | OriginalRoadway = t.Roadway, |
| | | MatchedKey = roadwayKeys.FirstOrDefault(rk => t.Roadway.Contains(rk)), |
| | | CreateDate = t.CreateDate |
| | | }) |
| | | .Where(t => t.MatchedKey != null) |
| | | .GroupBy(t => new { |
| | | RoadwayKey = t.MatchedKey, |
| | | Date = t.CreateDate.Date, |
| | | Hour = t.CreateDate.Hour |
| | | }) |
| | | .OrderByDescending(group => group.Key.Date) |
| | | .ThenByDescending(group => group.Key.Hour) |
| | | .Select(group => new { |
| | | Hour = $"{group.Key.Date:yyyy/M/d} {group.Key.Hour}:00", |
| | | Count = group.Count(), |
| | | Roadway = roadwayMappings[group.Key.RoadwayKey] // 映射为中文名称 |
| | | }) |
| | | .ToList(); |
| | | return content.OK1(total1: taskHty.Count, data: taskHty); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | } |