using DOAN.Model.MES.Andon; using DOAN.Model.MES.Andon.Dto; using DOAN.Model.MES.quality.FQC; using DOAN.Service.MES.SmartScreen.Quality.IService; using DOAN.Service.MES.SmartScreen.Site.IService; using Infrastructure.Attribute; using Mapster; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DOAN.Service.MES.SmartScreen.Site { [AppService(ServiceType = typeof(ISiteSafeGreenCrossSmartService), ServiceLifetime = LifeTime.Transient)] public class SiteSafeGreenCrossSmartService : BaseService, ISiteSafeGreenCrossSmartService { public List GetGeenCrossSmartScreenForMonth() { UseTran2(() => { DateTime nowDate = DateTime.Now.Date; bool TodayExist = Context.Queryable().Where(it => it.SafeDate == nowDate).Any(); if (!TodayExist) { Context.Insertable(new SiteSafeGreenCross() { SafeDate = nowDate, SafeNum = 1, CreatedBy = "auto", CreatedTime = DateTime.Now, UpdatedBy = "auto", UpdatedTime = DateTime.Now }).ExecuteCommand(); } }); // 获取本月第一天 DateTime firstDayOfMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); // 获取本月最后一天 DateTime lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1); var list = Context.Queryable().Where(it => it.SafeDate >= firstDayOfMonth && it.SafeDate <= lastDayOfMonth) .ToList().Adapt>(); return list; } } }