调试测试修改 修改 插入不返回id

master
lxw 6 months ago
parent 59a7492a31
commit 471eade709

@ -13,4 +13,13 @@ public class DateUtils
DateTime endOfToday = startOfToday.AddDays(1).AddTicks(-1);
return dateTime >= startOfToday && dateTime <= endOfToday;
}
/// 获取明天的0.0.0
public static DateTime GetTomorrowFirst()
{
DateTime today = DateTime.Now; // 获取当前时间
DateTime tomorrow = today.Date.AddDays(1); // 获取明天的日期
return new DateTime(tomorrow.Year, tomorrow.Month, tomorrow.Day, 0, 0, 0); // 获取明天的0点
}
}

@ -127,7 +127,7 @@ namespace Entity.Api.Resp
///// <summary>
///// 换电电池
///// </summary>
//public List<SwapOrderBatteryResp> BatteryList{get;set;}
public List<SwapOrderBatteryResp> BatteryList{get;set;}
/// <summary>
/// 换电小步

@ -44,7 +44,7 @@ public class InfoEnum
[Info("换电站处于本地模式,不能远程换电","换电站处于本地模式,不能远程换电")] InfoStationModelRemoteErr,
[Info("车辆驶入","车辆驶入")] CarInInfo,
[Info("换电任务启动","换电任务启动")] StartSwapInfo,
}

