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