首页 > 其他分享 >时间非空判断

时间非空判断

时间:2023-09-23 09:11:44浏览次数:36  
标签:COUNT 非空 full JOIN 判断 时间 data sf EarTag

#region 存栏统计
/// <summary>
/// 存栏统计
/// </summary>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<IEnumerable<InventoryStatisticsDto>> ShowInventoryStatistics(string? Generic,int Variety,DateTime? KDate, DateTime? JDate)
{
using (IDbConnection dbConnection = Connection)
{
try
{
dbConnection.Open();
var data = $"SELECT {Generic} aaa, COUNT(c.BuildingName) Beginning," +
$"COUNT(sr.ShiftToBuild)RuRoundup, " +
$"COUNT(dt.TransferDate) RuReplanting," +
$"COUNT(lrm.BirthDate) Ruborn," +
$"COUNT(sr.TurnOutBuild) ChuRoundup, " +
$"COUNT(dm.DeathType) Chudeath," +
$"COUNT(em.DepartureState) Chueliminate," +
$"COUNT(ss.SaleDate) Rureturn," +
$"COUNT(pf.DateOfPurchase) Ruprocurement," +
$"COUNT(c.BuildingName) Beginning ," +
$"COUNT(CASE WHEN sf.PresenceState = 3 THEN 1 ELSE NULL END) AS chusale " +
$"FROM " +
$"SheepFileModel sf full JOIN " +
$"MaternalMating mm ON sf.EarTag = mm.EarTag full JOIN " +
$"BreedMaleAndFemaleStart bms ON bms.EarTag = sf.EarTag full JOIN " +
$"MaternalWeaning mw ON sf.EarTag = mw.EarTag full JOIN " +
$"LambAblactation la ON sf.EarTag = la.EarTag full JOIN " +
$"BodyMeasureModel bm ON sf.EarTag = bm.EarTag full JOIN " +
$"AppearanceModel am ON sf.EarTag = am.EarTag full JOIN " +
$"DeathModel dm ON sf.EarTag = dm.EarTag full JOIN " +
$"SheepRescission sr ON sf.EarTag = sr.EarTag full JOIN " +
$"BreedingHistoryModel bh ON sf.EarTag = bh.EarTag full JOIN " +
$"PregnancytestModel pt ON sf.EarTag = pt.EarTag full JOIN " +
$"ParturitionModel p ON sf.EarTag = p.EarTag full JOIN " +
$"SheepSaleModels ss ON sf.EarTag = ss.EarTag full JOIN " +
$"EliminationModel em ON sf.EarTag = em.EarTag full JOIN " +
$"DescendantTransfer dt ON sf.EarTag = dt.EarTag full JOIN " +
$"MarkModel er ON sf.EarTag = er.EarTag full JOIN " +
$"LambRegistrationModel lrm on lrm.EarTag = sf.EarTag full JOIN " +
$"EarTagOrMarkModel eom ON er.MarkId = eom.MarkId full JOIN " +
$"PurchaseFormModels pf on sf.EarTag = pf.BatchEarHorns full JOIN " +
$"EarTagModel etm ON eom.EarTagId = etm.EarTagId full JOIN " +
$"SheepRescission b ON sf.EarTag = b.EarTag full JOIN " +
$"ColumnManagementModel c ON b.ShiftToBuildingManagementId = c.BuildingManagementId full JOIN " +
$"FieldModel d ON b.ShiftToColumnManagementId = d.ColumnManagementId full JOIN " +
$"ProductionGrading pr ON sf.EarTag = pr.RankEarTag WHERE 1=1 ";
if (Variety != 0)
{
data += $" AND sf.Variety = {Variety} ";
}
if (KDate.HasValue)
{
data += $" AND sf.AdmissionDate >= '{KDate?.ToString("yyyy-MM-dd HH:mm:ss")} ' ";
}
if (JDate.HasValue)
{
data += $" AND sf.AdmissionDate <= '{JDate?.ToString("yyyy-MM-dd HH:mm:ss")} ' ";
}

data += $" Group by {Generic} ";
int ps = 1;
return await dbConnection.QueryAsync<InventoryStatisticsDto>(data);
}
catch (Exception)
{
throw;
}
finally
{
dbConnection.Close();
}
}
}
#endregion