@ -796,11 +796,11 @@ public abstract class BaseRepository<T> where T : class, new()
/// </summary>
/// <param name="entity">实体数据</param>
/// <returns></returns>
public async Task<int> InsertAsync(T entity)
public async Task<T> InsertAsync(T entity)
{
return await DbBaseClient
.Insertable(entity)
.ExecuteReturnIdentityAsync();
.ExecuteReturnEntityAsync();
}
public async Task<T> InsertReturnEntityAsync(T entity)
{
@ -814,12 +814,12 @@ public abstract class BaseRepository<T> where T : class, new()
/// <param name="entity">实体数据</param>
/// <param name="insertColumns">插入的列</param>
/// <returns></returns>
public int Insert(T entity, Expression<Func<T, object>> insertColumns = null)
public T Insert(T entity, Expression<Func<T, object>> insertColumns = null)
{
var insert = DbBaseClient.Insertable(entity);
if (insertColumns == null)
return insert.ExecuteReturnIdentity();
return insert.InsertColumns(insertColumns).ExecuteReturnIdentity();
return insert.ExecuteReturnEntity();
return insert.InsertColumns(insertColumns).ExecuteReturnEntity();
}
/// <summary>
@ -828,12 +828,12 @@ public abstract class BaseRepository<T> where T : class, new()
/// <param name="entity">实体数据</param>
/// <param name="insertColumns">插入的列</param>
/// <returns></returns>
public async Task<int> InsertAsync(T entity, Expression<Func<T, object>> insertColumns = null)
public async Task<T> InsertAsync(T entity, Expression<Func<T, object>> insertColumns = null)
{
var insert = DbBaseClient.Insertable(entity);
if (insertColumns == null)
return await insert.ExecuteReturnIdentityAsync();
return await insert.InsertColumns(insertColumns).ExecuteReturnIdentityAsync();
return await insert.ExecuteReturnEntityAsync();
return await insert.InsertColumns(insertColumns).ExecuteReturnEntityAsync();
}
/// <summary>
@ -869,9 +869,10 @@ public abstract class BaseRepository<T> where T : class, new()
/// </summary>
/// <param name="entity">实体类</param>
/// <returns></returns>
public int Insert(List<T> entity)
public bool Insert(List<T> entity)
{
return DbBaseClient.Insertable(entity.ToArray()).ExecuteReturnIdentity();
return DbBaseClient.Insertable(entity.ToArray()).ExecuteCommandIdentityIntoEntity();
;
}
/// <summary>
@ -879,9 +880,9 @@ public abstract class BaseRepository<T> where T : class, new()
/// </summary>
/// <param name="entity">实体类</param>
/// <returns></returns>
public async Task<int> InsertAsync(List<T> entity)
public async Task<bool> InsertAsync(List<T> entity)
{
return await DbBaseClient.Insertable(entity.ToArray()).ExecuteCommandAsync();
return await DbBaseClient.Insertable(entity.ToArray()).ExecuteCommandIdentityIntoEntityAsync();
}
/// <summary>

@ -299,7 +299,7 @@ public class BaseServices<T> where T : class, new()
/// </summary>
/// <param name="entity">实体数据</param>
/// <returns></returns>
public async Task<int> InsertAsync(T entity)
public async Task<T> InsertAsync(T entity)
{
return await BaseDal.InsertAsync(entity);
}
@ -310,7 +310,7 @@ public class BaseServices<T> where T : class, new()
/// <param name="entity">实体数据</param>
/// <param name="insertColumns">插入的列</param>
/// <returns></returns>
public int Insert(T entity, Expression<Func<T, object>> insertColumns = null)
public T Insert(T entity, Expression<Func<T, object>> insertColumns = null)
{
return BaseDal.Insert(entity, insertColumns);
}
@ -321,7 +321,7 @@ public class BaseServices<T> where T : class, new()
/// <param name="entity">实体数据</param>
/// <param name="insertColumns">插入的列</param>
/// <returns></returns>
public async Task<int> InsertAsync(T entity, Expression<Func<T, object>> insertColumns = null)
public async Task<T> InsertAsync(T entity, Expression<Func<T, object>> insertColumns = null)
{
return await BaseDal.InsertAsync(entity, insertColumns);
}
@ -353,7 +353,7 @@ public class BaseServices<T> where T : class, new()
/// </summary>
/// <param name="entity">实体类</param>
/// <returns></returns>
public int Insert(List<T> entity)
public bool Insert(List<T> entity)
{
return BaseDal.Insert(entity);
}
@ -363,7 +363,7 @@ public class BaseServices<T> where T : class, new()
/// </summary>
/// <param name="entity">实体类</param>
/// <returns></returns>
public async Task<int> InsertAsync(List<T> entity)
public async Task<bool> InsertAsync(List<T> entity)
{
return await BaseDal.InsertAsync(entity);
}

@ -180,7 +180,7 @@ public class CarPrepareState : IState
/// <summary>
/// 检查tbox连接状态
/// </summary>
/// </summary
/// <returns></returns>
public InvokeStatus CheckTBoxConnectFlag(SwappingStateMachine machine)
{

@ -41,13 +41,14 @@ public class DoSwappingState : IState
{
return SwappingStateMachine.ReturnWithInvokeErr(startSwapping, ExceptionReason.None);
}
InvokeStatus holdOn = HoldOn(machine);
if (holdOn != InvokeStatus.Done)
{
return SwappingStateMachine.ReturnWithInvokeErr(holdOn, ExceptionReason.None);
}
//查看通道状态
StateResult checkChannelStatus = CheckChannelStatus(machine);
if (checkChannelStatus != null)
@ -89,8 +90,8 @@ public class DoSwappingState : IState
{
return SwappingStateMachine.ReturnWithInvokeErr(packFinish, ExceptionReason.None);
}
//航车回归安全位置
InvokeStatus toInvokeStatus = ToSafePosition(machine);
if (toInvokeStatus != InvokeStatus.Done)
@ -121,7 +122,7 @@ public class DoSwappingState : IState
//查询车辆锁止状态
var startSwapping = PlcApi.StartSwapping(machine.SwapOrderBatteryInfo.InBinInfo.No,
machine.SwapOrderBatteryInfo.UpBinInfo.No);
//查詢當前任務狀態是否被更改
var readPlcTaskStatus = PlcApi.ReadTaskStatus(1);
if (startSwapping && readPlcTaskStatus)
@ -155,7 +156,7 @@ public class DoSwappingState : IState
bool holdOn = PlcApi.HoldOn();
if (holdOn)
{
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.StartSwapInfo);
machine.PlcHoldFlag = true;
}
}
@ -177,13 +178,12 @@ public class DoSwappingState : IState
() => machine.UnOldBatteryFlag, () =>
{
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoUnPack.GetLed());
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoUnPack);
int status = PlcApi.ReadPlcTaskStatus();
//处理程序太快plc还没有初始值的状态
if (status==1002 || status!=1003)
if (status == 1002 || status != 1003)
{
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoUnPack);
}
else
{
@ -195,7 +195,8 @@ public class DoSwappingState : IState
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.UnOldBatteryFlag,
machine);
}
}, () => { });
}, () => { SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoUnPack); }, false, () => { }, 10,
InvokeStatus.None);
}
public InvokeStatus OldBatteryCarryIn(SwappingStateMachine machine)
@ -204,25 +205,25 @@ public class DoSwappingState : IState
() => machine.StorageOldBatteryFlag, () =>
{
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoOldBatteryCarryIn.GetLed());
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoOldBatteryCarryIn);
var readPlcTaskStatus = PlcApi.ReadPlcTaskStatus();
if (PlcApi.ReadPlcTaskStatus() == 1003)
if (readPlcTaskStatus == 1003 || readPlcTaskStatus != 1004)
{
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoOldBatteryCarryIn);
}
else
{
machine.StorageOldBatteryFlag = true;
}
machine.StorageOldBatteryFlag = PlcApi.ReadPlcTaskStatus() == 1004;
machine.StorageOldBatteryFlag = readPlcTaskStatus == 1004;
if (machine.StorageOldBatteryFlag)
{
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StorageOldBatteryFlag,
machine);
}
}, () => { });
}, () => { SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoOldBatteryCarryIn); }, false, () => { }, 10,
InvokeStatus.None);
}
public InvokeStatus NewBatteryCarryOut(SwappingStateMachine machine)
@ -231,22 +232,23 @@ public class DoSwappingState : IState
() => machine.OutNewBatteryFlag, () =>
{
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoNewBatteryCarryOut.GetLed());
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut);
if (PlcApi.ReadPlcTaskStatus() == 1004)
{
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut);
}
else
{
machine.OutNewBatteryFlag = true;
}
if (machine.OutNewBatteryFlag)
{
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.OutNewBatteryFlag,
machine);
}
}, () => { });
}, () => { SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut);}, false, () => { }, 10,
InvokeStatus.None);
}
@ -256,10 +258,9 @@ public class DoSwappingState : IState
() => machine.InstallNewBatteryFlag, () =>
{
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoPack.GetLed());
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoPack);
if (PlcApi.ReadPlcTaskStatus() == 1005)
{
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoPack);
}
else
{
@ -271,7 +272,11 @@ public class DoSwappingState : IState
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.InstallNewBatteryFlag,
machine);
}
}, () => { });
}, () =>
{
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoPack);
},false, () => { },
10,InvokeStatus.None);
}
public InvokeStatus PackFinish(SwappingStateMachine machine)
@ -280,22 +285,23 @@ public class DoSwappingState : IState
() => machine.FinishNewBatteryFlag, () =>
{
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoPackFinish.GetLed());
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoPackFinish);
var readPlcTaskStatus = PlcApi.ReadPlcTaskStatus();
if (readPlcTaskStatus == 1006 || readPlcTaskStatus==1007 )
if (readPlcTaskStatus == 1006 || readPlcTaskStatus == 1007)
{
machine.FinishNewBatteryFlag = true;
machine.BusinessSwappingForCloudState =
InfoEnum.BusinessSwappingForCloudState.SwapFinish;
// CloudApi.SendStateLog(machine.SwapOrder, machine.BusinessSwappingForCloudState);
machine.BusinessSwappingStateUpdateTime = DateTime.Now;
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoPackFinish);
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.FinishNewBatteryFlag,
machine);
}
}, () => { });
}, () => { },false, () => { },
10,InvokeStatus.None);
}
/// <summary>
/// 行车回归安全位置
/// </summary>
@ -307,19 +313,19 @@ public class DoSwappingState : IState
() => machine.ToSafePositionFlag, () =>
{
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoPackFinish.GetLed());
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoToSafePosition);
if (PlcApi.ReadPlcTaskStatus() == 1007)
{
SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoToSafePosition);
machine.ToSafePositionFlag = true;
machine.BusinessSwappingStateUpdateTime = DateTime.Now;
machine.SwapStatus = 1;
}
}, () => { });
}
/// <summary>
/// 查看通道状态
/// :0无效值

