| | |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | WebResponseContent GetInventory(); |
| | | |
| | | /// <summary> |
| | | /// è·å临æçåç«åºåºå使¥è¦ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | WebResponseContent GetExpiredAndlow(); |
| | | } |
| | | } |
| | |
| | | public interface IInventory_BatchServices : IService<Dt_Inventory_Batch> |
| | | { |
| | | IRepository<Dt_Inventory_Batch> Repository { get; } |
| | | |
| | | WebResponseContent GetExpiredAndlow(); |
| | | } |
| | | } |
| | |
| | | /// <param name="messageRemark"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent AddMessageInfo(MessageGroupByEnum groupByEnum, string messageName, string messageInfo, MessageStatusEnum statusEnum = MessageStatusEnum.Undisposed, string messageRemark = ""); |
| | | WebResponseContent DeleteAndIntoHty(int[] keys); |
| | | WebResponseContent DeleteAndIntoHty(object[] keys); |
| | | void GetMessageInfo(); |
| | | } |
| | | } |
| | |
| | | } |
| | | public IRepository<Dt_InventoryInfo> Repository => BaseDal; |
| | | |
| | | public WebResponseContent GetExpiredAndlow() |
| | | { |
| | | try |
| | | { |
| | | // è·åå½åæ¶é´ï¼åªåæ¥æé¨åï¼å¿½ç¥æ¶é´ï¼ |
| | | DateTime currentDate = DateTime.Today; |
| | | // 计ç®30天åçæ¥æ |
| | | DateTime thresholdDate = currentDate.AddDays(30); |
| | | |
| | | // æ¥æ¾åºå䏿æåå |
| | | var inventoryList = BaseDal.QueryData(); |
| | | var expiredSoonList = new List<object>(); |
| | | |
| | | foreach (var item in inventoryList) |
| | | { |
| | | // æ£æ¥ValidityPeriodæ¯å¦ä¸ºç©º |
| | | if (string.IsNullOrEmpty(item.ValidityPeriod)) |
| | | continue; |
| | | |
| | | // 使ç¨ç²¾ç¡®æ ¼å¼è§£æ "2037-10-02" |
| | | if (DateTime.TryParseExact(item.ValidityPeriod.Trim(), "yyyy-MM-dd", |
| | | System.Globalization.CultureInfo.InvariantCulture, |
| | | System.Globalization.DateTimeStyles.None, out DateTime expiryDate)) |
| | | { |
| | | // 计ç®å©ä½å¤©æ°ï¼åªæ¯è¾æ¥æé¨åï¼ |
| | | double daysRemaining = (expiryDate - currentDate).TotalDays; |
| | | |
| | | // æ£æ¥æ¯å¦å¨30天å
ï¼å
æ¬å·²è¿æçï¼ |
| | | if (daysRemaining <= 30) |
| | | { |
| | | expiredSoonList.Add(new |
| | | { |
| | | MaterielCode = item.MaterielCode ?? "", |
| | | BatchNo = item.BatchNo ?? "", |
| | | ValidityPeriod = item.ValidityPeriod, |
| | | ExpiryDate = expiryDate.ToString("yyyy-MM-dd"), |
| | | }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // è®°å½è§£æå¤±è´¥çè®°å½ï¼ç¨äºè°è¯ï¼ |
| | | Console.WriteLine($"æ æ³è§£æææ: {item.ValidityPeriod}"); |
| | | } |
| | | } |
| | | |
| | | // æå©ä½å¤©æ°ååºæåï¼å³å°è¿æçæåé¢ï¼ |
| | | var sortedList = expiredSoonList.OrderBy(x => |
| | | { |
| | | var days = (int)((dynamic)x).DaysRemaining; |
| | | return days; |
| | | }).ToList(); |
| | | |
| | | return new WebResponseContent |
| | | { |
| | | Status = true, |
| | | Message = $"åç° {sortedList.Count} 个ååå°å¨30天å
è¿æ", |
| | | Data = new |
| | | { |
| | | TotalCount = sortedList.Count, |
| | | ExpiredCount = sortedList.Count(x => ((dynamic)x).DaysRemaining < 0), |
| | | WarningCount = sortedList.Count(x => ((dynamic)x).DaysRemaining >= 0), |
| | | CheckDate = currentDate.ToString("yyyy-MM-dd"), |
| | | Items = sortedList |
| | | } |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return new WebResponseContent |
| | | { |
| | | Status = false, |
| | | Message = $"è·åæææ°æ®å¤±è´¥: {ex.Message}" |
| | | }; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·ååºå |
| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_IWMsInfoServices; |
| | |
| | | { |
| | | public class Inventory_BatchServices : ServiceBase<Dt_Inventory_Batch, IRepository<Dt_Inventory_Batch>>, IInventory_BatchServices |
| | | { |
| | | public Inventory_BatchServices(IRepository<Dt_Inventory_Batch> BaseDal) : base(BaseDal) |
| | | private IMessageInfoService _messageInfoService; |
| | | public Inventory_BatchServices(IRepository<Dt_Inventory_Batch> BaseDal, IMessageInfoService messageInfoService) : base(BaseDal) |
| | | { |
| | | _messageInfoService = messageInfoService; |
| | | } |
| | | |
| | | public IRepository<Dt_Inventory_Batch> Repository => BaseDal; |
| | | |
| | | public WebResponseContent GetExpiredAndlow() |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | DateTime dateTime = DateTime.Now.AddDays(30).Date; |
| | | List<Dt_Inventory_Batch> inventory_Batches = BaseDal.QueryData(x => x.ValidityPeriod < dateTime); |
| | | foreach (var item in inventory_Batches) |
| | | { |
| | | var day = (item.ValidityPeriod - DateTime.Now).Days; |
| | | string d = $"è¿æ{day}å¤©è¿æ"; |
| | | if (day < 0) d = $"å·²è¿æ{Math.Abs(day)}天"; |
| | | _messageInfoService.AddMessageInfo(MessageGroupByEnum.InventoryExceedAlarm, "ç©æåç§°:" + item.MaterielName, $"ç©æç¼å·ã{item.MaterielCode}ãç©ææ¹æ¬¡ã{item.BatchNo}ã{d}"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |
| | |
| | | dt_MessageInfo = BaseDal.QueryFirst(x => x.MessageName == messageName && x.MessageRemark == messageRemark); |
| | | else |
| | | dt_MessageInfo = BaseDal.QueryFirst(x => x.MessageName == messageName && x.MessageInfo == messageInfo); |
| | | if (groupByEnum != MessageGroupByEnum.InventoryExceedAlarm && dt_MessageInfo != null) return content; |
| | | |
| | | if (dt_MessageInfo == null) |
| | | { |
| | | dt_MessageInfo = new Dt_MessageInfo(); |
| | |
| | | { |
| | | if (dt_MessageInfo.MessageGroupBy == MessageGroupByEnum.InventoryExceedAlarm.ObjToInt()) |
| | | { |
| | | if (dt_MessageInfo.MessageInfo == messageInfo) return content; |
| | | dt_MessageInfo.MessageStatus = statusEnum.ObjToInt(); |
| | | dt_MessageInfo.MessageName = messageName; |
| | | dt_MessageInfo.MessageInfo = messageInfo; |
| | |
| | | } |
| | | return content; |
| | | } |
| | | public WebResponseContent DeleteAndIntoHty(int[] keys) |
| | | public override WebResponseContent DeleteData(object[] keys) |
| | | { |
| | | return DeleteAndIntoHty(keys); |
| | | //return base.DeleteData(keys); |
| | | } |
| | | public WebResponseContent DeleteAndIntoHty(object[] keys) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | List<Dt_MessageInfo> messageInfos = BaseDal.QueryData(x => keys.Contains(x.Id)); |
| | | List<int> ints = new List<int>(); |
| | | foreach (var item in messageInfos) |
| | | { |
| | | item.MessageStatus = MessageStatusEnum.Processed.ObjToInt(); |
| | | item.Modifier = App.User.UserName; |
| | | ints.Add(item.Id); |
| | | } |
| | | BaseDal.DeleteAndMoveIntoHty(messageInfos, OperateTypeEnum.äººå·¥å®æ); |
| | | string MessageInfo = _cacheService.Get("MessageInfo"); |
| | | if (!string.IsNullOrEmpty(MessageInfo)) |
| | | { |
| | | List<Message>? messages = JsonConvert.DeserializeObject<List<Message>>(MessageInfo); |
| | | if (messages != null) |
| | | { |
| | | messages = messages.Where(x => !ints.Contains(x.Id)).ToList(); |
| | | _cacheService.AddOrUpdate("MessageInfo", JsonConvert.SerializeObject(messages)); |
| | | } |
| | | } |
| | | content.OK("å¤çæå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | List<int> keys = new List<int>(); |
| | | List<Message> messagesinfo = new List<Message>(); |
| | | string MessageInfo = _cacheService.Get("MessageInfo"); |
| | | if (!string.IsNullOrEmpty(MessageInfo)) |
| | |
| | | if (messages != null) |
| | | { |
| | | messagesinfo = messages; |
| | | keys = messages.Select(x => x.Id).ToList(); |
| | | } |
| | | } |
| | | var messinfo = BaseDal.QueryData(x => !keys.Contains(x.Id)); |
| | | var messinfo = BaseDal.QueryData(x => x.MessageStatus < MessageStatusEnum.Wait.ObjToInt()); |
| | | foreach (var item in messinfo) |
| | | { |
| | | Message message = new Message() |
| | |
| | | }; |
| | | if (_webSocketServer.OnlineCount > 0) |
| | | _webSocketServer.PublishAllClientPayload(JsonConvert.SerializeObject(obj)); |
| | | item.MessageStatus = MessageStatusEnum.Wait.ObjToInt(); |
| | | } |
| | | if (messagesinfo.Count > 0) |
| | | _cacheService.AddOrUpdate("MessageInfo", JsonConvert.SerializeObject(messagesinfo)); |
| | | BaseDal.UpdateData(messinfo); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | public enum MessageStatusEnum |
| | | { |
| | | /// <summary> |
| | | /// å¾
å¤ç |
| | | /// æªå¤ç |
| | | /// </summary> |
| | | [Description("å¾
å¤ç")] |
| | | [Description("æªå¤ç")] |
| | | Undisposed, |
| | | /// <summary> |
| | | /// æ¥å¤ç |
| | |
| | | [Description("æ¥å¤ç")] |
| | | Emergency, |
| | | /// <summary> |
| | | /// å¾
å¤ç |
| | | /// </summary> |
| | | [Description("å¾
å¤ç")] |
| | | Wait, |
| | | /// <summary> |
| | | /// å·²å¤ç |
| | | /// </summary> |
| | | [Description("å·²å¤ç")] |
| | |
| | | [ImporterHeader(Name = "æææè³")] |
| | | [ExporterHeader(DisplayName = "æææè³")] |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "æææè³")] |
| | | public string ValidityPeriod { get; set; } |
| | | public DateTime ValidityPeriod { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 夿³¨ |
| | |
| | | Status = false, |
| | | StockQuantity = inventoryInfo.StockQuantity, |
| | | AvailableQuantity = inventoryInfo.StockQuantity, |
| | | ValidityPeriod = inventoryInfo.ValidityPeriod, |
| | | ValidityPeriod = inventoryInfo.ValidityPeriod.ObjToDate(), |
| | | SupplyQuantity = inventoryInfo.SupplyQuantity, |
| | | }; |
| | | _inventory_BatchServices.AddData(inventory_Batch); |
| | |
| | | ERPStockQuantity = 0, |
| | | Status = false, |
| | | ProductionDate = detail.finishDate.ToString("yyyy-MM-dd"), |
| | | ValidityPeriod = inventoryInfo.ValidityPeriod, |
| | | ValidityPeriod = inventoryInfo.ValidityPeriod.ObjToDate(), |
| | | Remark = "èªå¨å建" |
| | | }; |
| | | BaseDal.Db.Insertable(inventory_Batch).ExecuteCommand(); |
| | |
| | | private readonly IContainerService _containerService; |
| | | private readonly IEquipmentAlarmInforService _equipmentAlarmInforService; |
| | | private readonly IMessageInfoService _messageInfoService; |
| | | public AlarmJob(IContainerService containerService, IEquipmentAlarmInforService equipmentAlarmInforService, IMessageInfoService messageInfoService) |
| | | private readonly IInventory_BatchServices _inventoryInfoService; |
| | | public AlarmJob(IContainerService containerService, IEquipmentAlarmInforService equipmentAlarmInforService, IMessageInfoService messageInfoService, IInventory_BatchServices inventoryInfoService) |
| | | { |
| | | _containerService = containerService; |
| | | _equipmentAlarmInforService = equipmentAlarmInforService; |
| | | _messageInfoService = messageInfoService; |
| | | _inventoryInfoService = inventoryInfoService; |
| | | } |
| | | //æ¯é1ç§æ§è¡ä¸æ¬¡ |
| | | [Invoke(Begin = "2025-09-01", Interval = 1000 * 5, IsEnabled = true, SkipWhileExecuting = true)] |
| | |
| | | //å·åº |
| | | _containerService.Sensor(); |
| | | _equipmentAlarmInforService.getDeviceStatus(); |
| | | _inventoryInfoService.GetExpiredAndlow(); |
| | | _messageInfoService.GetMessageInfo(); |
| | | } |
| | | } |
| | |
| | | { |
| | | } |
| | | [HttpPost, HttpGet, Route("DeleteAndIntoHty")] |
| | | public WebResponseContent DeleteAndIntoHty([FromBody] int[] keys) |
| | | public WebResponseContent DeleteAndIntoHty([FromBody] object[] keys) |
| | | { |
| | | return Service.DeleteAndIntoHty(keys); |
| | | } |
| | |
| | | bind: { key: "MessageGroupByEnum", data: [] }, |
| | | require: true, |
| | | }, |
| | | { |
| | | field: "messageStatus", |
| | | title: "ç¶æ", |
| | | type: "string", |
| | | width: 100, |
| | | align: "center", |
| | | bind: { key: "MessageStatusEnum", data: [] }, |
| | | require: true, |
| | | }, |
| | | // { |
| | | // field: "messageStatus", |
| | | // title: "ç¶æ", |
| | | // type: "string", |
| | | // width: 100, |
| | | // align: "center", |
| | | // bind: { key: "MessageStatusEnum", data: [] }, |
| | | // require: true, |
| | | // }, |
| | | { |
| | | field: "messageName", |
| | | title: "å¼å¸¸ä¿¡æ¯åç§°", |
| | | type: "string", |
| | | width: 200, |
| | | align: "left", |
| | | link: true, |
| | | // link: true, |
| | | require: true, |
| | | }, |
| | | { |
| | |
| | | align: "left", |
| | | require: true, |
| | | }, |
| | | { |
| | | field: "messageRemark", |
| | | title: "夿³¨", |
| | | type: "string", |
| | | width: 200, |
| | | align: "left", |
| | | }, |
| | | { |
| | | field: "creater", |
| | | title: "å建人", |
| | | type: "string", |
| | | width: 100, |
| | | align: "center", |
| | | }, |
| | | // { |
| | | // field: "messageRemark", |
| | | // title: "夿³¨", |
| | | // type: "string", |
| | | // width: 200, |
| | | // align: "left", |
| | | // }, |
| | | // { |
| | | // field: "creater", |
| | | // title: "å建人", |
| | | // type: "string", |
| | | // width: 100, |
| | | // align: "center", |
| | | // }, |
| | | { |
| | | field: "createDate", |
| | | title: "å建æ¶é´", |
| | |
| | | width: 160, |
| | | align: "center", |
| | | }, |
| | | { |
| | | field: "modifier", |
| | | title: "ä¿®æ¹äºº", |
| | | type: "string", |
| | | width: 100, |
| | | align: "center", |
| | | }, |
| | | { |
| | | field: "modifyDate", |
| | | title: "ä¿®æ¹æ¶é´", |
| | | type: "datetime", |
| | | width: 160, |
| | | align: "center", |
| | | }, |
| | | // { |
| | | // field: "modifier", |
| | | // title: "ä¿®æ¹äºº", |
| | | // type: "string", |
| | | // width: 100, |
| | | // align: "center", |
| | | // }, |
| | | // { |
| | | // field: "modifyDate", |
| | | // title: "ä¿®æ¹æ¶é´", |
| | | // type: "datetime", |
| | | // width: 160, |
| | | // align: "center", |
| | | // }, |
| | | ]); |
| | | |
| | | const detail = ref({ |
| | |
| | | </el-col> |
| | | </el-row> --> |
| | | </div> |
| | | <div style="margin-top: 20px"> |
| | | <!-- <div style="margin-top: 20px"> |
| | | <el-button type="primary">å·²å¤ç</el-button> |
| | | <!-- <el-button type="danger">驳å</el-button> --> |
| | | </div> |
| | | <el-button type="danger">驳å</el-button> |
| | | </div> --> |
| | | </div> |
| | | </div> |
| | | </template> |