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