@ -153,6 +153,11 @@ public class SwapDoneState : IState
machine);
}
}
});
}, () =>
{
SoundTool.PlayOneSound(machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success
? (int)InfoEnum.SwapInfo.InfoCarLeave
: (int)InfoEnum.SwapInfo.ErrInfoCarLeave);
}, false,() => { },10,InvokeStatus.None);
}
}

@ -235,7 +235,7 @@ public class SwappingStateMachine : IDisposable
ResetData();
//重置云平台下发的指令
CloudApi.ClearCarCanStartInfo();
// CloudApi.ClearCarCanStartInfo();
}
public bool Cancel()
@ -270,28 +270,75 @@ public class SwappingStateMachine : IDisposable
private void ResetStep()
{
RadarInFlag = false;
BeginRfidReadFlag = false;
RfidReadFlag = false;
CloudVelCheckFlag = false;
BoxConnectFlag = false;
BoxLocalCheckFlag = false;
CloudTBoxFlag = false;
SelectPackFlag = false;
VehiclesInPlaceFlag = false;
DistributeSelectPackFlag = false;
CloudCarCanStartFlag = false;
VelUnlockFlag = false;
StartSwappingFlag = false;
PlcHoldFlag = false;
ChannelStatusOkFlag = false;
VehiclesInPlace2Flag = false;
UnOldBatteryFlag = false;
StorageOldBatteryFlag = false;
OutNewBatteryFlag = false;
InstallNewBatteryFlag = false;
FinishNewBatteryFlag = false;
ToSafePositionFlag = false;
VelLockFlag = false;
RadarOutFlag = false;
PlcHoldFlag = false;
}
//关于仓库锁定相关重置

