From 5224b2e818b4e7c962d57a50a77227430ee68771 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 26 Sep 2023 18:05:49 +0800 Subject: [PATCH] Update unit test --- Src/Asp.NetCore2/TDengineTest/Demo/ORMTest.cs | 51 ++++++++++++- .../Models/Unit/T_TD_AOIRecord.cs | 73 +++++++++++++++++++ 2 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 Src/Asp.NetCore2/TDengineTest/Models/Unit/T_TD_AOIRecord.cs diff --git a/Src/Asp.NetCore2/TDengineTest/Demo/ORMTest.cs b/Src/Asp.NetCore2/TDengineTest/Demo/ORMTest.cs index c6b6bc8ea..f04078033 100644 --- a/Src/Asp.NetCore2/TDengineTest/Demo/ORMTest.cs +++ b/Src/Asp.NetCore2/TDengineTest/Demo/ORMTest.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; -using SqlSugar; +using SqlSugar; using TDengineDriver; namespace OrmTest @@ -377,9 +377,36 @@ CACHEMODEL 'both'");//不支持 UPDATE 1 选项 voltage = 11 }).ExecuteCommand(); var list=db.Queryable().ToList(); + + db.Ado.ExecuteCommand(@" CREATE TABLE aoi_recordsuper (fcreatetime timestamp, fsncode VARCHAR(50), fmachineno VARCHAR(50),lotno VARCHAR(50),billno VARCHAR(50),fresult VARCHAR(50) + ,fproduct VARCHAR(50),machinetime VARCHAR(50),id VARCHAR(50),uploadtype VARCHAR(50),dimbin VARCHAR(50)) + TAGS (workstation VARCHAR(50));"); + + var dt2=Convert.ToDateTime("2023-09-23 08:00:00.12345"); + db.Ado.ExecuteCommand(@" + + +INSERT INTO aoirecord_2309 USING aoi_recordsuper TAGS (""AOI"") +VALUES ('2023-09-23', ""10.2"", ""A219"",""2309050001"",""B03123"",""OK"",""681-ABC"",""2023-9-5"",""123"",""首测"",""A"") +(now, ""10.2"", ""A219"",""2309050001"",""B03123"",""OK"",""681-ABC"",""2023-9-5"",""123"",""首测"",""A"")"); + + var date = Convert.ToDateTime("2023-9-25 00:00:00"); + var list3=db.Queryable().ToList(); + var list2 = db.Queryable() + .Where(t => t.fcreatetime >= date).ToList(); + + if (list2.Count != 1) + { + throw new Exception("unit error"); + } + } private static void US() { + //clear static config + SqlSugar.TDengine.TDengineProvider._IsIsNanosecond = false; + SqlSugar.TDengine.TDengineProvider._IsMicrosecond = false; + //说明: //字符串中指定TsType=config_ns //实体加上 SqlParameterDbType =typeof(DateTime19) @@ -418,6 +445,28 @@ CACHEMODEL 'both'");//不支持 UPDATE 1 选项 voltage = 11 }).ExecuteCommand(); var list = db.Queryable().ToList(); + + db.Ado.ExecuteCommand(@" CREATE TABLE aoi_recordsuper (fcreatetime timestamp, fsncode VARCHAR(50), fmachineno VARCHAR(50),lotno VARCHAR(50),billno VARCHAR(50),fresult VARCHAR(50) + ,fproduct VARCHAR(50),machinetime VARCHAR(50),id VARCHAR(50),uploadtype VARCHAR(50),dimbin VARCHAR(50)) + TAGS (workstation VARCHAR(50));"); + + var dt2 = Convert.ToDateTime("2023-09-23 08:00:00.12345"); + db.Ado.ExecuteCommand(@" + + +INSERT INTO aoirecord_2309 USING aoi_recordsuper TAGS (""AOI"") +VALUES ('2023-09-23', ""10.2"", ""A219"",""2309050001"",""B03123"",""OK"",""681-ABC"",""2023-9-5"",""123"",""首测"",""A"") +(now, ""10.2"", ""A219"",""2309050001"",""B03123"",""OK"",""681-ABC"",""2023-9-5"",""123"",""首测"",""A"")"); + + var date = Convert.ToDateTime("2023-9-25 00:00:00"); + var list3 = db.Queryable().ToList(); + var list2 = db.Queryable() + .Where(t => t.fcreatetime >= date).ToList(); + + if (list2.Count != 1) + { + throw new Exception("unit error"); + } } private static List GetInsertDatas() diff --git a/Src/Asp.NetCore2/TDengineTest/Models/Unit/T_TD_AOIRecord.cs b/Src/Asp.NetCore2/TDengineTest/Models/Unit/T_TD_AOIRecord.cs new file mode 100644 index 000000000..22519fbd5 --- /dev/null +++ b/Src/Asp.NetCore2/TDengineTest/Models/Unit/T_TD_AOIRecord.cs @@ -0,0 +1,73 @@ +using SqlSugar; +using SqlSugar.DbConvert; +using System; +using System.Collections.Generic; +using System.Text; + +namespace OrmTest +{ + + [SugarTable("aoi_recordsuper")] + public class T_TD_AOIRecord + { + [SugarColumn(IsPrimaryKey = true, SqlParameterDbType = typeof(DateTime19))] + public DateTime fcreatetime { get; set; } + /// + /// 产品唯一码 + /// + [SugarColumn(SqlParameterDbType = typeof(CommonPropertyConvert))] + public string fsncode { get; set; } + /// + /// 机台号 + /// + [SugarColumn(SqlParameterDbType = typeof(CommonPropertyConvert))] + public string fmachineno { get; set; } + /// + /// 批次号 + /// + [SugarColumn(SqlParameterDbType = typeof(CommonPropertyConvert))] + public string lotno { get; set; } + /// + /// 单据号 + /// + [SugarColumn(SqlParameterDbType = typeof(CommonPropertyConvert))] + public string billno { get; set; } + /// + /// 结果 + /// + [SugarColumn(SqlParameterDbType = typeof(CommonPropertyConvert))] + public string fresult { get; set; } + /// + /// bin编号 + /// + [SugarColumn(SqlParameterDbType = typeof(CommonPropertyConvert))] + public string dimbin { get; set; } + /// + /// 工站 + /// + [SugarColumn(SqlParameterDbType = typeof(CommonPropertyConvert))] + public string workstation { get; set; } + /// + /// 料号 + /// + [SugarColumn(SqlParameterDbType = typeof(CommonPropertyConvert))] + public string fproduct { get; set; } + /// + /// 机台时间 + /// + [SugarColumn(SqlParameterDbType = typeof(CommonPropertyConvert))] + public string machinetime { get; set; } + /// + /// 唯一ID + /// + [SugarColumn(SqlParameterDbType = typeof(CommonPropertyConvert))] + public string id { get; set; } + /// + /// 测试状态 + /// + [SugarColumn(SqlParameterDbType = typeof(CommonPropertyConvert))] + public string uploadtype { get; set; } + } + + +}