diff --git a/Service/Charger/Handler/RecordChargeHandler.cs b/Service/Charger/Handler/RecordChargeHandler.cs index c13daf2..dfb4a90 100644 --- a/Service/Charger/Handler/RecordChargeHandler.cs +++ b/Service/Charger/Handler/RecordChargeHandler.cs @@ -67,15 +67,15 @@ namespace Service.Charger.Handler client.ChargeOrderNo = msg.ChargerOrderNo; - int count = _chargeOrderRepository.GetCount(it => it.Sn == client.ChargeOrderNo); - if (count < 1) + ChargeOrder db = _chargeOrderRepository.QueryByClause(it => it.Sn == msg.ChargerOrderNo); + if (db == null) { ChargeOrder chargeOrder = new ChargeOrder() { Sn = client.ChargeOrderNo, BatteryNo = client.BatteryNo, - StartTime = new DateTime((msg.StartYear+1900) , msg.StartMonth ,msg.StartDay ,msg.StartHour, msg.StartMinute, msg.StartSecond), - EndTime = new DateTime(msg.EndYear + 1900, msg.EndMonth, msg.EndDay, msg.EndHour, msg.EndMinute, msg.EndSecond), + StartTime = new DateTime((msg.StartYear+2000) , msg.StartMonth ,msg.StartDay ,msg.StartHour, msg.StartMinute, msg.StartSecond), + EndTime = new DateTime(msg.EndYear + 2000, msg.EndMonth, msg.EndDay, msg.EndHour, msg.EndMinute, msg.EndSecond), StartSoc = msg.SocBefore, StopSoc = msg.SocAfter, ChargeTimeCount= msg.ChargingTimeCount, @@ -99,6 +99,31 @@ namespace Service.Charger.Handler _chargeOrderRepository.Insert(chargeOrder); } + else + { + db.StartTime = new DateTime((msg.StartYear+2000) , msg.StartMonth ,msg.StartDay ,msg.StartHour, msg.StartMinute, msg.StartSecond); + db.EndTime = new DateTime(msg.EndYear + 2000, msg.EndMonth, msg.EndDay, msg.EndHour, msg.EndMinute, msg.EndSecond); + db.StartSoc = msg.SocBefore; + db.StopSoc = msg.SocAfter; + db.ChargeTimeCount= msg.ChargingTimeCount; + db.ElecCount = Convert.ToDecimal(msg.ChargingPower); + db.AcElecCount = Convert.ToDecimal(msg.AcMeterElecCount); + db.StartAcElec = Convert.ToDecimal(msg.AcMeterDataBefore); + db.StopAcElec = Convert.ToDecimal(msg.AcMeterDataAfter); + db.StartDcElec = Convert.ToDecimal(msg.DcMeterDataBefore); + db.StopDcElec = Convert.ToDecimal(msg.DcMeterDataAfter); + db.SharpElecCount = Convert.ToDecimal(powersPeriods[0]); + db.PeakElecCount = Convert.ToDecimal(powersPeriods[0]); + db.FlatElecCount = Convert.ToDecimal(powersPeriods[0]); + db.ValleyElecCount = Convert.ToDecimal(powersPeriods[0]); + db.AcSharpElecCount = Convert.ToDecimal(acPowersPeriods[0]); + db.AcPeakElecCount = Convert.ToDecimal(acPowersPeriods[0]); + db.AcFlatElecCount = Convert.ToDecimal(acPowersPeriods[0]); + db.AcValleyElecCount = Convert.ToDecimal(acPowersPeriods[0]); + db.ChargeMode = msg.ChargeMode; + db.StartMode = msg.StartMode; + _chargeOrderRepository.Update(db); + } ctx.Channel.WriteAndFlushAsync(new RecordChargeRespData()); } diff --git a/WebStarter/Program.cs b/WebStarter/Program.cs index f31c6b3..52047e9 100644 --- a/WebStarter/Program.cs +++ b/WebStarter/Program.cs @@ -15,7 +15,7 @@ builder.Host.ConfigureContainer(cb => { cb.Register(c => { - var db = new SqlSugarClient(new ConnectionConfig + var db = new SqlSugarScope(new ConnectionConfig { ConfigId = AppSettingsConstVars.ConfigId, ConnectionString = AppSettingsConstVars.DbSqlConnection, // �������ݿ������ַ���