Add user tese case

This commit is contained in:
sunkaixuan 2023-12-25 23:46:54 +08:00
parent 2ee1eda859
commit d3ce26a501
4 changed files with 281 additions and 0 deletions

View File

@ -33,6 +33,7 @@ namespace OrmTest
}
public static void Init()
{
UnitSelectNASFDADSFA.Init();
UnitOneToOneFilter.Init();
UnitOneToManyNsdfafa.Init();
UnitTreaaafasa.Init();

View File

@ -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<ProductProcessUnit, ProcessUnit>();
db.DbMaintenance.TruncateTable<ProductProcessUnit, ProcessUnit>();
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<ProductProcessUnit>()
.LeftJoin<ProcessUnit>((t1, t2) => t1.Id == t2.Id)
.LeftJoin<ProcessUnit>((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");
}
}
}
}

View File

@ -0,0 +1,89 @@
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using SqlSugar;
namespace tech.fuhong.mes.basis.entity
{
/// <summary>
/// 工序信息 - 数据实体
///
/// @author 复弘智能
/// @version 1.0 2023-12-09
/// </summary>
[SugarTable("basis_process_unit")]
[Description("工序信息")]
public class ProcessUnit : BizEntity
{
/// <summary>
/// 记录编号(关键字)
/// </summary>
[SugarColumn(ColumnName = "process_unit_id", ColumnDescription = "记录编号", Length = 10, IsPrimaryKey = true, IsIdentity = true)]
public long? Id { get; set; }
/// <summary>
/// 工序编码
/// </summary>
[SugarColumn(ColumnName = "process_unit_code", ColumnDescription = "工序编码", Length = 50, IsNullable = false)]
public String? ProcessUnitCode { get; set; }
/// <summary>
///// 工序名称
///// </summary>
//[SugarColumn(ColumnName = "process_unit_name", ColumnDescription = "工序名称", Length = 50, IsNullable = false)]
//public String? ProcessUnitName { get; set; }
///// <summary>
///// 有效标识
///// </summary>
//[SugarColumn(ColumnName = "active_flag", ColumnDescription = "有效标识", IsNullable = false)]
//public bool? ActiveFlag { get; set; }
///// <summary>
///// 同步源记录ID
///// </summary>
//[SugarColumn(ColumnName = "sync_record_id", ColumnDescription = "同步源记录ID", Length = 50, IsNullable = true)]
//public String? SyncRecordId { get; set; }
///// <summary>
///// 最近同步时间
///// </summary>
//[SugarColumn(ColumnName = "sync_time", ColumnDescription = "最近同步时间", IsNullable = true)]
//public DateTime? SyncTime { get; set; }
///// <summary>
///// 最近同步时间 (查询上限)
///// </summary>
//[SugarColumn(IsIgnore = true)]
//public DateTime? SyncTimeTop { get; set; }
///// <summary>
///// 最近同步时间 (查询下限)
///// </summary>
//[SugarColumn(IsIgnore = true)]
//public DateTime? SyncTimeBottom { get; set; }
///// <summary>
///// 哈希值
///// </summary>
//public override int GetHashCode()
//{
// return (Id == null) ? 0 : Id.GetHashCode();
//}
///// <summary>
///// 两个对象是否相等
///// </summary>
//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
{
}
}

View File

@ -0,0 +1,115 @@
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using SqlSugar;
namespace tech.fuhong.mes.basis.entity
{
/// <summary>
/// 产品工艺下的工序明细 - 数据实体
///
/// @author 复弘智能
/// @version 1.0 2023-12-22
/// </summary>
[SugarTable("basis_product_process_unit")]
[Description("产品工艺下的工序明细")]
public class ProductProcessUnit : BizEntity
{
/// <summary>
/// 记录编号(关键字)
/// </summary>
[SugarColumn(ColumnName = "id", ColumnDescription = "记录编号", Length = 10, IsPrimaryKey = true, IsIdentity = true)]
public long? Id { get; set; }
///// <summary>
///// 产品工艺记录编号关联basis_product_process.process_id
///// </summary>
//[SugarColumn(ColumnName = "process_id", ColumnDescription = "产品工艺记录编号关联basis_product_process.process_id", Length = 10, IsNullable = false)]
//public long? ProcessId { get; set; }
///// <summary>
///// 工序记录编号关联basis_process_unit.process_unit_id
///// </summary>
//[SugarColumn(ColumnName = "process_unit_id", ColumnDescription = "工序记录编号关联basis_process_unit.process_unit_id", Length = 10, IsNullable = false)]
//public long? ProcessUnitId { get; set; }
/// <summary>
/// 工序信息
/// </summary>
[SugarColumn(IsIgnore = true)]
public ProcessUnit? ProcessUnit { get; set; }
///// <summary>
///// 作业指导书文档地址
///// </summary>
//[SugarColumn(ColumnName = "working_instruction_url", ColumnDescription = "作业指导书文档地址", Length = 200, IsNullable = true)]
//public String? WorkingInstructionUrl { get; set; }
/// <summary>
/// 检验标准文档地址
/// </summary>
[SugarColumn(ColumnName = "inspection_standard_url", ColumnDescription = "检验标准文档地址", Length = 200, IsNullable = true)]
public String? InspectionStandardUrl { get; set; }
///// <summary>
///// 排序号(正序)
///// </summary>
//[SugarColumn(ColumnName = "sort_number", ColumnDescription = "排序号(正序)", Length = 4, IsNullable = false)]
//public int? SortNumber { get; set; }
///// <summary>
///// 同步源记录ID
///// </summary>
//[SugarColumn(ColumnName = "sync_record_id", ColumnDescription = "同步源记录ID", Length = 50, IsNullable = true)]
//public String? SyncRecordId { get; set; }
///// <summary>
///// 最近同步时间
///// </summary>
//[SugarColumn(ColumnName = "sync_time", ColumnDescription = "最近同步时间", IsNullable = true)]
//public DateTime? SyncTime { get; set; }
///// <summary>
///// 最近同步时间 (查询上限)
///// </summary>
//[SugarColumn(IsIgnore = true)]
//public DateTime? SyncTimeTop { get; set; }
///// <summary>
///// 最近同步时间 (查询下限)
///// </summary>
//[SugarColumn(IsIgnore = true)]
//public DateTime? SyncTimeBottom { get; set; }
///// <summary>
///// 产品记录编号关联basis_material.material_id
///// </summary>
//[SugarColumn(ColumnName = "product_id", ColumnDescription = "产品记录编号关联basis_material.material_id", Length = 10, IsNullable = false)]
//public long? ProductId { get; set; }
///// <summary>
///// 下道工序记录编号关联basis_process_unit.process_unit_id
///// </summary>
//[SugarColumn(ColumnName = "next_process_unit_id", ColumnDescription = "下道工序记录编号关联basis_process_unit.process_unit_id", Length = 10, IsNullable = true)]
//public long? NextProcessUnitId { get; set; }
/// <summary>
/// 下一道工序信息
/// </summary>
[SugarColumn(IsIgnore = true)]
public ProcessUnit? NextProcessUnit { get; set; }
/// <summary>
/// 哈希值
/// </summary>
public override int GetHashCode()
{
return (Id == null) ? 0 : Id.GetHashCode();
}
/// <summary>
/// 两个对象是否相等
/// </summary>
public override bool Equals(Object obj)
{
if (Id == null || obj == null || !(obj is ProductProcessUnit))
{
return false;
}
return Id.Equals(((ProductProcessUnit)obj).Id);
}
}
}