using Entity.DbModel.Station; using HybirdFrameworkCore.Entity; using Microsoft.AspNetCore.Mvc; using Repository.Station; using Service.Cloud.Client; using Service.Cloud.Msg.Cloud.Resp; using Service.Execute.Api; using Service.Execute.Model; using SqlSugar; namespace WebStarter.Controllers.Test; [ApiController] [Route("[controller]")] public class GenController : ControllerBase { private readonly ISqlSugarClient _sqlSugarClient; private readonly BatteryGroupRepository _batteryGroupRepository; public GenController(ISqlSugarClient sqlSugarClient, BatteryGroupRepository batteryGroupRepository) { _sqlSugarClient = sqlSugarClient; _batteryGroupRepository = batteryGroupRepository; } /// /// 生成文件 /// /// [HttpGet("gen/t/{id}")] public void Get(int id) { Console.WriteLine(); _sqlSugarClient.DbFirst .IsCreateAttribute() //创建sqlsugar自带特性 .FormatFileName(it => ToPascalCase(it)) //格式化文件名(文件名和表名不一样情况) .FormatClassName(it => ToPascalCase(it)) //格式化类名 (类名和表名不一样的情况) .FormatPropertyName(it => ToPascalCase(it)) //格式化属性名 (属性名和字段名不一样情况) .CreateClassFile("D:\\lxw\\work\\pro\\c#\\hn_back_main\\Entity\\DbModel\\Station\\Temp", "Entity.DbModel.Station"); Console.WriteLine("生成完毕"); } [HttpGet("CloudTestVelCheck")] public Result CloudTestVelCheck() { CarAuthRes carAuthRes = CloudApi.VehicleCheck(new RfidReadModel() { //VelMac = "111", VelNo = "晋C03733D", VelVin = "LZ5NB6D38RB000421", }, new SwapOrder() { VehicleEnterTime = DateTime.Now }); return Result.Success(carAuthRes); } [HttpGet("CloudTestUploadSwapOrder")] public Result CloudTestUploadSwapOrder() { var uploadSwapOrder = CloudApi.UploadSwapOrder(new SwapOrder() { VehicleEnterTime = DateTime.Now, CloudSn = "T20240701102224000002fc", VehicleVin = "LZ5NB6D38RB000421", SwapResult = 1, SwapBeginTime = DateTime.Now, SwapEndTime = DateTime.Now, VehicleLeaveTime = DateTime.Now, }, 1, new SwapOrderBattery() { DownBatteryNo = "123", DownBatterySoc = 30, DownBatteryBinNo = 2, UpBatteryNo = "456", UpBatterySoc = 100, UpBatteryBinNo = 3 }, 1, new SwapOrderReportCloud() { }); return Result.Success(); } [HttpGet("CloudTestUploadChargeOrder")] public Result CloudTestUploadChargeOrder() { List chargeOrders = new List() { new() { BatteryNo = "123", CloudChargeOrder = "HNGX0002C20012406210913551911", StartTime = DateTime.Now, StartSoc = 30, }, new() { EndTime = DateTime.Now, StopSoc = 100, } }; CloudClientMgr.CloudClient?.PublishChargeOrder(chargeOrders, 1); return Result.Success(); } [HttpGet("test115")] public void Test115() { var group = new BatteryGroup() { BatteryNo = "1", Group = 1, }; var batteryGroup = new BatteryGroup() { BatteryNo = "2", Group = 2, }; var groups = new List() { group, batteryGroup }; _batteryGroupRepository.Insert(groups); BatteryGroup batteryGroups = _batteryGroupRepository.QueryByClause(i => i.Group == 1); /* /*BatteryGroup batteryGroup = batteryGroups[0]; _batteryGroupRepository.Delete(batteryGroup); BatteryGroup batteryGroup1 = batteryGroups[1]; batteryGroup1.Group = 3; _batteryGroupRepository.Update(batteryGroup1);#1# if (batteryGroups == null) { Console.WriteLine(); } else { Console.WriteLine(); } */ Console.WriteLine("测试完毕"); } static string ToPascalCase(string input) { if (string.IsNullOrEmpty(input)) return input; string[] strings = input.Split("_"); string res = ""; foreach (var s in strings) { string first = s.First().ToString().ToUpper(); string te = first + s.Substring(1); res += te; } return res; } }