CutWeldService.cs
8.96 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
using ApkInfo;
using Hh.Mes.Common;
using Hh.Mes.Common.config;
using Hh.Mes.Common.Json;
using Hh.Mes.Common.log;
using Hh.Mes.Common.Redis;
using Hh.Mes.Pojo.System;
using Hh.Mes.POJO.Entity;
using Hh.Mes.POJO.EnumEntitys;
using Hh.Mes.POJO.Response;
using Hh.Mes.POJO.ViewModel;
using Hh.Mes.POJO.WebEntity;
using Hh.Mes.Service.Repository;
using Hh.Mes.Service.SystemAuth;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using static Microsoft.AspNetCore.Hosting.Internal.HostingApplication;
namespace Hh.Mes.Service
{
public class CutWeldService : RepositorySqlSugar<dynamic>
{
/// <summary>
/// 管段工序完工调用
/// </summary>
/// <param name="BarCode">追踪码</param>
/// <param name="processesState">状态</param>
/// <returns></returns>
public void SendIWPTechnologylineProcess(string BarCode, int processesState)
{
if (string.IsNullOrWhiteSpace(BarCode)) return;
//切割完成处理,ECS完成时会更新套料方案,工单工序,这里只需要组织数据反馈上游
var oprSequenceCode = "";
if (processesState == (int)EnumCutHeadState.已套料)
oprSequenceCode = EnumoprSequenceCode.套料;
if (processesState == (int)EnumCutHeadState.切坡完成)
oprSequenceCode = EnumoprSequenceCode.切割坡口;
if (processesState == (int)EnumCutHeadState.切割完成)
oprSequenceCode = EnumoprSequenceCode.切割;
if (processesState == (int)EnumCutHeadState.坡口完成)
oprSequenceCode = EnumoprSequenceCode.坡口;
if (processesState == (int)EnumCutHeadState.打磨完成)
oprSequenceCode = EnumoprSequenceCode.打磨;
if (processesState == (int)EnumCutHeadState.组对完成)
oprSequenceCode = EnumoprSequenceCode.组对;
if (processesState == (int)EnumCutHeadState.焊接完成)
oprSequenceCode = EnumoprSequenceCode.焊接;
if (processesState == (int)EnumCutHeadState.组焊完成)
oprSequenceCode = EnumoprSequenceCode.组焊;
if (oprSequenceCode == "") return;
var workOrderDetail = base.Context.Queryable<bus_workOrder_detail>().Where(x => x.oprSequenceCode == oprSequenceCode && x.barCode == BarCode).First();
if (workOrderDetail == null) return;
//更新工单明细
workOrderDetail.workReportStatus = (int)EnumWorkReportStatus.完工已报工;
Context.Updateable(workOrderDetail).UpdateColumns(t => new { t.workReportStatus }).ExecuteCommand();
var data = new
{
workOrderCode = workOrderDetail.workOrderCode,//工单
partCode = workOrderDetail.partCode,//管段号
barCode = workOrderDetail.barCode,//追踪码(管段码)
oprSequenceCode = workOrderDetail.oprSequenceCode,//工序
stationCode = workOrderDetail.stationCode,//工位
equipmentCode = workOrderDetail.equipmentCode,//生产设备
actualStartTime = workOrderDetail.actualStartTime,//开始时间
actualEndTime = workOrderDetail.actualEndTime,// 完成时间
cutMaterCode = workOrderDetail.cutMaterCode,//管段物料编码
weldNo = workOrderDetail.weldNo,//组对(焊接)焊口号
batchNo = workOrderDetail.batchNo,//组对(焊接)批次号
createBy = workOrderDetail.createBy,//操作人
};
return;
//调用上游MES工序完工反馈
var url = GetDictionaryDictValue("UrlProcessFeedback", "GetUrl");
HttpManVoid(url, data, EnumLog.调用上游MES工序完工反馈.ToString(), method: "post");
}
/// <summary>
/// PDA,ECS调用,任务号设备完工报工
/// </summary>
/// <param name="taskCode">任务号</param>
/// <param name="equipmentCode">设备编码</param>
/// <returns></returns>
public void SendTaskEnd(string taskCode, string equipmentCode)
{
if (string.IsNullOrWhiteSpace(taskCode) || string.IsNullOrWhiteSpace(equipmentCode)) return;
//切割完成处理,ECS完成时会更新套料方案,工单工序,这里只需要组织数据反馈上游
var oprSequenceCode = "";
if (equipmentCode == EquipmentCode.锯床)
oprSequenceCode = EnumoprSequenceCode.切割;
if (equipmentCode == EquipmentCode.端面坡口机)
oprSequenceCode = EnumoprSequenceCode.坡口;
if (equipmentCode == EquipmentCode.机器人打磨)
oprSequenceCode = EnumoprSequenceCode.打磨;
if (equipmentCode == EquipmentCode.机器人XY焊接)
oprSequenceCode = EnumoprSequenceCode.组焊;
if (equipmentCode == EquipmentCode.组焊一体机)
oprSequenceCode = EnumoprSequenceCode.组焊;
if (equipmentCode == EquipmentCode.组焊平台)
oprSequenceCode = EnumoprSequenceCode.组焊;
if (oprSequenceCode == "") return;
var workOrderDetail = base.Context.Queryable<bus_workOrder_detail>().Where(x => x.oprSequenceCode == oprSequenceCode && x.barCode == taskCode).First();
var taskEquipment = base.Context.Queryable<base_task_equipment>().Where(x => x.taskCode == taskCode).First();
//工单明细没有不反馈,已经完工不反馈
if (workOrderDetail == null) return;
if(workOrderDetail.state== (int)EnumOrderBodyStatus.已完成) return;
//更新任务
if (taskEquipment != null)
{
if (taskEquipment.sendStatus == 0)
taskEquipment.sendStatus = (int)EnumWeldTechnologyEquipmentStatus.成功;
taskEquipment.updateTime = DateTime.Now;
taskEquipment.updateBy = sysUserApi?.Account;
Context.Updateable(taskEquipment).UpdateColumns(t => new { t.sendStatus, t.updateTime, t.updateBy }).AddQueue();
workOrderDetail.actualEndTime = taskEquipment.updateTime;
}
else {
workOrderDetail.actualEndTime = DateTime.Now;
}
//更新工单明细
workOrderDetail.state = (int)EnumOrderBodyStatus.已完成;
workOrderDetail.equipmentCode = equipmentCode;
workOrderDetail.updateBy = sysUserApi?.Account;
workOrderDetail.workReportStatus = (int)EnumWorkReportStatus.完工已报工;
Context.Updateable(workOrderDetail).UpdateColumns(t => new { t.state, t.actualEndTime, t.equipmentCode, t.updateBy, t.workReportStatus }).AddQueue();
//更新工单
Context.Updateable<bus_workOrder_head>()
.SetColumns(x => x.state == (int)EnumOrderBodyStatus.已完成)
.SetColumns(x => x.actualEndTime == DateTime.Now)
.SetColumns(x => x.updateTime == DateTime.Now)
.Where(x => x.keys == workOrderDetail.headKeys).AddQueue();
if (taskEquipment != null)
{
Context.Updateable<bus_workOrder_head>()
.SetColumns(x => x.updateBy == taskEquipment.createBy)
.Where(x => x.keys == workOrderDetail.headKeys).AddQueue();
}
else {
string userAccount = sysUserApi?.Account;
Context.Updateable<bus_workOrder_head>()
.SetColumns(x => x.updateBy == userAccount)
.Where(x => x.keys == workOrderDetail.headKeys).AddQueue();
}
Context.SaveQueues();
var data = new
{
workOrderCode = workOrderDetail.workOrderCode,//工单
partCode = workOrderDetail.partCode,//管段号
barCode = workOrderDetail.barCode,//追踪码(管段码)
oprSequenceCode = workOrderDetail.oprSequenceCode,//工序
stationCode = workOrderDetail.stationCode,//工位
equipmentCode = equipmentCode,//生产设备
actualStartTime = workOrderDetail.actualStartTime,//开始时间
actualEndTime = workOrderDetail.actualEndTime,// 完成时间
cutMaterCode = workOrderDetail.cutMaterCode,//管段物料编码
weldNo = workOrderDetail.weldNo,//组对(焊接)焊口号
batchNo = workOrderDetail.batchNo,//组对(焊接)批次号
createBy = workOrderDetail.createBy,//操作人
};
return;
//调用上游MES工序完工反馈
var url = GetDictionaryDictValue("UrlProcessFeedback", "GetUrl");
HttpManVoid(url, data, EnumLog.调用上游MES工序完工反馈.ToString(), method: "post");
}
}
}