获取本月安全生产数据

This commit is contained in:
qianhao.xu
2025-04-14 17:04:28 +08:00
parent c0d249f4b2
commit a10aa585ba
3 changed files with 84 additions and 3 deletions

View File

@@ -0,0 +1,15 @@
using DOAN.Model.MES.Andon.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DOAN.Service.MES.SmartScreen.Site.IService
{
public interface ISiteSafeGreenCrossSmartService
{
public List<SiteSafeGreenCrossDto> GetGeenCrossSmartScreenForMonth();
}
}

View File

@@ -0,0 +1,55 @@
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<SiteSafeGreenCross>, ISiteSafeGreenCrossSmartService
{
public List<SiteSafeGreenCrossDto> GetGeenCrossSmartScreenForMonth()
{
UseTran2(() =>
{
DateTime nowDate = DateTime.Now.Date;
bool TodayExist = Context.Queryable<SiteSafeGreenCross>().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<SiteSafeGreenCross>().Where(it => it.SafeDate >= firstDayOfMonth && it.SafeDate <= lastDayOfMonth)
.ToList().Adapt<List<SiteSafeGreenCrossDto>>();
return list;
}
}
}