WorkOrderController.cs
8.81 KB
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
using Hh.Mes.Common.Request;
using Hh.Mes.POJO.Entity;
using Hh.Mes.POJO.WebEntity.bus;
using Hh.Mes.Service.Configure;
using Hh.Mes.Service.Wo;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using System;
using System.Collections.Generic;
using System.Linq;
using WebMvc.Aop;
using Hh.Mes.Service.SystemAuth;
using WebMvc.Common;
using Autofac.Core;
namespace WebMvc.Areas.wo.Controllers
{
/// <summary>
/// 工序工单
/// </summary>
[Area("wo")]
public class WorkOrderController : BaseController
{
private readonly WorkOrderService workOrderService;
private readonly LineService lineService;
public WorkOrderController(IAuth authUtil, WorkOrderService service, LineService lineService) : base(authUtil)
{
workOrderService = service;
this.lineService = lineService;
workOrderService.sysWebUser = authUtil.GetCurrentUser().User;
}
#region 视图功能
public IActionResult Index( string sysWhereLineSelect)
{
var lineList = lineService.GetLineList();
var listItem = lineList.FirstOrDefault(x => x.Value == sysWhereLineSelect);
if (listItem != null) listItem.Selected = true;
return View(lineList);
}
/// <summary>
/// 报检页面
/// </summary>
/// <returns></returns>
public IActionResult Inspection()
{
return View();
}
/// <summary>
/// 工序任务明细物料页面
/// </summary>
/// <param name="headKey">工序任务明细HeadKey</param>
/// <param name="bodyKey">工序任务明细BodyKey</param>
/// <returns></returns>
public IActionResult MaterDetail(Guid headKey, Guid bodyKey)
{
var data = ValueTuple.Create(headKey, bodyKey);
return View(data);
}
/// <summary>
/// 收货
/// </summary>
/// <param name="headKey">工序任务HeadKey</param>
/// <returns></returns>
public IActionResult Receipt(Guid headKey)
{
TempData["workOrderHeadKey"] = headKey;
return View();
}
/// <summary>
/// 收货统计
/// </summary>
/// <param name="headKey">工序任务Id</param>
/// <returns></returns>
public IActionResult ReceiptStatistics(Guid headKey)
{
TempData["workOrderHeadKeyByStatistics"] = headKey;
ViewBag.headKey = headKey;
return View();
}
/// <summary>
/// 报检页面 适合车间扫码使用
/// </summary>
/// <returns></returns>
public IActionResult InspectionExt()
{
return View();
}
#endregion
#region 获取数据
/// <summary>
/// 加载及分页查询
/// </summary>
/// <param name="pageRequest">表单请求信息</param>
/// <param name="entity">请求条件实例</param>
/// <returns></returns>
[HttpPost]
public string Load(PageReq pageRequest, bus_workOrder_head entity)
{
return Serialize(workOrderService.Load(pageRequest, entity));
}
/// <summary>
/// 加载及分页查询
/// </summary>
/// <param name="pageRequest">表单请求信息</param>
/// <param name="entity">请求条件实例</param>
/// <returns></returns>
[HttpPost]
public string LoadDesc(PageReq pageRequest, bus_workOrder_detail entity)
{
return Serialize(workOrderService.LoadDesc(pageRequest, entity));
}
[HttpGet, HttpPost]
public string LoadMaterDetail(PageReq pageReq, bus_workOrder_detail_material entity)
{
return Serialize(workOrderService.LoadMaterDetail(pageReq, entity));
}
/// <summary>
/// 收货
/// </summary>
/// <param name="pageReq"></param>
/// <param name="materialCode">物料编码</param>
/// <param name="materialName">物料名称</param>
/// <returns></returns>
[HttpPost]
public string LoadReceipt(PageReq pageReq, string materialCode = "", string materialName = "")
{
TempData.Keep("workOrderHeadKey");
var headKey = Guid.Parse(TempData["workOrderHeadKey"].ToString());
return Serialize(workOrderService.LoadReceipt(pageReq, headKey, materialCode, materialName));
}
/// <summary>
/// 更新收货数量
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
public string UpdReceipt(List<base_inventory> model)
{
model.ForEach((item) =>
{
//库存数量 = 收货数量 - 消耗数量
item.qty = item.quantityReceived - item.consumedQuantity;
item.updateTime = DateTime.Now;
item.updateBy = workOrderService.sysWebUser?.Account;
});
return Serialize(workOrderService.UpdReceipt(model));
}
/// <summary>
/// 收货统计--根据物料编码分组统计
/// </summary>
/// <param name="pageReq"></param>
/// <returns></returns>
[HttpGet, HttpPost]
public string LoadReceiptStatistics(PageReq pageReq)
{
return Serialize("");
}
/// <summary>
/// 根据条码获取工序信息、物料信息、设备工艺参数信息
/// </summary>
/// <param name="barCode"></param>
/// <returns></returns>
[HttpPost]
public string InspectionExt(string barCode)
{
return Serialize(workOrderService.GetWorkOrderInfoByPlanCode(barCode));
}
#endregion
#region 处理数据
/// <summary>
/// 删除数据
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
[HttpPost]
[ServiceFilter(typeof(OperLogFilter))]
public string DelByKeys(Guid[] ids)
{
return Serialize(workOrderService.DelByKeys(ids));
}
#endregion
#region 导出数据
/// <summary>
/// 导出数据
/// </summary>
/// <param name="entity">请求条件实例</param>
/// <returns></returns>
[HttpPost]
public string Export(bus_workOrder_head entity)
{
return Serialize(workOrderService.Export(entity));
}
#endregion
#region 自定义方法
/// <summary>
/// 报工
/// </summary>
/// <param name="headKey"></param>
/// <returns></returns>
[HttpPost]
public string WorkReport(Guid headKey, bool IsValdate = true)
{
var user = workOrderService.sysWebUser?.Account;
return Serialize("");
}
/// <summary>
/// 获取当前工序任务明细设备工艺参数
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
[HttpPost]
public string GetEquipmentInfo(bus_workOrder_detail entity)
{
return Serialize(workOrderService.GetEquipmentInfo(entity));
}
/// <summary>
/// 获取当前工序任务明细物料消耗
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public string GetMaterialInfo(bus_workOrder_detail entity)
{
return Serialize(workOrderService.GetMaterialInfo(entity));
}
/// <summary>
/// 数据录入、开工
/// </summary>
/// <param name="headKeys"></param>
/// <param name="bodyKeys"></param>
/// <param name="id"></param>
/// <param name="actualStartTime"></param>
/// <param name="Material"></param>
/// <param name="Equipment"></param>
/// <returns></returns>
public string UpdateProcess(Guid headKeys, Guid bodyKeys, int id, DateTime actualStartTime, List<bus_workOrder_material_use_log> Material, List<bus_equipment_process_template> Equipment, string stationCode)
{
return Serialize(workOrderService.UpdateProcess(headKeys, bodyKeys, id, actualStartTime, Material, Equipment, stationCode));
}
/// <summary>
/// 完工
/// </summary>
/// <param name="headKeys"></param>
/// <param name="id"></param>
/// <param name="actualEndTime"></param>
/// <returns></returns>
[HttpPost]
public string WorkComplete(Guid headKeys, int id, DateTime actualEndTime)
{
return Serialize(workOrderService.WorkComplete(headKeys, id, actualEndTime));
}
#endregion
}
}