提交 | 用户 | 时间
|
1e2ff5
|
1 |
package com.billion.main.plcServer.sub; |
b9df2f
|
2 |
|
bf5dcc
|
3 |
import com.billion.common.utils.StringUtils; |
a2cd0f
|
4 |
import com.billion.main.bs.domain.BsBomChildInfo; |
H |
5 |
import com.billion.main.bs.service.IBsBomChildInfoService; |
|
6 |
import com.billion.main.constant.Constants; |
bf5dcc
|
7 |
import com.billion.main.da.domain.DaCollectionParamConf; |
H |
8 |
import com.billion.main.da.domain.DaMaterialCollection; |
|
9 |
import com.billion.main.da.domain.DaParamCollection; |
|
10 |
import com.billion.main.da.domain.DaStationCollection; |
|
11 |
import com.billion.main.da.service.IDaCollectionParamConfService; |
|
12 |
import com.billion.main.da.service.IDaMaterialCollectionService; |
1e2ff5
|
13 |
import com.billion.main.da.service.IDaParamCollectionService; |
a2cd0f
|
14 |
import com.billion.main.da.service.IDaStationCollectionService; |
H |
15 |
import com.billion.main.om.domain.OmOrderScheduling; |
|
16 |
import com.billion.main.om.domain.OmProductionOrderInfo; |
|
17 |
import com.billion.main.om.service.IOmOrderSchedulingService; |
|
18 |
import com.billion.main.om.service.IOmProductionOrderInfoService; |
b9df2f
|
19 |
import com.billion.main.sys.domain.SysCount; |
H |
20 |
import com.billion.main.sys.service.ISysCountService; |
a2cd0f
|
21 |
import com.kangaroohy.milo.model.ReadWriteEntity; |
1e2ff5
|
22 |
import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
H |
23 |
import com.kangaroohy.milo.service.MiloService; |
|
24 |
import lombok.extern.slf4j.Slf4j; |
|
25 |
import org.springframework.stereotype.Component; |
b9df2f
|
26 |
|
a2cd0f
|
27 |
import java.time.LocalDateTime; |
bf5dcc
|
28 |
import java.util.Date; |
a2cd0f
|
29 |
import java.util.List; |
b9df2f
|
30 |
import java.util.Objects; |
a2cd0f
|
31 |
import java.util.concurrent.CompletableFuture; |
1e2ff5
|
32 |
@Slf4j |
H |
33 |
@Component |
|
34 |
public class OPCUaSubscription implements SubscriptionCallback { |
|
35 |
public static MiloService miloService; |
|
36 |
public IDaParamCollectionService daParamCollectionService; |
a2cd0f
|
37 |
public IDaStationCollectionService daStationCollectionService; |
H |
38 |
public IOmProductionOrderInfoService omProductionOrderInfoService; |
|
39 |
public IOmOrderSchedulingService omOrderSchedulingService; |
bf5dcc
|
40 |
public IBsBomChildInfoService bsBomChildInfoService; |
H |
41 |
public IDaCollectionParamConfService daCollectionParamConfService; |
|
42 |
public IDaMaterialCollectionService daMaterialCollectionService; |
b9df2f
|
43 |
public ISysCountService sysCountService; |
bf5dcc
|
44 |
|
1e2ff5
|
45 |
|
H |
46 |
public OPCUaSubscription(MiloService miloService, |
a2cd0f
|
47 |
IDaParamCollectionService daParamCollectionService, |
H |
48 |
IDaStationCollectionService daStationCollectionService, |
|
49 |
IOmProductionOrderInfoService omProductionOrderInfoService, |
|
50 |
IOmOrderSchedulingService omOrderSchedulingService, |
bf5dcc
|
51 |
IBsBomChildInfoService bsBomChildInfoService, |
H |
52 |
IDaCollectionParamConfService daCollectionParamConfService, |
b9df2f
|
53 |
IDaMaterialCollectionService daMaterialCollectionService, |
H |
54 |
ISysCountService sysCountService |
a2cd0f
|
55 |
) { |
1e2ff5
|
56 |
OPCUaSubscription.miloService = miloService; |
H |
57 |
this.daParamCollectionService = daParamCollectionService; |
a2cd0f
|
58 |
this.daStationCollectionService = daStationCollectionService; |
H |
59 |
this.omProductionOrderInfoService = omProductionOrderInfoService; |
|
60 |
this.omOrderSchedulingService = omOrderSchedulingService; |
bf5dcc
|
61 |
this.bsBomChildInfoService = bsBomChildInfoService; |
H |
62 |
this.daCollectionParamConfService = daCollectionParamConfService; |
|
63 |
this.daMaterialCollectionService = daMaterialCollectionService; |
b9df2f
|
64 |
this.sysCountService = sysCountService; |
1e2ff5
|
65 |
} |
H |
66 |
@Override |
|
67 |
public void onSubscribe(String identifier, Object value) { |
a2cd0f
|
68 |
log.info("地址:"+identifier+"值:"+value); |
H |
69 |
try { |
|
70 |
if(null != value ) { |
|
71 |
String[] nodes = identifier.split("[.]"); |
|
72 |
String thoroughfare = nodes[0];//通道 |
|
73 |
String device = nodes[1];//设备 |
|
74 |
String tab = nodes[2];//标记 |
|
75 |
String valueString = value.toString();//地址值 |
|
76 |
CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
|
77 |
onSubscribe(thoroughfare,device,tab,valueString); |
|
78 |
plackWorkOrder(thoroughfare,device,tab,valueString); |
|
79 |
}); |
|
80 |
} |
|
81 |
} catch (Exception e) { |
|
82 |
log.error(e.getMessage()); |
|
83 |
} |
|
84 |
} |
1e2ff5
|
85 |
|
a2cd0f
|
86 |
public void onSubscribe(String thoroughfare,String device,String tab,String valueString) { |
H |
87 |
try { |
|
88 |
if (Constants.RecordData.equals(tab)){ |
|
89 |
//工站交互初始化 |
|
90 |
if (Constants.ZERO.equals(valueString)){ |
|
91 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value("0").build()); |
|
92 |
//请求进站 |
|
93 |
} else if (Constants.ONE.equals(valueString)){ |
b9df2f
|
94 |
//1.1//首工站 |
H |
95 |
if(Constants.C005.equals(device) || Constants.OP005.equals(device) || Constants.P010.equals(device)){ |
a2cd0f
|
96 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value("11").build()); |
H |
97 |
} |
b9df2f
|
98 |
///////除首工站所有工站 |
H |
99 |
else if(Constants.PLC1.contains(device) && Constants.OP310.contains(device)){ |
a2cd0f
|
100 |
//校验SFCCode是否存在 |
H |
101 |
Object SFCCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".SFCCode").getValue(); |
|
102 |
Object PalletID = miloService.readFromOpcUa(thoroughfare + "." + device + ".PalletID").getValue(); |
|
103 |
if (SFCCode == null ) { |
|
104 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value("23").build()); |
|
105 |
} else { |
|
106 |
OmOrderScheduling omOrderScheduling = new OmOrderScheduling(); |
|
107 |
omOrderScheduling.setRemarks(PalletID.toString()); |
|
108 |
List<OmOrderScheduling> resultList = omOrderSchedulingService.selectOmOrderSchedulingList(omOrderScheduling); |
|
109 |
log.info("查询结果数量: {}", resultList); |
|
110 |
BsBomChildInfo bsbomChildInfo= new BsBomChildInfo(); |
|
111 |
bsbomChildInfo.setLocationCode(device); |
|
112 |
bsbomChildInfo.setBomCode(resultList.get(0).getWorkOrderNo()); |
|
113 |
//下发配方 |
|
114 |
formula(thoroughfare, device, bsbomChildInfo); |
|
115 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value("11").build()); |
b9df2f
|
116 |
|
a2cd0f
|
117 |
} |
H |
118 |
} |
|
119 |
//出站保存数据 |
|
120 |
} else if (Constants.TWO.equals(valueString)) { |
b9df2f
|
121 |
OmProductionOrderInfo omProductionOrderInfo = new OmProductionOrderInfo(); |
H |
122 |
OmOrderScheduling omOrderScheduling = new OmOrderScheduling(); |
|
123 |
Object SFCCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".SFCCode").getValue(); |
|
124 |
//上线工位 |
|
125 |
if(Constants.ONLINE.contains(device)){ |
a2cd0f
|
126 |
Object workOrderNumber = miloService.readFromOpcUa(thoroughfare + "." + device + ".WorkOrderNumber").getValue(); |
b9df2f
|
127 |
Object nowQty = miloService.readFromOpcUa(thoroughfare + "." + device + ".PalletID").getValue(); |
a2cd0f
|
128 |
omOrderScheduling.setWorkOrderNo(workOrderNumber.toString()); |
b9df2f
|
129 |
omOrderScheduling.setNowQty((Long) nowQty); |
a2cd0f
|
130 |
omOrderScheduling.setSfcCode(SFCCode.toString()); |
b9df2f
|
131 |
//托盘绑定SFCCode和工单和产线 |
H |
132 |
if(Constants.OP005.equals(device)){ |
|
133 |
omOrderScheduling.setRemarks("Body"); |
bf5dcc
|
134 |
} |
b9df2f
|
135 |
if(Constants.C005.equals(device)){ |
H |
136 |
omOrderScheduling.setRemarks("Head"); |
bf5dcc
|
137 |
} |
b9df2f
|
138 |
omOrderSchedulingService.insertOmOrderScheduling(omOrderScheduling); |
H |
139 |
}else if(Constants.OFFLINE.contains(device)){ |
|
140 |
if(Constants.C070.equals(device)){ |
|
141 |
omOrderScheduling.setRemarks("Head"); |
|
142 |
omOrderScheduling.setSfcCode(SFCCode.toString()); |
|
143 |
List<OmOrderScheduling> omOrderSchedulingList = omOrderSchedulingService.selectOmOrderSchedulingList(omOrderScheduling); |
|
144 |
Object nowQty = omOrderSchedulingList.get(0).getNowQty(); |
|
145 |
Object WorkOrderNumber = omOrderSchedulingList.get(0).getWorkOrderNo(); |
|
146 |
omProductionOrderInfo.setWorkOrderNo(WorkOrderNumber.toString()); |
|
147 |
List<OmProductionOrderInfo> omProductionOrderInfoList = omProductionOrderInfoService.selectOmProductionOrderInfoList(omProductionOrderInfo); |
|
148 |
Object headQty = omProductionOrderInfoList.get(0).getHeadQty(); |
|
149 |
if (nowQty == headQty){ |
|
150 |
omProductionOrderInfoList.get(0).setHeadStatus("3"); |
a2cd0f
|
151 |
|
b9df2f
|
152 |
|
H |
153 |
omProductionOrderInfoService.updateOmProductionOrderInfo(omProductionOrderInfoList.get(0)); |
bf5dcc
|
154 |
} |
b9df2f
|
155 |
} else if (Constants.OP310.equals(device)) { |
H |
156 |
omOrderScheduling.setRemarks("Body"); |
|
157 |
omOrderScheduling.setSfcCode(SFCCode.toString()); |
|
158 |
List<OmOrderScheduling> omOrderSchedulingList = omOrderSchedulingService.selectOmOrderSchedulingList(omOrderScheduling); |
|
159 |
Object nowQty = omOrderSchedulingList.get(0).getNowQty(); |
|
160 |
Object WorkOrderNumber = omOrderSchedulingList.get(0).getWorkOrderNo(); |
|
161 |
omProductionOrderInfo.setWorkOrderNo(WorkOrderNumber.toString()); |
|
162 |
List<OmProductionOrderInfo> omProductionOrderInfoList = omProductionOrderInfoService.selectOmProductionOrderInfoList(omProductionOrderInfo); |
|
163 |
Object bodyQty = omProductionOrderInfoList.get(0).getBodyQty(); |
|
164 |
if (nowQty == bodyQty){ |
|
165 |
omProductionOrderInfoList.get(0).setBodyStatus("3"); |
|
166 |
|
|
167 |
|
|
168 |
omProductionOrderInfoService.updateOmProductionOrderInfo(omProductionOrderInfoList.get(0)); |
bf5dcc
|
169 |
} |
H |
170 |
} |
b9df2f
|
171 |
} else if (Constants.P010.equals(device)) { |
H |
172 |
Object workOrderNumber = miloService.readFromOpcUa(thoroughfare + "." + device + ".WorkOrderNumber").getValue(); |
|
173 |
Object nowQty = miloService.readFromOpcUa(thoroughfare + "." + device + ".PalletID").getValue(); |
|
174 |
omOrderScheduling.setWorkOrderNo(workOrderNumber.toString()); |
|
175 |
omOrderScheduling.setNowQty((Long) nowQty); |
|
176 |
omOrderScheduling.setSfcCode(SFCCode.toString()); |
|
177 |
omOrderScheduling.setRemarks("Pre"); |
|
178 |
omOrderSchedulingService.insertOmOrderScheduling(omOrderScheduling); |
|
179 |
List<OmOrderScheduling> omOrderSchedulingList = omOrderSchedulingService.selectOmOrderSchedulingList(omOrderScheduling); |
|
180 |
Object WorkOrderNumber = omOrderSchedulingList.get(0).getWorkOrderNo(); |
|
181 |
omProductionOrderInfo.setWorkOrderNo(WorkOrderNumber.toString()); |
|
182 |
List<OmProductionOrderInfo> omProductionOrderInfoList = omProductionOrderInfoService.selectOmProductionOrderInfoList(omProductionOrderInfo); |
|
183 |
Object preQty = omProductionOrderInfoList.get(0).getPreQty(); |
|
184 |
if (nowQty == preQty){ |
|
185 |
omProductionOrderInfoList.get(0).setPreStatus("3"); |
|
186 |
|
|
187 |
|
|
188 |
omProductionOrderInfoService.updateOmProductionOrderInfo(omProductionOrderInfoList.get(0)); |
|
189 |
|
|
190 |
} |
a2cd0f
|
191 |
} |
b9df2f
|
192 |
//查询descriptive字段等于1的采集项保存到扫码保存到da_material_collection表里 |
H |
193 |
DaCollectionParamConf daCollectionParamConf1 = new DaCollectionParamConf(); |
|
194 |
daCollectionParamConf1.setProcessesCode(device); |
|
195 |
daCollectionParamConf1.setDescriptive("1"); |
|
196 |
List<DaCollectionParamConf> daCollectionParamConfList1 = daCollectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf1); |
|
197 |
for (DaCollectionParamConf conf : daCollectionParamConfList1) { |
|
198 |
String gatherAddress = conf.getGatherAddress(); |
|
199 |
Object valueObj = miloService.readFromOpcUa(gatherAddress).getValue(); // 获取原始值对象:ml-citation{ref="4" data="citationList"} |
|
200 |
if (valueObj == null || StringUtils.isEmpty(valueObj.toString())) { |
|
201 |
log.warn("采集地址{}返回空值,跳过存储", gatherAddress); |
|
202 |
continue; // 终止当前循环迭代:ml-citation{ref="1,2" data="citationList"} |
|
203 |
} |
|
204 |
DaMaterialCollection materialCollection = new DaMaterialCollection(); |
|
205 |
materialCollection.setSfcCode(SFCCode.toString()); |
|
206 |
materialCollection.setLocationCode(device); |
|
207 |
materialCollection.setParamName(conf.getParameterSetName()); |
|
208 |
materialCollection.setParamValue((String) miloService.readFromOpcUa(gatherAddress).getValue()); |
|
209 |
materialCollection.setCollectTime(new Date()); |
|
210 |
daMaterialCollectionService.insertDaMaterialCollection(materialCollection); |
|
211 |
} |
|
212 |
//查询descriptive字段等于2的采集项保存到扫码保存到da_param_collection表里 |
|
213 |
DaCollectionParamConf daCollectionParamConf2 = new DaCollectionParamConf(); |
|
214 |
daCollectionParamConf2.setProcessesCode(device); |
|
215 |
daCollectionParamConf2.setDescriptive("2"); |
|
216 |
List<DaCollectionParamConf> daCollectionParamConfList2 = daCollectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf2); |
|
217 |
for (DaCollectionParamConf conf : daCollectionParamConfList2) { |
|
218 |
String gatherAddress = conf.getGatherAddress(); |
|
219 |
Object valueObj = miloService.readFromOpcUa(gatherAddress).getValue(); // 获取原始值对象:ml-citation{ref="4" data="citationList"} |
|
220 |
if (valueObj == null || StringUtils.isEmpty(valueObj.toString())) { |
|
221 |
log.warn("采集地址{}返回空值,跳过存储", gatherAddress); |
|
222 |
continue; // 终止当前循环迭代:ml-citation{ref="1,2" data="citationList"} |
|
223 |
} |
|
224 |
DaParamCollection paramCollection = new DaParamCollection(); |
|
225 |
paramCollection.setSfcCode(SFCCode.toString()); |
|
226 |
paramCollection.setLocationCode(device); |
|
227 |
paramCollection.setParamName(conf.getParameterSetName()); |
|
228 |
paramCollection.setParamValue((String) miloService.readFromOpcUa(gatherAddress).getValue()); |
|
229 |
paramCollection.setCollectionTime(new Date()); |
|
230 |
daParamCollectionService.insertDaParamCollection(paramCollection); |
|
231 |
} |
|
232 |
DaStationCollection daStationCollection = new DaStationCollection(); |
|
233 |
daStationCollection.setLocationCode(device); |
|
234 |
daStationCollection.setSfcCode(SFCCode.toString()); |
|
235 |
daStationCollection.setInboundTime((Date) miloService.readFromOpcUa(thoroughfare + "." + device + ".StartTime").getValue()); |
|
236 |
daStationCollection.setOutboundTime((Date) miloService.readFromOpcUa(thoroughfare + "." + device + ".StopTime").getValue()); |
|
237 |
daStationCollectionService.insertDaStationCollection(daStationCollection); |
|
238 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value("21").build()); |
a2cd0f
|
239 |
} |
H |
240 |
} |
|
241 |
} |
|
242 |
catch (Exception e) { |
|
243 |
log.error(e.getMessage()); |
|
244 |
} |
|
245 |
} |
|
246 |
//首工站下发工单,并生成SN码 |
|
247 |
private static final String[] MONTH = {"A","B","C","D","E","F","G","H","I","J","K","L"}; |
|
248 |
public void plackWorkOrder(String thoroughfare, String device, String tab, String valueString) { |
|
249 |
try { |
|
250 |
if (Constants.WorkOrderRequest.equals(tab)) { |
b9df2f
|
251 |
if (Constants.ZERO.equals(valueString)) { |
H |
252 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderRequestDone").value("0").build()); |
|
253 |
}else if (Constants.ONE.equals(valueString)){ |
|
254 |
if (Constants.OP005.equals(device)){ |
bf5dcc
|
255 |
// 查询数据库获取符合条件的订单信息 |
b9df2f
|
256 |
OmProductionOrderInfo getBodyOrder = omProductionOrderInfoService.getBodyOrder(); |
H |
257 |
if (getBodyOrder != null) { |
|
258 |
//判断当前下发数量是否满足计划数量 |
bf5dcc
|
259 |
//更新工单状态 |
b9df2f
|
260 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderNumber").value(getBodyOrder.getWorkOrderNo()).build()); |
H |
261 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ProductionPlan").value(String.valueOf(getBodyOrder.getPlanQty())).build()); |
|
262 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".EngineType").value(getBodyOrder.getEngineType()).build()); |
a2cd0f
|
263 |
//生成sn码 |
b9df2f
|
264 |
SysCount serialNumber = sysCountService.getSerialNumber(); |
a2cd0f
|
265 |
String A3 = String.valueOf(LocalDateTime.now().getYear()).substring(2); |
b9df2f
|
266 |
//判断是否跨年 |
H |
267 |
if(A3.equals(String.valueOf(serialNumber.getYear()))){ |
|
268 |
String A1 = getBodyOrder.getEngineType();//获取产品型号 |
|
269 |
String A2 = "3";//固定产线 |
a2cd0f
|
270 |
String A4 = MONTH[LocalDateTime.now().getMonthValue() - 1];// 获取当前月份(1-12) |
b9df2f
|
271 |
String A5 = String.format("%05d", serialNumber.getSerialNumber()); |
a2cd0f
|
272 |
String SFCCode = A1 + A2 + A3+ A4 + A5; |
H |
273 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".SFCCode").value(SFCCode).build()); |
b9df2f
|
274 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MESSFCCode").value(SFCCode).build()); |
H |
275 |
sysCountService.updateSerialNumber(); |
a2cd0f
|
276 |
}else{ |
b9df2f
|
277 |
sysCountService.clean(); |
H |
278 |
sysCountService.updateYear(); |
|
279 |
String A1 = getBodyOrder.getEngineType();//获取产品型号 |
a2cd0f
|
280 |
String A2 = "3"; |
b9df2f
|
281 |
String newA3 = String.valueOf(LocalDateTime.now().getYear()).substring(2); |
a2cd0f
|
282 |
String A4 = MONTH[LocalDateTime.now().getMonthValue() - 1];// 获取当前月份(1-12) |
b9df2f
|
283 |
String A5 = String.format("%05d", sysCountService.getSerialNumber().getSerialNumber()); |
H |
284 |
String SFCCode = A1 + A2 + newA3+ A4 + A5; |
a2cd0f
|
285 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".SFCCode").value(SFCCode).build()); |
b9df2f
|
286 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MESSFCCode").value(SFCCode).build()); |
H |
287 |
sysCountService.updateSerialNumber(); |
a2cd0f
|
288 |
} |
H |
289 |
// 更新 WorkOrderRequestDone 地址块 |
|
290 |
BsBomChildInfo bsbomChildInfo= new BsBomChildInfo(); |
|
291 |
bsbomChildInfo.setLocationCode(device); |
b9df2f
|
292 |
bsbomChildInfo.setBomCode(getBodyOrder.getWorkOrderNo()); |
a2cd0f
|
293 |
//发下工艺配方 |
H |
294 |
formula(thoroughfare, device, bsbomChildInfo); |
b9df2f
|
295 |
omProductionOrderInfoService.updateBodyStatus1(); |
H |
296 |
//判断缸体工单完成 |
|
297 |
OmProductionOrderInfo getBodyOrder2 = omProductionOrderInfoService.getBodyOrder(); |
|
298 |
if (Objects.equals(getBodyOrder2.getBodyQty(), getBodyOrder2.getPlanQty())){ |
|
299 |
omProductionOrderInfoService.updateBodyStatus2(); |
|
300 |
} |
|
301 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(getBodyOrder2.getBodyQty()).build()); |
|
302 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderRequestDone").value("11").build()); |
|
303 |
} |
|
304 |
} else if (Constants.C005.equals(device)) { |
|
305 |
// 查询数据库获取符合条件的订单信息 |
|
306 |
OmProductionOrderInfo getHeadOrder = omProductionOrderInfoService.getHeadOrder(); |
|
307 |
if (getHeadOrder != null) { |
|
308 |
//判断当前下发数量是否满足计划数量 |
|
309 |
//更新工单状态 |
|
310 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderNumber").value(getHeadOrder.getWorkOrderNo()).build()); |
|
311 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ProductionPlan").value(String.valueOf(getHeadOrder.getPlanQty())).build()); |
|
312 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".EngineType").value(getHeadOrder.getEngineType()).build()); |
|
313 |
//生成sn码 |
|
314 |
SysCount headNumber = sysCountService.getHeadNumber(); |
|
315 |
String A3 = String.valueOf(LocalDateTime.now().getYear()).substring(2); |
|
316 |
//判断是否跨年 |
|
317 |
if(A3.equals(String.valueOf(headNumber.getYear()))){ |
|
318 |
String A1 = getHeadOrder.getEngineType();//获取产品型号 |
|
319 |
String A2 = "3";//固定产线 |
|
320 |
String A4 = MONTH[LocalDateTime.now().getMonthValue() - 1];// 获取当前月份(1-12) |
|
321 |
String A5 = String.format("%05d", headNumber.getHeadNumber()); |
|
322 |
String SFCCode = A1 + A2 + A3+ A4 + A5; |
|
323 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".SFCCode").value(SFCCode).build()); |
|
324 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MESSFCCode").value(SFCCode).build()); |
|
325 |
sysCountService.updateHeadNumber(); |
|
326 |
}else{ |
|
327 |
sysCountService.clean(); |
|
328 |
sysCountService.updateYear(); |
|
329 |
String A1 = getHeadOrder.getEngineType();//获取产品型号 |
|
330 |
String A2 = "3"; |
|
331 |
String newA3 = String.valueOf(LocalDateTime.now().getYear()).substring(2); |
|
332 |
String A4 = MONTH[LocalDateTime.now().getMonthValue() - 1];// 获取当前月份(1-12) |
|
333 |
String A5 = String.format("%05d", sysCountService.getHeadNumber().getHeadNumber()); |
|
334 |
String SFCCode = A1 + A2 + newA3+ A4 + A5; |
|
335 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".SFCCode").value(SFCCode).build()); |
|
336 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MESSFCCode").value(SFCCode).build()); |
|
337 |
sysCountService.updateHeadNumber(); |
a2cd0f
|
338 |
} |
b9df2f
|
339 |
// 更新 WorkOrderRequestDone 地址块 |
H |
340 |
BsBomChildInfo bsbomChildInfo= new BsBomChildInfo(); |
|
341 |
bsbomChildInfo.setLocationCode(device); |
|
342 |
bsbomChildInfo.setBomCode(getHeadOrder.getWorkOrderNo()); |
|
343 |
//发下工艺配方 |
|
344 |
formula(thoroughfare, device, bsbomChildInfo); |
|
345 |
omProductionOrderInfoService.updateHeadStatus1(); |
|
346 |
//判断缸体工单完成 |
|
347 |
OmProductionOrderInfo getHeadOrder2 = omProductionOrderInfoService.getHeadOrder(); |
|
348 |
if (Objects.equals(getHeadOrder2.getHeadQty(), getHeadOrder2.getPlanQty())){ |
|
349 |
omProductionOrderInfoService.updateHeadStatus2(); |
|
350 |
} |
|
351 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(getHeadOrder2.getHeadQty()).build()); |
|
352 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderRequestDone").value("11").build()); |
|
353 |
} |
|
354 |
} else if (Constants.P010.equals(device)) { |
|
355 |
// 查询数据库获取符合条件的订单信息 |
|
356 |
OmProductionOrderInfo getPreOrder = omProductionOrderInfoService.getPreOrder(); |
|
357 |
if (getPreOrder != null) { |
|
358 |
//判断当前下发数量是否满足计划数量 |
|
359 |
//更新工单状态 |
|
360 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderNumber").value(getPreOrder.getWorkOrderNo()).build()); |
|
361 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ProductionPlan").value(String.valueOf(getPreOrder.getPlanQty())).build()); |
|
362 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".EngineType").value(getPreOrder.getEngineType()).build()); |
|
363 |
//生成sn码 |
|
364 |
SysCount preNumber = sysCountService.getPreNumber(); |
|
365 |
String A3 = String.valueOf(LocalDateTime.now().getYear()).substring(2); |
|
366 |
if(A3.equals(String.valueOf(preNumber.getYear()))){ |
|
367 |
String A1 = getPreOrder.getEngineType();//获取产品型号 |
|
368 |
String A2 = "3"; |
|
369 |
String A4 = MONTH[LocalDateTime.now().getMonthValue() - 1];// 获取当前月份(1-12) |
|
370 |
String A5 = String.format("%05d", preNumber.getPreNumber()); |
|
371 |
String SFCCode = A1 + A2 + A3+ A4 + A5; |
|
372 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".SFCCode").value(SFCCode).build()); |
|
373 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MESSFCCode").value(SFCCode).build()); |
|
374 |
sysCountService.updatePreNumber(); |
|
375 |
}else{ |
|
376 |
sysCountService.clean(); |
|
377 |
sysCountService.updateYear(); |
|
378 |
String A1 = getPreOrder.getEngineType();//获取产品型号 |
|
379 |
String A2 = "3"; |
|
380 |
String newA3 = String.valueOf(LocalDateTime.now().getYear()).substring(2); |
|
381 |
String A4 = MONTH[LocalDateTime.now().getMonthValue() - 1];// 获取当前月份(1-12) |
|
382 |
String A5 = String.format("%05d", sysCountService.getPreNumber().getPreNumber()); |
|
383 |
String SFCCode = A1 + A2 + newA3+ A4 + A5; |
|
384 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".SFCCode").value(SFCCode).build()); |
|
385 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MESSFCCode").value(SFCCode).build()); |
|
386 |
sysCountService.updateHeadNumber(); |
|
387 |
} |
|
388 |
|
|
389 |
// 更新 WorkOrderRequestDone 地址块 |
|
390 |
BsBomChildInfo bsbomChildInfo= new BsBomChildInfo(); |
|
391 |
bsbomChildInfo.setLocationCode(device); |
|
392 |
bsbomChildInfo.setBomCode(getPreOrder.getWorkOrderNo()); |
|
393 |
//发下工艺配方 |
|
394 |
formula(thoroughfare, device, bsbomChildInfo); |
|
395 |
omProductionOrderInfoService.updatePreStatus1(); |
|
396 |
//判断缸体工单完成 |
|
397 |
OmProductionOrderInfo getPreOrder2 = omProductionOrderInfoService.getPreOrder(); |
|
398 |
if (Objects.equals(getPreOrder2.getPreQty(), getPreOrder2.getPlanQty())){ |
|
399 |
omProductionOrderInfoService.updatePreStatus2(); |
|
400 |
} |
|
401 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(getPreOrder2.getPreQty()).build()); |
|
402 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderRequestDone").value("11").build()); |
a2cd0f
|
403 |
} |
H |
404 |
} |
|
405 |
} |
|
406 |
} |
|
407 |
} catch (Exception e) { |
|
408 |
log.error(e.getMessage()); |
1e2ff5
|
409 |
} |
H |
410 |
} |
a2cd0f
|
411 |
|
H |
412 |
//发下工艺配方方法 |
|
413 |
private void formula(String thoroughfare, String device, BsBomChildInfo bsbomChildInfo) throws Exception { |
bf5dcc
|
414 |
List<BsBomChildInfo> bomChildList = bsBomChildInfoService.selectBsBomChildInfoList(bsbomChildInfo); |
a2cd0f
|
415 |
for (int i = 1; i <= bomChildList.size(); i++) { |
H |
416 |
// 生成 MaterialCode 节点 |
|
417 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".Material1Code"+ i).value(bomChildList.get(i-1).getMaterialCode()).build()); |
|
418 |
// 生成 MaterialNumber 节点 |
|
419 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".Material1Number"+ i).value(bomChildList.get(i-1).getCostQty()).build()); |
|
420 |
} |
|
421 |
} |
|
422 |
|
|
423 |
} |
|
424 |
// |
|
425 |
|