wanshenmean
5 小时以前 ad64840cc04dac2278ca02f22ddc02b1a218e9cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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;
        }
    }
}