陈勇
2 天以前 6b74e1dcf5642c8f56975471e27780d695953989
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
using AngleSharp.Dom;
using Mapster;
using Masuit.Tools;
using SqlSugar;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Linq.Expressions;
using WIDESEA_Core;
using WIDESEA_DTO.Basic;
using WIDESEA_IStoragIntegrationServices;
 
namespace WIDESEA_StorageBasicService;
 
public class VV_MesLockInfoService : ServiceBase<VV_MesLockInfo, IVV_MesLockInfoRepository>, IVV_MesLockInfoService
{
    private readonly IVV_StockInfoRepository _stockInfoRepository;
    private readonly IDt_MESLockInfoRepository _MESLockInfoRepository;
    private readonly IDt_CarBodyInfoRepository _carBodyInfoRepository;
    private readonly IMESService _MESService;
    public VV_MesLockInfoService(IVV_MesLockInfoRepository BaseDal, IVV_StockInfoRepository stockInfoRepository, IDt_MESLockInfoRepository MESLockInfoRepository, IDt_CarBodyInfoRepository carBodyInfoRepository, IMESService MESService) : base(BaseDal)
    {
        _stockInfoRepository = stockInfoRepository;
        _MESLockInfoRepository = MESLockInfoRepository;
        _carBodyInfoRepository = carBodyInfoRepository;
        _MESService = MESService;
    }
 
    public WebResponseContent GetMesLockInfo()
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            List<VV_MesLockInfo> mesLockInfos = BaseDal.QueryData(x => x.LockStatue == 1 || x.LockStatue == 0).OrderBy(x => x.sequenceNo).ToList();
            List<VV_StockInfo> stockInfos = _stockInfoRepository.QueryData(x => x.CarType == 2).OrderBy(x => x.CreateDate).Take(50).ToList();
            List<MesLockDTO> mesLockDTOs = new List<MesLockDTO>();
            mesLockInfos.ForEach(x =>
            {
                mesLockDTOs.Add(new MesLockDTO
                {
                    lockStatue = x.LockStatue,
                    pvi = x.PVI,
                    vehicleCharacteristic = x.vehicleCharacteristic,
                    carBodyCharacteristic = x.carBodyCharacteristic
                });
            });
            stockInfos.ForEach(x =>
            {
                mesLockDTOs.Add(new MesLockDTO
                {
                    lockStatue = 2,
                    pvi = x.PVI,
                    vehicleCharacteristic = x.vehicleCharacteristic,
                    carBodyCharacteristic = x.carBodyCharacteristic
                });
            });
            return content.OK(data: mesLockDTOs);
        }
        catch (Exception ex)
        {
            return content.Error(ex.Message);
        }
    }
 
    public WebResponseContent GetStockInfo(string PVI)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            VV_StockInfo stockInfos = _stockInfoRepository.QueryFirst(x => x.PVI == PVI);
 
            return content.OK(data: stockInfos);
        }
        catch (Exception ex)
        {
            return content.Error(ex.Message);
        }
    }
 
    public WebResponseContent MesLock(object[] keys)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            List<Dt_CarBodyInfo> bodyInfos = new List<Dt_CarBodyInfo>();
            List<Dt_MESLockInfo> lockinfo = new List<Dt_MESLockInfo>();
            foreach (var item in keys)
            {
 
            }
 
            if (!bodyInfos.Any()) throw new Exception("锁车上报失败:无锁车数据");
 
            var mesLock = _MESLockInfoRepository.QueryFirst(x => x.Id == Convert.ToInt32(keys));
            mesLock.LockStatue = 3; //异常锁车
            var carInfo = _carBodyInfoRepository.QueryFirst(x => x.Id == mesLock.carBodyID);
            if (carInfo != null)
            {
                bodyInfos.Add(carInfo);
                lockinfo.Add(mesLock);
            }
 
            WebResponseContent webResponse = _MESService.LockRequest(carInfo, 1);
            if (webResponse.Status)
            {
                _MESLockInfoRepository.UpdateData(lockinfo);
                content.OK();
            }
            else
            {
                content.Error();
            }
        }
        catch (Exception ex)
        {
            content.Error(ex.Message);
        }
        return content;
    }
 
    public WebResponseContent MesUnLock(object[] keys)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            List<Dt_CarBodyInfo> bodyInfos = new List<Dt_CarBodyInfo>();
            foreach (var item in keys)
            {
 
            }
 
            if (!bodyInfos.Any()) throw new Exception("锁车上报失败:无锁车数据");
 
            var mesLock = _MESLockInfoRepository.QueryFirst(x => x.Id == Convert.ToInt32(keys));
 
            var carInfo = _carBodyInfoRepository.QueryFirst(x => x.Id == mesLock.carBodyID);
            if (carInfo != null) bodyInfos.Add(carInfo);
 
            WebResponseContent webResponse = _MESService.LockRequest(carInfo, 1);
            if (webResponse.Status)
            {
                content.OK();
            }
            else
            {
                content.Error();
            }
        }
        catch (Exception ex)
        {
            content.Error(ex.Message);
        }
        return content;
    }
 
}