@ -115,10 +115,10 @@ public class MonitorService
{
SwapAndChargingCountResp chargingCountResp = new()
{
ChargeTodayCount = ChargeOrderRepository.GetCount(i => DateUtils.IsDateTimeToday(i.EndTime)),
ChargeTodayCount = ChargeOrderRepository.GetCount(i => DateTime.Today<=i.EndTime && i.EndTime<= DateUtils.GetTomorrowFirst()),
ChargeTotalCount = ChargeOrderRepository.GetCount(i => i.EndTime != null),
SwapTodayCount =
SwapOrderRepository.GetCount(i => i.SwapResult != 0 && DateUtils.IsDateTimeToday(i.SwapEndTime)),
SwapOrderRepository.GetCount(i => i.SwapResult != 0 && DateTime.Today<=i.SwapEndTime && i.SwapEndTime<= DateUtils.GetTomorrowFirst()),
SwapTotalCount = SwapOrderRepository.GetCount(i => i.SwapResult != 0),
};
@ -135,7 +135,7 @@ public class MonitorService
{
//校验:出仓位
BinInfo? removeBin = BinInfoRepository.QueryByClause(i =>
i.No.Equals(removeBinNo) && i.ChargeStatus == 2 && i.Exists == 1 && i.AmtLock == 0);
i.No.Equals(removeBinNo) && (i.ChargeStatus == 2 || i.ChargeStatus==4) && i.Exists == 1 && i.AmtLock == 0);
if (removeBin == null)
{
@ -143,7 +143,7 @@ public class MonitorService
}
BinInfo? putBin = BinInfoRepository.QueryByClause(i =>
i.No.Equals(putBinNo) && i.ChargeStatus == 2 && i.Exists == 0 && i.AmtLock == 0 && i.Status == 1);
i.No.Equals(putBinNo) && (i.ChargeStatus == 2 || i.ChargeStatus==4) && i.Exists == 0 && i.AmtLock == 0 && i.Status == 1);
if (putBin == null)
{
return Result<bool>.Fail("入仓位状态有误");

@ -72,8 +72,8 @@ namespace Service.System.Dict
if (isExist != null)
return result = "字典类型已存在,名称或编码重复";
var insert = await _sysDictTypeRep.InsertAsync(input.Adapt<SysDictType>());
if (insert > 0)
SysDictType sysDictType = await _sysDictTypeRep.InsertAsync(input.Adapt<SysDictType>());
if (sysDictType.Id > 0)
return result = "添加字典类型成功";
else
return result = "添加字典类型失败";

@ -91,8 +91,8 @@ namespace Service.System
var isExist = await _sysConfigRep.QueryByClauseAsync(u => u.Name == input.Name || u.Code == input.Code);
if (isExist != null)
result = "已存在同名或同编码参数配置";
int insertSesult = await _sysConfigRep.InsertAsync(input.Adapt<SysConfig>());
if (insertSesult > 0)
SysConfig insertAsync = await _sysConfigRep.InsertAsync(input.Adapt<SysConfig>());
if (insertAsync.Id > 0)
result = "增加参数配置成功";
return result;

@ -43,20 +43,20 @@ public class SwapOrderController : ControllerBase
//电池不要了
////查询订单电池数据
//List< SwapOrderBattery> batteryList = swapOrderBatteryService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn));
List< SwapOrderBattery> batteryList = swapOrderBatteryService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn));
////映射
//var config = new MapperConfiguration(cfg => cfg.CreateMap<SwapOrderBatteryResp,SwapOrderBattery > ().ReverseMap());
//IMapper mapper = config.CreateMapper();
//List<SwapOrderBatteryResp> swapOrderBattery = mapper.Map<List<SwapOrderBatteryResp>>(batteryList);
//映射
var config = new MapperConfiguration(cfg => cfg.CreateMap<SwapOrderBatteryResp,SwapOrderBattery > ().ReverseMap());
IMapper mapper = config.CreateMapper();
List<SwapOrderBatteryResp> swapOrderBattery = mapper.Map<List<SwapOrderBatteryResp>>(batteryList);
////将电池数据添加到换电订单数据中
//for (int i = 0; i < swapOrderResp.Rows.Count; i++)
//{
// swapOrderResp.Rows[i].BatteryList = new List<SwapOrderBatteryResp>();
// swapOrderResp.Rows[i].BatteryList.AddRange(swapOrderBattery.Where(battery => battery.SwapOrderSn == swapOrderResp.Rows[i].Sn).ToList());
//}
//将电池数据添加到换电订单数据中
for (int i = 0; i < swapOrderResp.Rows.Count; i++)
{
swapOrderResp.Rows[i].BatteryList = new List<SwapOrderBatteryResp>();
swapOrderResp.Rows[i].BatteryList.AddRange(swapOrderBattery.Where(battery => battery.SwapOrderSn == swapOrderResp.Rows[i].Sn).ToList());
}
//查询订单步序数据
var stepList = swapOrderStepService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn));

@ -60,25 +60,25 @@ public class GenController : ControllerBase
[HttpGet("test115")]
public void Test115()
{
/*_batteryGroupRepository.Insert(new List<BatteryGroup>()
var group = new BatteryGroup()
{
new BatteryGroup()
{
BatteryNo = "1",
Group = 1,
},
new BatteryGroup()
{
BatteryNo = "2",
Group = 2,
},
});*/
BatteryGroup batteryGroups = _batteryGroupRepository.QueryByClause(i=>i.Group==1);
BatteryNo = "1",
Group = 1,
};
var batteryGroup = new BatteryGroup()
{
BatteryNo = "2",
Group = 2,
};
var groups = new List<BatteryGroup>() { 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);*/
_batteryGroupRepository.Update(batteryGroup1);#1#
if (batteryGroups == null)
{
@ -88,6 +88,7 @@ public class GenController : ControllerBase
{
Console.WriteLine();
}
*/
Console.WriteLine("测试完毕");
}

Loading…
Cancel
Save