diff --git a/Src/Asp.NetCore2/OceanBaseForOracleTest/Config.cs b/Src/Asp.NetCore2/OceanBaseForOracleTest/Config.cs index e5c404d23..279841da1 100644 --- a/Src/Asp.NetCore2/OceanBaseForOracleTest/Config.cs +++ b/Src/Asp.NetCore2/OceanBaseForOracleTest/Config.cs @@ -16,7 +16,7 @@ namespace OrmTest /// Account have permission to create database /// 用有建库权限的数据库账号 /// - public static string ConnectionString = "Driver={OceanBase ODBC 2.0 Driver};Server=172.19.9.9;Port=2883;Database=XIR_TRD;User=XIR_TRD@Xpia2C6G#obtest:1650773680;Password=aaAA11%%;Option=3;"; + public static string ConnectionString = "Driver={OceanBase ODBC 2.0 Driver};Server=172.19.9.9;Port=2883;Database=XRFQ_APP;User=XRFQ_APP@xir#observer:1681125558;Password=xpar;Option=3;"; /// /// Account have permission to create database /// 用有建库权限的数据库账号 diff --git a/Src/Asp.NetCore2/OceanBaseForOracleTest/Program.cs b/Src/Asp.NetCore2/OceanBaseForOracleTest/Program.cs index a9aa7e811..964f8eb02 100644 --- a/Src/Asp.NetCore2/OceanBaseForOracleTest/Program.cs +++ b/Src/Asp.NetCore2/OceanBaseForOracleTest/Program.cs @@ -1,6 +1,8 @@ using OrmTest; using SqlSugar; using SqlSugar.OceanBaseForOracle; +using System.Xml.Linq; +using xTPLM.RFQ.Model.XRFQ_APP; using static Npgsql.Replication.PgOutput.Messages.RelationMessage; namespace OceanBaseForOracle @@ -31,33 +33,44 @@ namespace OceanBaseForOracle Console.WriteLine(db.Ado.Connection.ConnectionString); }; Console.WriteLine("Master:"); - db.Insertable(new Order() { Id=109,Name = "abc", CustomId = 1, CreateTime = DateTime.Now }).ExecuteCommand(); - db.Deleteable().Where(m => m.Id == 109).ExecuteCommand(); - db.Updateable().SetColumns(m => new Order + //db.Queryable().Where(m => m.REMARK==""&& m.PRICE_TYPE == 1 && m.PRICE >= 100 && m.PRICE_UPPER >= 100).ToList() ; + //db.Insertable(new Dto { }).ExecuteCommand(); + db.Insertable(new TRFQ_INSTRUCTIONS { - Name = "我是修改" - }).Where(m => m.Id == 2).ExecuteCommand(); - Console.WriteLine("Slave:"); - //var s = db.Queryable().First(); - //var list = db.Queryable().Select(m => new Order - //{ - // Id = m.Id, - // CreateTime = m.CreateTime, - // CustomId = m.CustomId, - // Idname = SqlFunc.Subqueryable().Where(s => s.Id == 2).Select(s => s.Name), - // Name = m.Name, - // Price = m.Price, - //}).ToList(); - //var grouplist = db.Queryable().OrderByDescending(m=>m.Id).GroupBy(m=>new {m.Id,m.Name}).SelectMergeTable(m => new Order - //{ - // Id = m.Id, - // Name = m.Name, - // CreateTime= SqlFunc.AggregateMin(m.CreateTime), - // Price= SqlFunc.AggregateSum(m.Price), - //}).OrderBy(m=>m.Id).Where(m=>m.Id==1).ToList(); - //var orderlist = db.Queryable().OrderBy(m => new { m.Id, m.Name }).ToList(); - var pageList = db.Queryable().OrderBy(m=>m.Id).ToOffsetPage(1, 3); + I_NAME = "测试新增", + END_TIME = DateTime.Now.Date, + REMARK = "我是备注", + CREATE_BY = 1, + UPDATE_TIME = DateTime.Now, + UPDATE_BY = 1, + STATUS = 0, + I_CODE = "090005", + A_TYPE = "SPT_BD", + M_TYPE = "X_CNBD", + ORDER_MONEY = 500, + I_TYPE = 1, + PRICE_TYPE = 3, + YTM = 0, + YTM_OE = 0, + PRICE = 100, + NETPRICE = 0, + TRADE_TYPE = "10", + PARTY_ID = 1000, + SECU_ACCID = "bss", + ORDER_DATE = DateTime.Now, + SET_DAYS = 0, + SOURCE_TYPE = "xRFQ" + }).ExecuteCommand(); Console.WriteLine("#### MasterSlave End ####"); } } + + public class Dto + { + public string PatID1 { get; set; } + + public string PatID3 { get; set; } + + public string PatID { get; set; } + } } \ No newline at end of file diff --git a/Src/Asp.NetCore2/OceanBaseForOracleTest/TRFQ_INSTRUCTIONS.cs b/Src/Asp.NetCore2/OceanBaseForOracleTest/TRFQ_INSTRUCTIONS.cs new file mode 100644 index 000000000..70f1eb40f --- /dev/null +++ b/Src/Asp.NetCore2/OceanBaseForOracleTest/TRFQ_INSTRUCTIONS.cs @@ -0,0 +1,361 @@ +using SqlSugar; + +namespace xTPLM.RFQ.Model.XRFQ_APP +{ + /// + ///指令表 + /// + [SugarTable("TRFQ_INSTRUCTIONS")] + public partial class TRFQ_INSTRUCTIONS + { + private decimal? _ytm_upper; + private decimal? _ytm_oe_upper; + private decimal? _netprice_upper; + private decimal? _price_upper; + + public TRFQ_INSTRUCTIONS() + { + + + } + /// + /// Desc:指令编号 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsNullable = false, IsPrimaryKey = true, OracleSequenceName = "TRFQ_INSTRUCTIONS$SEQ", IsIdentity = true)] + public int I_ID { get; set; } + + /// + /// Desc:指令名称 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true, Length = 128)] + public string I_NAME { get; set; } + + /// + /// Desc:截止时间 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true)] + public DateTime? END_TIME { get; set; } + + /// + /// Desc:备注 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true, Length = 1024)] + public string REMARK { get; set; } + + /// + /// Desc:创建人ID + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true)] + public int? CREATE_BY { get; set; } + + /// + /// Desc:最后一次修改时间 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true)] + public DateTime? UPDATE_TIME { get; set; } + + /// + /// Desc:最后一次修改人 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true)] + public int? UPDATE_BY { get; set; } + /// + /// Desc:状态 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true)] + public int? STATUS { get; set; } + + /// + /// Desc:债券代码 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true, Length = 100)] + public string I_CODE { get; set; } + + /// + /// Desc:资产类型 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true, Length = 100)] + public string A_TYPE { get; set; } + + /// + /// Desc:交易市场 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true, Length = 100)] + public string M_TYPE { get; set; } + + /// + /// Desc:面额(万元) + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true)] + public decimal? ORDER_MONEY { get; set; } + + /// + /// Desc:价格类型 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true)] + public int? PRICE_TYPE { get; set; } + + /// + /// Desc:交易方向 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true)] + public string TRADE_TYPE { get; set; } + + /// + /// Desc:交易对手 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true)] + public int? PARTY_ID { get; set; } + + /// + /// Desc:是否城投 0:否,1:是 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true)] + public int? IS_CITY_INVESTMENT { get; set; } + + /// + /// Desc:是否永续债,0:否;1:是 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true)] + public int? PERPETUAL { get; set; } + + /// + /// Desc:是否利率债 0:未划分,1:信用债,2:利率债 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true)] + public int? IS_RATES { get; set; } + + /// + /// Desc:最小交易日期 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true)] + public DateTime? ORDER_DATE_MIN { get; set; } + + /// + /// Desc:最大交易日期 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true)] + public DateTime? ORDER_DATE_MAX { get; set; } + + /// + /// Desc:交易市场。(非债券交易市场,该字段而是作为筛选,限制指令债券的交易市场) + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true, Length = 100)] + public string MARKET { get; set; } + + /// + /// Desc:外部ID(提交给外部系统审批,返回主键) + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true)] + public int? SYSID_EXT { get; set; } + + /// + /// Desc:内证账户 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true, Length = 64)] + public string SECU_ACCID { get; set; } + + /// + /// 提交审批IR用户 + /// + [SugarColumn(IsNullable = true, Length = 40)] + public string SUBMIT_IRUSER { get; set; } + + /// + /// 久期 + /// + [SugarColumn(IsNullable = true)] + public decimal? MODIFIED_D { get; set; } + + /// + /// 产品类型 + /// + [SugarColumn(IsNullable = true, Length = 100)] + public string P_CLASS { get; set; } + + /// + /// 剩余期限 + /// + [SugarColumn(IsNullable = true)] + public decimal? LAST_TERM { get; set; } + + /// + /// 期限类型 + /// + [SugarColumn(IsNullable = true, Length = 100)] + public string LAST_TERM_TYPE { get; set; } + + /// + /// 提示 + /// + [SugarColumn(IsNullable = true, Length = 4000)] + public string SUBMIT_MESSAGE { get; set; } + + /// + /// 到期收益率 + /// + [SugarColumn(IsNullable = true)] + public decimal? YTM { get; set; } + + /// + /// 指令类型 1:精确指令 2:模糊指令 + /// + [SugarColumn(IsNullable = false)] + public int I_TYPE { get; set; } = 1; + + /// + /// 交易日期 + /// + [SugarColumn(IsNullable = true)] + public DateTime? ORDER_DATE { get; set; } + + /// + /// Desc:清算速度 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsNullable = true)] + public int SET_DAYS { get; set; } + + /// + /// Desc:指令流水号 请勿使用 + /// Default: + /// Nullable:True + /// + [Obsolete] + [SugarColumn(IsNullable = true)] + public string I_NO { get; set; } + + /// + /// 行权收益率 + /// + [SugarColumn(IsNullable = true)] + public decimal? YTM_OE { get; set; } + + /// + /// 净价 + /// + [SugarColumn(IsNullable = true)] + public decimal? NETPRICE { get; set; } + + /// + /// 全价 + /// + [SugarColumn(IsNullable = true)] + public decimal? PRICE { get; set; } + + /// + /// 到期收益率上限 (模糊指令有效) + /// + [SugarColumn(IsNullable = true)] + public decimal? YTM_UPPER { get; set; } + + /// + /// 行政收益率上限 (模式指令有效) + /// + [SugarColumn(IsNullable = true)] + public decimal? YTM_OE_UPPER { get; set; } + + /// + /// 净价上限(模糊指令有效) + /// + [SugarColumn(IsNullable = true)] + public decimal? NETPRICE_UPPER { get; set; } + + /// + /// 全价上限 (模糊指令有效) + /// + [SugarColumn(IsNullable = true)] + public decimal? PRICE_UPPER { get; set; } + + + /// + /// 提交审批时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime? SUBMIT_TIME { get; set; } + + /// + /// 上交所固收平台约定号 + /// + [SugarColumn(IsNullable = true, Length = 20)] + public string SHG_AGREENUM { get; set; } + + /// + /// 上交所固收平台对手方交易员代码 + /// + [SugarColumn(IsNullable = true, Length = 50)] + public string SHG_TRADER_CP { get; set; } + + /// + /// 上交所固收平台对手方席位号 + /// + [SugarColumn(IsNullable = true, Length = 50)] + public string SHG_SEATNO_CP { get; set; } + + /// + /// 数据来源 + /// + [SugarColumn(IsNullable = true, Length = 256)] + public string SOURCE_TYPE { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime? CREATE_TIME { get; set; } + + /// + /// 外部交易标识 + /// + [SugarColumn(IsNullable = true, Length = 128)] + public string EXT_TRADE_ID { get; set; } + } + +} diff --git a/Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/OceanBaseForOracleProvider.cs b/Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/OceanBaseForOracleProvider.cs index fca311151..5bce15019 100644 --- a/Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/OceanBaseForOracleProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/OceanBaseForOracleProvider.cs @@ -224,12 +224,19 @@ namespace SqlSugar.OceanBaseForOracle } if (orderParameters.Select(it => it.ParameterName).GroupBy(it => it).Where(it => it.Count() > 1).Any()) { - orderParameters= parameters.Where(it=>sql.Contains(it.ParameterName)) - .OrderBy(it => sql.IndexOf(it.ParameterName)).ToList(); + + foreach (var param in parameters.OrderByDescending(it => it.ParameterName.Length)) + { + sql = sql.Replace(param.ParameterName, helper.FormatValue(param.Value) + ""); + } + orderParameters = new List(); } - foreach (var param in parameters.OrderByDescending(it => it.ParameterName.Length)) + else { - sql = sql.Replace(param.ParameterName, "?"); + foreach (var param in parameters.OrderByDescending(it => it.ParameterName.Length)) + { + sql = sql.Replace(param.ParameterName, "?"); + } } } OdbcCommand sqlCommand = new OdbcCommand(sql, (OdbcConnection)this.Connection);