Admin
17 小时以前 1cd9280bbecf557f8978ad3839f14827ff9f4d34
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/*
 *所有关于Dt_PLCinfoDetail类的业务代码应在此处编写
*可使用repository.调用常用方法,获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Dt_PLCinfoDetailService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using WIDESEA_Core.BaseProvider;
using WIDESEA_Core.Extensions.AutofacManager;
using WIDESEA_Entity.DomainModels;
using System.Linq;
using WIDESEA_Core.Utilities;
using System.Linq.Expressions;
using WIDESEA_Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using WIDESEA_Services.IRepositories;
using System;
using WIDESEA_Services.Repositories;
using System.Collections.Generic;
 
namespace WIDESEA_Services.Services
{
    public partial class Dt_PLCinfoDetailService
    {
        private readonly IHttpContextAccessor _httpContextAccessor;
        private readonly IDt_PLCinfoDetailRepository _repository;//访问数据库
 
        [ActivatorUtilitiesConstructor]
        public Dt_PLCinfoDetailService(
            IDt_PLCinfoDetailRepository dbRepository,
            IHttpContextAccessor httpContextAccessor
            )
        : base(dbRepository)
        {
            _httpContextAccessor = httpContextAccessor;
            _repository = dbRepository;
            //多租户会用到这init代码,其他情况可以不用
            //base.Init(dbRepository);
        }
 
        public static WebResponseContent GetPLCinfoDetailData(SaveModel saveModel)
        {
            Dt_PLCinfoDetail plcinfoDetail = new Dt_PLCinfoDetail();
            List<Dt_PLCinfoDetail> ListplcinfoDetail = new List<Dt_PLCinfoDetail>();
            string plcdetail_number = saveModel.MainData["plcdetail_number"].ToString();
            string plcdetail_value = saveModel.MainData["plcdetail_value"].ToString();
            for (int i = Convert.ToInt32(saveModel.MainData["plcdetail_value"]); i <= Convert.ToInt32(saveModel.MainData["plcdetail_value"]) + 46; i++)
            {
                string plcdetail_valtype = null;
                string plcdetail_name = null;
                string plcdetail_opratortype = null;
                string plcdetail_remark = null;
                int a = i % 50;
                switch (a)
                {
                    case 0:
                        plcdetail_valtype = "Struct";
                        plcdetail_opratortype = "Disable";
                        plcdetail_remark = "交互";
                        break;
                    case 2:
                        plcdetail_valtype = "String";
                        plcdetail_name = "W_Line_TrayBarcode";
                        plcdetail_opratortype = "Write";
                        plcdetail_remark = "托盘条码";
                        break;
                    case 30:
                        plcdetail_valtype = "DInt";
                        plcdetail_name = "W_Line_TargetPosition";
                        plcdetail_opratortype = "Write";
                        plcdetail_remark = "目标位置";
                        break;
                    case 34:
                        plcdetail_valtype = "DInt";
                        plcdetail_name = "W_Line_TaskNum";
                        plcdetail_opratortype = "Write";
                        plcdetail_remark = "任务号";
                        break;
                    case 38:
                        plcdetail_valtype = "Int";
                        plcdetail_opratortype = "Disable";
                        plcdetail_remark = "备用";
                        break;
                    case 40:
                        plcdetail_valtype = "Int";
                        plcdetail_opratortype = "Disable";
                        plcdetail_remark = "备用";
                        break;
                    case 42:
                        plcdetail_valtype = "Int";
                        plcdetail_opratortype = "Disable";
                        plcdetail_remark = "备用";
                        break;
                    case 44:
                        plcdetail_valtype = "Int";
                        plcdetail_opratortype = "Disable";
                        plcdetail_remark = "备用";
                        break;
                    case 46:
                        plcdetail_valtype = "Int";
                        plcdetail_opratortype = "Disable";
                        plcdetail_remark = "备用";
                        break;
                }
                if (plcdetail_valtype != null)
                {
                    plcinfoDetail = new Dt_PLCinfoDetail()
                    {
                        plcdetail_id = Guid.NewGuid(),
                        plcdetail_headid = new Guid("B6147197-E558-430B-92A1-286A1E4DBB01"),
                        plcdetail_db = "DB12",
                        plcdetail_valtype = plcdetail_valtype,
                        plcdetail_value = (Convert.ToInt32(saveModel.MainData["plcdetail_value"]) + a).ToString(),
                        plcdetail_number = plcdetail_number,
                        plcdetail_name = plcdetail_name,
                        plcdetail_opratortype = plcdetail_opratortype,
                        plcdetail_equipment = "ConveyorLine",
                        plcdetail_remark = plcdetail_remark,
                    };
                    ListplcinfoDetail.Add(plcinfoDetail);
                }
                if (Convert.ToInt32(saveModel.MainData["plcdetail_value"]) == i)
                {
                    for (int j = 0; j <= 17; j++)
                    {
                        plcdetail_valtype = null;
                        plcdetail_name = null;
                        plcdetail_opratortype = null;
                        plcdetail_remark = null;
                        if (j >= 10)
                            plcdetail_value = Convert.ToInt32(saveModel.MainData["plcdetail_value"]) + 1 + "." + j % 10;
                        else
                            plcdetail_value = Convert.ToInt32(saveModel.MainData["plcdetail_value"]) + "." + j;
 
                        switch (j)
                        {
                            case 0:
                                plcdetail_valtype = "Bool";
                                plcdetail_name = "R_Line_InteractionRequest";
                                plcdetail_opratortype = "Read";
                                plcdetail_remark = "扫码请求交互";
                                break;
                            case 1:
                                plcdetail_valtype = "Bool";
                                plcdetail_opratortype = "Disable";
                                break;
                            case 2:
                                plcdetail_valtype = "Bool";
                                plcdetail_name = "R_Line_InboundInteractionRequest";
                                plcdetail_opratortype = "Read";
                                plcdetail_remark = "入库请求交互";
                                break;
                            case 3:
                                plcdetail_valtype = "Bool";
                                plcdetail_name = "W_Line_InboundInteractionComplete";
                                plcdetail_opratortype = "Write";
                                plcdetail_remark = "入库交互完成";
                                break;
                            case 4:
                                plcdetail_valtype = "Bool";
                                plcdetail_name = "R_Line_OutboundInteractionRequest";
                                plcdetail_opratortype = "Read";
                                plcdetail_remark = "入库请求交互";
                                break;
                            case 5:
                                plcdetail_valtype = "Bool";
                                plcdetail_opratortype = "Disable";
                                break;
                            case 6:
                                plcdetail_valtype = "Bool";
                                plcdetail_name = "R_Line_ReallocationRequest";
                                plcdetail_opratortype = "Read";
                                plcdetail_remark = "请求重新分配路线";
                                break;
                            case 7:
                                plcdetail_valtype = "Bool";
                                plcdetail_name = "W_Line_ReallocationComplete";
                                plcdetail_opratortype = "Write";
                                plcdetail_remark = "完成重新分配路线";
                                break;
                            case 10:
                                plcdetail_valtype = "Bool";
                                plcdetail_opratortype = "Disable";
                                break;
                            case 11:
                                plcdetail_valtype = "Bool";
                                plcdetail_opratortype = "Disable";
                                break;
                            case 12:
                                plcdetail_valtype = "Bool";
                                plcdetail_opratortype = "Disable";
                                break;
                            case 13:
                                plcdetail_valtype = "Bool";
                                plcdetail_opratortype = "Disable";
                                break;
                            case 14:
                                plcdetail_valtype = "Bool";
                                plcdetail_opratortype = "Disable";
                                break;
                            case 15:
                                plcdetail_valtype = "Bool";
                                plcdetail_opratortype = "Disable";
                                break;
                            case 16:
                                plcdetail_valtype = "Bool";
                                plcdetail_opratortype = "Disable";
                                break;
                            case 17:
                                plcdetail_valtype = "Bool";
                                plcdetail_opratortype = "Disable";
                                break;
                        }
                        if (plcdetail_valtype != null)
                        {
                            plcinfoDetail = new Dt_PLCinfoDetail()
                            {
                                plcdetail_id = Guid.NewGuid(),
                                plcdetail_headid = new Guid("B6147197-E558-430B-92A1-286A1E4DBB01"),
                                plcdetail_db = "DB12",
                                plcdetail_valtype = plcdetail_valtype,
                                plcdetail_value = plcdetail_value,
                                plcdetail_number = plcdetail_number,
                                plcdetail_name = plcdetail_name,
                                plcdetail_opratortype = plcdetail_opratortype,
                                plcdetail_equipment = "ConveyorLine",
                                plcdetail_remark = plcdetail_remark,
                            };
                            ListplcinfoDetail.Add(plcinfoDetail);
                        }
                    }
                }
            }
            Dt_PLCinfoDetailRepository.Instance.AddRange(ListplcinfoDetail, true);
 
            return new WebResponseContent().OK();
        }
 
       
    }
}