using WIDESEAWCS_Core.BaseServices;
|
using WIDESEAWCS_ITaskInfoRepository;
|
using WIDESEAWCS_ITaskInfoService;
|
using WIDESEAWCS_Model.Models;
|
|
namespace WIDESEAWCS_TaskInfoService
|
{
|
/// <summary>
|
/// 假电芯位置服务实现
|
/// </summary>
|
public class FakeBatteryPositionService : ServiceBase<Dt_FakeBatteryPosition, IFakeBatteryPositionRepository>, IFakeBatteryPositionService
|
{
|
public FakeBatteryPositionService(IFakeBatteryPositionRepository BaseDal) : base(BaseDal)
|
{
|
}
|
|
/// <inheritdoc/>
|
public List<int> GetNextAvailable(int count)
|
{
|
return BaseDal.GetNextAvailable(count);
|
}
|
|
/// <inheritdoc/>
|
public int ResetAll()
|
{
|
return BaseDal.ResetAll();
|
}
|
|
/// <inheritdoc/>
|
public bool MarkAsUsed(List<int> positions)
|
{
|
return BaseDal.MarkAsUsed(positions);
|
}
|
|
/// <inheritdoc/>
|
public int? GetPositionIndex(int row, int col)
|
{
|
return BaseDal.GetPositionIndex(row, col);
|
}
|
|
/// <inheritdoc/>
|
public bool InitializeIfEmpty()
|
{
|
var existing = BaseDal.QueryFirst(x => true);
|
if (existing != null)
|
return true;
|
|
// 生成48个点位:3行×16列,行优先
|
var positions = new List<Dt_FakeBatteryPosition>();
|
for (int row = 1; row <= 3; row++)
|
{
|
for (int col = 1; col <= 16; col++)
|
{
|
int positionIndex = (row - 1) * 16 + col;
|
positions.Add(new Dt_FakeBatteryPosition
|
{
|
PositionIndex = positionIndex,
|
Row = row,
|
Col = col,
|
IsUsed = false,
|
Creater = "System"
|
});
|
}
|
}
|
|
return BaseDal.AddData(positions) > 0;
|
}
|
}
|
}
|