From d3ce26a501e5c6e1389d02b3c1386e3161328bf2 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Mon, 25 Dec 2023 23:46:54 +0800 Subject: [PATCH] Add user tese case --- .../UserTestCases/UnitTest/Main.cs | 1 + .../UnitTest/UnitSelectNASFDADSFA.cs | 76 ++++++++++++ .../UnitTest/Unitasf1/ProcessUnit.cs | 89 ++++++++++++++ .../UnitTest/Unitasf1/ProductProcessUnit.cs | 115 ++++++++++++++++++ 4 files changed, 281 insertions(+) create mode 100644 Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/UnitSelectNASFDADSFA.cs create mode 100644 Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitasf1/ProcessUnit.cs create mode 100644 Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitasf1/ProductProcessUnit.cs diff --git a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs index d9ddb0cd7..974370875 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs @@ -33,6 +33,7 @@ namespace OrmTest } public static void Init() { + UnitSelectNASFDADSFA.Init(); UnitOneToOneFilter.Init(); UnitOneToManyNsdfafa.Init(); UnitTreaaafasa.Init(); diff --git a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/UnitSelectNASFDADSFA.cs b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/UnitSelectNASFDADSFA.cs new file mode 100644 index 000000000..92a9ac568 --- /dev/null +++ b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/UnitSelectNASFDADSFA.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using tech.fuhong.mes.basis.entity; +using static OrmTest.UJsonsdafa; + +namespace OrmTest +{ + internal class UnitSelectNASFDADSFA + { + public static void Init() + { + var db = NewUnitTest.Db; + + db.CodeFirst.InitTables(); + db.DbMaintenance.TruncateTable(); + db.Insertable( + new ProcessUnit() + { + ProcessUnitCode = "a", + //ProcessUnitName = "c", + //SyncRecordId = "a", + //ActiveFlag = true, + //SyncTime = DateTime.Now, + //SyncTimeBottom = DateTime.Now, + //SyncTimeTop = DateTime.Now + }) + .ExecuteCommand(); + db.Insertable( + new ProcessUnit() + { + ProcessUnitCode = "c", + //ProcessUnitName = "c", + //SyncRecordId = "a", + //ActiveFlag = true, + //SyncTime = DateTime.Now, + //SyncTimeBottom = DateTime.Now, + //SyncTimeTop = DateTime.Now + }) + .ExecuteCommand(); + db.Insertable( + new ProductProcessUnit() + { + Id=1, + //InspectionStandardUrl="", + // NextProcessUnitId=1, + // ProcessId=1, + // ProcessUnitId=1, + // ProductId=1, + // SortNumber=1, + // SyncRecordId="", + // WorkingInstructionUrl="", + // SyncTime=DateTime.Now, + // SyncTimeBottom=DateTime.Now, + // SyncTimeTop=DateTime.Now + }) + .ExecuteCommand(); + var list=db.Queryable() + .LeftJoin((t1, t2) => t1.Id == t2.Id) + .LeftJoin((t1, t2, t3) => t2.Id+1 == t3.Id) + .Select((t1,t2,t3) => new ProductProcessUnit() + { + InspectionStandardUrl =t3.ProcessUnitCode + t2.ProcessUnitCode, + ProcessUnit= new ProcessUnit() { ProcessUnitCode=t2.ProcessUnitCode}, + NextProcessUnit= new ProcessUnit() { ProcessUnitCode = t3.ProcessUnitCode }, + }).ToList(); + if (list.First().InspectionStandardUrl != "ca" && list.First().ProcessUnit.ProcessUnitCode != "a" + && list.First().ProcessUnit.ProcessUnitCode != "c") + { + throw new Exception("unit error"); + } + } + } +} diff --git a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitasf1/ProcessUnit.cs b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitasf1/ProcessUnit.cs new file mode 100644 index 000000000..ea4b7a5b1 --- /dev/null +++ b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitasf1/ProcessUnit.cs @@ -0,0 +1,89 @@ +using System; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using SqlSugar; + +namespace tech.fuhong.mes.basis.entity +{ + + /// + /// 工序信息 - 数据实体 + /// + /// @author 复弘智能 + /// @version 1.0 2023-12-09 + /// + [SugarTable("basis_process_unit")] + [Description("工序信息")] + public class ProcessUnit : BizEntity + { + /// + /// 记录编号(关键字) + /// + [SugarColumn(ColumnName = "process_unit_id", ColumnDescription = "记录编号", Length = 10, IsPrimaryKey = true, IsIdentity = true)] + public long? Id { get; set; } + + /// + /// 工序编码 + /// + [SugarColumn(ColumnName = "process_unit_code", ColumnDescription = "工序编码", Length = 50, IsNullable = false)] + public String? ProcessUnitCode { get; set; } + + /// + ///// 工序名称 + ///// + //[SugarColumn(ColumnName = "process_unit_name", ColumnDescription = "工序名称", Length = 50, IsNullable = false)] + //public String? ProcessUnitName { get; set; } + + ///// + ///// 有效标识 + ///// + //[SugarColumn(ColumnName = "active_flag", ColumnDescription = "有效标识", IsNullable = false)] + //public bool? ActiveFlag { get; set; } + + ///// + ///// 同步源记录ID + ///// + //[SugarColumn(ColumnName = "sync_record_id", ColumnDescription = "同步源记录ID", Length = 50, IsNullable = true)] + //public String? SyncRecordId { get; set; } + ///// + ///// 最近同步时间 + ///// + //[SugarColumn(ColumnName = "sync_time", ColumnDescription = "最近同步时间", IsNullable = true)] + //public DateTime? SyncTime { get; set; } + ///// + ///// 最近同步时间 (查询上限) + ///// + //[SugarColumn(IsIgnore = true)] + //public DateTime? SyncTimeTop { get; set; } + ///// + ///// 最近同步时间 (查询下限) + ///// + //[SugarColumn(IsIgnore = true)] + //public DateTime? SyncTimeBottom { get; set; } + + ///// + ///// 哈希值 + ///// + //public override int GetHashCode() + //{ + // return (Id == null) ? 0 : Id.GetHashCode(); + //} + + ///// + ///// 两个对象是否相等 + ///// + //public override bool Equals(Object obj) + //{ + // if (Id == null || obj == null || !(obj is ProcessUnit)) + // { + // return false; + // } + + // return Id.Equals(((ProcessUnit)obj).Id); + //} + } + + public class BizEntity + { + } +} \ No newline at end of file diff --git a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitasf1/ProductProcessUnit.cs b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitasf1/ProductProcessUnit.cs new file mode 100644 index 000000000..f313ba4c8 --- /dev/null +++ b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitasf1/ProductProcessUnit.cs @@ -0,0 +1,115 @@ +using System; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using SqlSugar; + +namespace tech.fuhong.mes.basis.entity +{ + + /// + /// 产品工艺下的工序明细 - 数据实体 + /// + /// @author 复弘智能 + /// @version 1.0 2023-12-22 + /// + [SugarTable("basis_product_process_unit")] + [Description("产品工艺下的工序明细")] + public class ProductProcessUnit : BizEntity + { + /// + /// 记录编号(关键字) + /// + [SugarColumn(ColumnName = "id", ColumnDescription = "记录编号", Length = 10, IsPrimaryKey = true, IsIdentity = true)] + public long? Id { get; set; } + + ///// + ///// 产品工艺记录编号,关联basis_product_process.process_id + ///// + //[SugarColumn(ColumnName = "process_id", ColumnDescription = "产品工艺记录编号,关联basis_product_process.process_id", Length = 10, IsNullable = false)] + //public long? ProcessId { get; set; } + ///// + ///// 工序记录编号,关联basis_process_unit.process_unit_id + ///// + //[SugarColumn(ColumnName = "process_unit_id", ColumnDescription = "工序记录编号,关联basis_process_unit.process_unit_id", Length = 10, IsNullable = false)] + //public long? ProcessUnitId { get; set; } + /// + /// 工序信息 + /// + [SugarColumn(IsIgnore = true)] + public ProcessUnit? ProcessUnit { get; set; } + ///// + ///// 作业指导书文档地址 + ///// + //[SugarColumn(ColumnName = "working_instruction_url", ColumnDescription = "作业指导书文档地址", Length = 200, IsNullable = true)] + //public String? WorkingInstructionUrl { get; set; } + + /// + /// 检验标准文档地址 + /// + [SugarColumn(ColumnName = "inspection_standard_url", ColumnDescription = "检验标准文档地址", Length = 200, IsNullable = true)] + public String? InspectionStandardUrl { get; set; } + + ///// + ///// 排序号(正序) + ///// + //[SugarColumn(ColumnName = "sort_number", ColumnDescription = "排序号(正序)", Length = 4, IsNullable = false)] + //public int? SortNumber { get; set; } + + ///// + ///// 同步源记录ID + ///// + //[SugarColumn(ColumnName = "sync_record_id", ColumnDescription = "同步源记录ID", Length = 50, IsNullable = true)] + //public String? SyncRecordId { get; set; } + ///// + ///// 最近同步时间 + ///// + //[SugarColumn(ColumnName = "sync_time", ColumnDescription = "最近同步时间", IsNullable = true)] + //public DateTime? SyncTime { get; set; } + ///// + ///// 最近同步时间 (查询上限) + ///// + //[SugarColumn(IsIgnore = true)] + //public DateTime? SyncTimeTop { get; set; } + ///// + ///// 最近同步时间 (查询下限) + ///// + //[SugarColumn(IsIgnore = true)] + //public DateTime? SyncTimeBottom { get; set; } + ///// + ///// 产品记录编号,关联basis_material.material_id + ///// + //[SugarColumn(ColumnName = "product_id", ColumnDescription = "产品记录编号,关联basis_material.material_id", Length = 10, IsNullable = false)] + //public long? ProductId { get; set; } + ///// + ///// 下道工序记录编号,关联basis_process_unit.process_unit_id + ///// + //[SugarColumn(ColumnName = "next_process_unit_id", ColumnDescription = "下道工序记录编号,关联basis_process_unit.process_unit_id", Length = 10, IsNullable = true)] + //public long? NextProcessUnitId { get; set; } + /// + /// 下一道工序信息 + /// + [SugarColumn(IsIgnore = true)] + public ProcessUnit? NextProcessUnit { get; set; } + + /// + /// 哈希值 + /// + public override int GetHashCode() + { + return (Id == null) ? 0 : Id.GetHashCode(); + } + + /// + /// 两个对象是否相等 + /// + public override bool Equals(Object obj) + { + if (Id == null || obj == null || !(obj is ProductProcessUnit)) + { + return false; + } + + return Id.Equals(((ProductProcessUnit)obj).Id); + } + } +} \ No newline at end of file