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