using WIDESEAWCS_Core.BaseServices; using WIDESEAWCS_ITaskInfoRepository; using WIDESEAWCS_ITaskInfoService; using WIDESEAWCS_Model.Models; namespace WIDESEAWCS_TaskInfoService { /// /// 假电芯位置服务实现 /// public class FakeBatteryPositionService : ServiceBase, IFakeBatteryPositionService { public FakeBatteryPositionService(IFakeBatteryPositionRepository BaseDal) : base(BaseDal) { } /// public List GetNextAvailable(int count) { return BaseDal.GetNextAvailable(count); } /// public int ResetAll() { return BaseDal.ResetAll(); } /// public bool MarkAsUsed(List positions) { return BaseDal.MarkAsUsed(positions); } /// public int? GetPositionIndex(int row, int col) { return BaseDal.GetPositionIndex(row, col); } /// public bool InitializeIfEmpty() { var existing = BaseDal.QueryFirst(x => true); if (existing != null) return true; // 生成48个点位:3行×16列,行优先 var positions = new List(); 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; } } }