标签:COUNT,非空,full,JOIN,判断,时间,data,sf,EarTag
From: https://www.cnblogs.com/qibaidao/p/17723858.html

相关文章

  • 中小型 MySQL,如何判断是否需要读写分离?
    在中小型MySQL数据库中是否需要实施读写分离取决于多个因素,包括数据库的负载、性能需求、可用性要求和预算等。以下是一些判断是否需要读写分离的考虑因素:负载均衡:如果您的数据库服务器经常处于高负载状态,主要是因为读和写操作同时进行,那么考虑使用读写分离来分担负载是有意义的。......
  • Delphi XE 时间和时间戳互转换
    usesSystem.DateUtils;functionTForm1.Gettamptime(vlen:Integer):string;varss:string;beginifvlen=13thenbeginss:=DateTimeToTimeStamp(now).time.ToString;Result:=IntToStr(DateTimeToUnix(Now,false))+Copy(ss,Length(ss)-......
  • Easy CVR视频存储平台怎么样才能快捷判断视频流编码格式?
    EasyCVR是一个功能强大的设备接入平台,它支持多种设备接入协议,并能够分发多种视频格式的视频流。同时,它还提供视频监控直播、云端录像、云存储、录像检索与回看、智能告警、平台级联、智能分析等多种视频服务,能够满足用户在视频监控领域的需求。无论是个人用户还是企业用户,都可以......
  • JS实现电子签名,并且将带logo和时间水印的电子签名保存到本地
    页面效果如下 本地保存的电子签名图片如下 具体实现代码如下<!DOCTYPEhtml><html><head><metacharset="utf-8"><title>电子签名</title><style>#canvas{border:1pxsolid#000;margin-bo......
  • Redis怎么设置过期时间
    pexpire(Stringkey,longmilliseconds):设置n毫秒后过期。expireAt(Stringkey,longunixTime):设置某个时间戳后过期(精确到秒)。pexpireAt(Stringkey,longmillisecondsTimestamp):设置某个时间戳后过期(精确到毫秒)。persist(Stringkey):移除过期时间。setkvexseconds......
  • nods中mysql时间相差8小时
    前言最近在做自己的一个记账项目,后端nestjs中使用typeorm的mysql。当添加记录时,发现所以时间都相差了8小时。后面查了一下资料发现因为默认timezone是用UTC的。所以只需要设置成我们自己的时区即可。解决方法ormconfig.json{"type":"mysql","host":"localhost","po......
  • GPS北斗卫星同步时钟(NTP时间同步)助力化工厂各系统协同方案
    GPS北斗卫星同步时钟(NTP时间同步)助力化工厂各系统协同方案GPS北斗卫星同步时钟(NTP时间同步)助力化工厂各系统协同方案京准电子科技官微——ahjzsz本项目需配备多台HR-901GB网络时间服务器,各作业部部署一台或多台一级NTP网络时间服务器(炼铁事业部包括高炉、烧结和球团,需配置3台网......
  • JAVA 后端 记录方法运行时间
     LocalDateTimeldStart=LocalDateTime.now();//记录开始时间//中间是需要计算时间的代码段落LocalDateTimeldEnd=LocalDateTime.now();//记录结束时间Durationdu=Duration.between(ldStart,ldEnd);LongcostSeconds=du.toMillis()/1000;System.out.println("postNurseCo......
  • 如何将 Transformer 应用于时间序列模型
    在机器学习的广阔前景中,transformers就像建筑奇迹一样高高耸立,以其复杂的设计和捕获复杂关系的能力重塑了我们处理和理解大量数据的方式。自2017年创建第一个Transformer以来,Transformer类型呈爆炸式增长,其中包括ChatGPT和DALL-E等强大的生成式AI模型。虽然transform......
  • java8 新特性之日期时间处理 LocatDate、LocalTime、LocalDateTime、ZonedDateTime、D
    一、LocalDate、LocalTime、LocalDateTime和常用API1、LocalDatepublicvoidtest01(){//1.创建指定的日期LocalDatedate1=LocalDate.of(2021,05,06);System.out.println("date1="+date1);//2.得到当前的日期LocalDate......