提交 | 用户 | 时间
|
e57a89
|
1 |
package com.jcdm.main.da.paramCollection.service.impl; |
懒 |
2 |
|
6a462f
|
3 |
import cn.hutool.core.collection.CollUtil; |
b64ed2
|
4 |
import cn.hutool.core.date.DateUtil; |
237733
|
5 |
import cn.hutool.core.util.ObjectUtil; |
6a462f
|
6 |
import cn.hutool.core.util.StrUtil; |
8f0f8d
|
7 |
import cn.hutool.db.Db; |
6a462f
|
8 |
import cn.hutool.http.HttpRequest; |
W |
9 |
import cn.hutool.http.HttpResponse; |
|
10 |
import cn.hutool.json.JSONUtil; |
7bee80
|
11 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
0ce25f
|
12 |
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
237733
|
13 |
import com.jcdm.common.core.domain.AjaxResult; |
e57a89
|
14 |
import com.jcdm.common.utils.DateUtils; |
a60fef
|
15 |
import com.jcdm.common.utils.StringUtils; |
7bee80
|
16 |
import com.jcdm.main.bs.formula.service.IBsFormulaInfoService; |
懒 |
17 |
import com.jcdm.main.bs.formula.service.impl.BsFormulaInfoServiceImpl; |
b77c7b
|
18 |
import com.jcdm.main.bs.formulaChild.domain.BsFormulaChildInfo; |
懒 |
19 |
import com.jcdm.main.bs.formulaChild.mapper.BsFormulaChildInfoMapper; |
7bee80
|
20 |
import com.jcdm.main.bs.formulaChild.service.IBsFormulaChildInfoService; |
6a462f
|
21 |
import com.jcdm.main.constant.Constants; |
b64ed2
|
22 |
import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf; |
懒 |
23 |
import com.jcdm.main.da.collectionParamConf.mapper.DaCollectionParamConfMapper; |
5966d6
|
24 |
import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService; |
e57a89
|
25 |
import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
懒 |
26 |
import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper; |
|
27 |
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; |
8cfe20
|
28 |
import com.jcdm.main.da.paramCollectionTemp.domain.DaParamCollectionTemp; |
A |
29 |
import com.jcdm.main.da.paramCollectionTemp.service.IDaParamCollectionTempService; |
32483a
|
30 |
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; |
懒 |
31 |
import com.jcdm.main.da.passingStationCollection.mapper.DaPassingStationCollectionMapper; |
|
32 |
import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; |
054a69
|
33 |
import com.jcdm.main.plcserver.sub.OPCUaSubscription; |
237733
|
34 |
import com.jcdm.main.restful.factoryMes.service.RestfulService; |
6a462f
|
35 |
import com.jcdm.main.restful.qingYan.doman.ChildVO; |
W |
36 |
import com.jcdm.main.restful.qingYan.doman.ParentVO; |
32483a
|
37 |
import com.kangaroohy.milo.model.ReadWriteEntity; |
懒 |
38 |
import com.kangaroohy.milo.service.MiloService; |
bdb404
|
39 |
import lombok.extern.slf4j.Slf4j; |
054a69
|
40 |
import org.apache.ibatis.session.ExecutorType; |
懒 |
41 |
import org.apache.ibatis.session.SqlSession; |
|
42 |
import org.apache.ibatis.session.SqlSessionFactory; |
bdb404
|
43 |
import org.slf4j.Logger; |
A |
44 |
import org.slf4j.LoggerFactory; |
e57a89
|
45 |
import org.springframework.beans.factory.annotation.Autowired; |
5966d6
|
46 |
import org.springframework.security.core.parameters.P; |
e57a89
|
47 |
import org.springframework.stereotype.Service; |
懒 |
48 |
|
054a69
|
49 |
import javax.annotation.Resource; |
5966d6
|
50 |
import java.text.SimpleDateFormat; |
A |
51 |
import java.time.Instant; |
b64ed2
|
52 |
import java.util.*; |
d76bba
|
53 |
import java.util.concurrent.CompletableFuture; |
6a462f
|
54 |
import java.util.stream.Collectors; |
e57a89
|
55 |
|
懒 |
56 |
/** |
|
57 |
* 设备产品过程参数采集Service业务层处理 |
|
58 |
* |
|
59 |
* @author yyt |
|
60 |
* @date 2023-12-13 |
|
61 |
*/ |
bdb404
|
62 |
@Slf4j |
e57a89
|
63 |
@Service |
0ce25f
|
64 |
public class DaParamCollectionServiceImpl extends ServiceImpl<DaParamCollectionMapper,DaParamCollection> implements IDaParamCollectionService |
e57a89
|
65 |
{ |
bdb404
|
66 |
private static final Logger logger = LoggerFactory.getLogger("sys-user"); |
A |
67 |
|
e57a89
|
68 |
@Autowired |
懒 |
69 |
private DaParamCollectionMapper daParamCollectionMapper; |
b64ed2
|
70 |
|
懒 |
71 |
@Autowired |
|
72 |
private DaCollectionParamConfMapper daCollectionParamConfMapper; |
b77c7b
|
73 |
|
懒 |
74 |
@Autowired |
|
75 |
private BsFormulaChildInfoMapper bsFormulaChildInfoMapper; |
7bee80
|
76 |
|
懒 |
77 |
@Autowired |
|
78 |
private IBsFormulaChildInfoService bsFormulaChildInfoService; |
32483a
|
79 |
|
懒 |
80 |
@Autowired |
|
81 |
private MiloService miloService; |
|
82 |
|
|
83 |
@Autowired |
|
84 |
private DaPassingStationCollectionMapper daPassingStationCollectionMapper; |
e57a89
|
85 |
|
054a69
|
86 |
@Resource |
懒 |
87 |
private SqlSessionFactory sqlSessionFactory; |
|
88 |
|
ddb300
|
89 |
@Autowired |
A |
90 |
private IDaParamCollectionService daParamCollectionService; |
5966d6
|
91 |
|
A |
92 |
@Autowired |
|
93 |
private IDaCollectionParamConfService daCollectionParamConfService; |
8cfe20
|
94 |
|
A |
95 |
@Autowired |
|
96 |
private IDaParamCollectionTempService daParamCollectionTempService; |
237733
|
97 |
|
A |
98 |
public SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
ddb300
|
99 |
|
e57a89
|
100 |
/** |
懒 |
101 |
* 查询设备产品过程参数采集 |
|
102 |
* |
|
103 |
* @param id 设备产品过程参数采集主键 |
|
104 |
* @return 设备产品过程参数采集 |
|
105 |
*/ |
|
106 |
@Override |
|
107 |
public DaParamCollection selectDaParamCollectionById(Long id) |
|
108 |
{ |
|
109 |
return daParamCollectionMapper.selectDaParamCollectionById(id); |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* 查询设备产品过程参数采集列表 |
|
114 |
* |
|
115 |
* @param daParamCollection 设备产品过程参数采集 |
|
116 |
* @return 设备产品过程参数采集 |
|
117 |
*/ |
|
118 |
@Override |
|
119 |
public List<DaParamCollection> selectDaParamCollectionList(DaParamCollection daParamCollection) |
|
120 |
{ |
|
121 |
return daParamCollectionMapper.selectDaParamCollectionList(daParamCollection); |
054a69
|
122 |
} |
懒 |
123 |
|
|
124 |
@Override |
|
125 |
public void saveBeachDaParamCollection(List<DaParamCollection> list) { |
|
126 |
// ExecutorType.SIMPLE: 这个执行器类型不做特殊的事情。它为每个语句的执行创建一个新的预处理语句。 |
|
127 |
// ExecutorType.REUSE: 这个执行器类型会复用预处理语句。 |
|
128 |
// ExecutorType.BATCH: 这个执行器会批量执行所有更新语句,如果 SELECT 在它们中间执行还会标定它们是 必须的,来保证一个简单并易于理解的行为。 |
bdb404
|
129 |
logger.info("进入乐工批量方法saveBeachDaParamCollection"); |
054a69
|
130 |
|
懒 |
131 |
// 关闭session的自动提交 |
|
132 |
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); |
|
133 |
try { |
|
134 |
DaParamCollectionMapper userMapper = sqlSession.getMapper(DaParamCollectionMapper.class); |
|
135 |
list.stream().forEach(DaParamCollection -> userMapper.insertDaParamCollection(DaParamCollection)); |
|
136 |
// 提交数据 |
|
137 |
sqlSession.commit(); |
|
138 |
sqlSession.rollback(); |
bdb404
|
139 |
logger.info("结束乐工批量方法saveBeachDaParamCollection"); |
A |
140 |
|
054a69
|
141 |
} catch (Exception e) { |
懒 |
142 |
sqlSession.rollback(); |
|
143 |
} finally { |
|
144 |
sqlSession.close(); |
|
145 |
} |
e57a89
|
146 |
} |
懒 |
147 |
|
|
148 |
/** |
|
149 |
* 新增设备产品过程参数采集 |
|
150 |
* |
|
151 |
* @param daParamCollection 设备产品过程参数采集 |
|
152 |
* @return 结果 |
|
153 |
*/ |
|
154 |
@Override |
|
155 |
public int insertDaParamCollection(DaParamCollection daParamCollection) |
|
156 |
{ |
|
157 |
daParamCollection.setCreateTime(DateUtils.getNowDate()); |
|
158 |
return daParamCollectionMapper.insertDaParamCollection(daParamCollection); |
|
159 |
} |
|
160 |
|
|
161 |
/** |
|
162 |
* 修改设备产品过程参数采集 |
|
163 |
* |
|
164 |
* @param daParamCollection 设备产品过程参数采集 |
|
165 |
* @return 结果 |
|
166 |
*/ |
|
167 |
@Override |
|
168 |
public int updateDaParamCollection(DaParamCollection daParamCollection) |
|
169 |
{ |
|
170 |
daParamCollection.setUpdateTime(DateUtils.getNowDate()); |
|
171 |
return daParamCollectionMapper.updateDaParamCollection(daParamCollection); |
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* 批量删除设备产品过程参数采集 |
|
176 |
* |
|
177 |
* @param ids 需要删除的设备产品过程参数采集主键 |
|
178 |
* @return 结果 |
|
179 |
*/ |
|
180 |
@Override |
|
181 |
public int deleteDaParamCollectionByIds(Long[] ids) |
|
182 |
{ |
|
183 |
return daParamCollectionMapper.deleteDaParamCollectionByIds(ids); |
|
184 |
} |
|
185 |
|
|
186 |
/** |
|
187 |
* 删除设备产品过程参数采集信息 |
|
188 |
* |
|
189 |
* @param id 设备产品过程参数采集主键 |
|
190 |
* @return 结果 |
|
191 |
*/ |
|
192 |
@Override |
|
193 |
public int deleteDaParamCollectionById(Long id) |
|
194 |
{ |
|
195 |
return daParamCollectionMapper.deleteDaParamCollectionById(id); |
|
196 |
} |
b64ed2
|
197 |
|
懒 |
198 |
@Override |
|
199 |
public void addBasicParameters(DaParamCollection daParamCollection) { |
|
200 |
// 假设这是从数据库或其他地方获取的参数数据 |
|
201 |
Map<String, String> map = new HashMap<>(); |
|
202 |
map.put("GC", "南浔工厂"); |
|
203 |
map.put("CXBH", "Pack线"); |
|
204 |
map.put("SBBH", "设备001"); |
|
205 |
map.put("YGBH", "员工001"); |
|
206 |
map.put("GDBH", daParamCollection.getWorkOrderNo()); |
|
207 |
map.put("CPXH", daParamCollection.getModel()); |
|
208 |
map.put("INT", DateUtil.formatDateTime(new Date())); |
|
209 |
|
|
210 |
map.forEach((key, value) -> { |
|
211 |
DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf(); |
|
212 |
daCollectionParamConf.setProcessesCode(daParamCollection.getLocationCode()); |
|
213 |
daCollectionParamConf.setCollectParameterId(key); |
|
214 |
List<DaCollectionParamConf> daCollectionParamConfs = daCollectionParamConfMapper.selectDaCollectionParamConfList(daCollectionParamConf); |
|
215 |
DaParamCollection saveData = new DaParamCollection(); |
|
216 |
saveData.setWorkOrderNo(daParamCollection.getWorkOrderNo()); |
|
217 |
saveData.setProductCode(daParamCollection.getProductCode()); |
|
218 |
saveData.setLocationCode(daParamCollection.getLocationCode()); |
3c2299
|
219 |
saveData.setSfcCode(daParamCollection.getProductBarcode()); |
b64ed2
|
220 |
saveData.setParamCode(daCollectionParamConfs.get(0).getCollectParameterId()); |
懒 |
221 |
saveData.setParamName(daCollectionParamConfs.get(0).getCollectParameterName()); |
|
222 |
saveData.setCollectionTime(new Date()); |
|
223 |
saveData.setParamValue(value); |
|
224 |
daParamCollectionMapper.insertDaParamCollection(saveData); |
|
225 |
}); |
|
226 |
} |
49c784
|
227 |
|
懒 |
228 |
@Override |
|
229 |
public void addTighteningParameters(DaParamCollection daParamCollection) { |
b77c7b
|
230 |
String paramCode = daParamCollection.getParamCode(); |
a60fef
|
231 |
String tightenData = daParamCollection.getTightenTheArray(); |
A |
232 |
if(StringUtils.isNotBlank(paramCode)&&StringUtils.isNotBlank(tightenData)){ |
|
233 |
tightenData = tightenData.replace("[", "").replace("]", "").replace(" ", ""); |
|
234 |
String[] tightenDataParts = tightenData.split(","); |
|
235 |
String[] paramCodeParts = paramCode.split(","); |
|
236 |
for (int i = 0; i < paramCodeParts.length; i++) { |
|
237 |
daParamCollection.setParamValue(tightenDataParts[i]); |
|
238 |
daParamCollection.setParamCode(paramCodeParts[i]); |
|
239 |
daParamCollection.setCollectionTime(new Date()); |
|
240 |
daParamCollection.setSfcCode(daParamCollection.getProductBarcode()); |
|
241 |
daParamCollectionMapper.insertDaParamCollection(daParamCollection); |
8cfe20
|
242 |
|
A |
243 |
DaParamCollectionTemp daParamCollectionTemp = new DaParamCollectionTemp(); |
|
244 |
daParamCollectionTemp.setParamValue(tightenDataParts[i]); |
|
245 |
daParamCollectionTemp.setParamCode(paramCodeParts[i]); |
|
246 |
daParamCollectionTemp.setCollectionTime(new Date()); |
|
247 |
daParamCollectionTemp.setSfcCode(daParamCollection.getProductBarcode()); |
|
248 |
daParamCollectionTemp.setLocationCode(daParamCollection.getLocationCode()); |
d76bba
|
249 |
daParamCollectionTemp.setProductCode(daParamCollection.getProductCode()); |
8cfe20
|
250 |
daParamCollectionTempService.save(daParamCollectionTemp); |
a60fef
|
251 |
} |
b77c7b
|
252 |
} |
49c784
|
253 |
} |
32483a
|
254 |
|
懒 |
255 |
@Override |
|
256 |
public void saveCampaignTimeParameters(DaParamCollection daParamCollection) { |
7bee80
|
257 |
List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>() |
懒 |
258 |
.eq(BsFormulaChildInfo::getProcessesCode, daParamCollection.getLocationCode()) |
|
259 |
.eq(BsFormulaChildInfo::getSpareField4, "1") |
|
260 |
); |
237733
|
261 |
if(StringUtils.isNotBlank(list.get(0).getResults())){ |
A |
262 |
if(!list.get(0).getResults().equals("OK")){ |
|
263 |
try { |
|
264 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+daParamCollection.getLocationCode()+".RecordDataDone").value(22).build()); |
|
265 |
} catch (Exception e) { |
|
266 |
throw new RuntimeException(e); |
|
267 |
} |
|
268 |
return; |
|
269 |
} |
|
270 |
}else { |
7bee80
|
271 |
try { |
懒 |
272 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+daParamCollection.getLocationCode()+".RecordDataDone").value(22).build()); |
|
273 |
} catch (Exception e) { |
|
274 |
throw new RuntimeException(e); |
|
275 |
} |
|
276 |
return; |
|
277 |
} |
32483a
|
278 |
BsFormulaChildInfo bsFormulaChildInfo = new BsFormulaChildInfo(); |
懒 |
279 |
bsFormulaChildInfo.setProcessesCode(daParamCollection.getLocationCode()); |
|
280 |
bsFormulaChildInfo.setProductCode(daParamCollection.getProductCode()); |
|
281 |
bsFormulaChildInfo.setSpareField4("1"); |
|
282 |
List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(bsFormulaChildInfo); |
|
283 |
String result = bsFormulaChildInfos.get(0).getResults(); |
|
284 |
if(result != null && !result.isEmpty()){ |
|
285 |
try { |
|
286 |
//过站参数采集记录出站时间 |
|
287 |
DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf(); |
|
288 |
daCollectionParamConf.setProcessesCode(daParamCollection.getLocationCode()); |
|
289 |
daCollectionParamConf.setCollectParameterId("OUTT"); |
|
290 |
List<DaCollectionParamConf> daCollectionParamConfs = daCollectionParamConfMapper.selectDaCollectionParamConfList(daCollectionParamConf); |
|
291 |
DaParamCollection saveData = new DaParamCollection(); |
|
292 |
saveData.setWorkOrderNo(daParamCollection.getWorkOrderNo()); |
|
293 |
saveData.setProductCode(daParamCollection.getProductCode()); |
|
294 |
saveData.setLocationCode(daParamCollection.getLocationCode()); |
|
295 |
saveData.setSfcCode(daParamCollection.getProductBarcode()); |
|
296 |
saveData.setParamCode(daCollectionParamConfs.get(0).getCollectParameterId()); |
|
297 |
saveData.setParamName(daCollectionParamConfs.get(0).getCollectParameterName()); |
|
298 |
saveData.setCollectionTime(new Date()); |
|
299 |
saveData.setParamValue(DateUtil.formatDateTime(new Date())); |
|
300 |
daParamCollectionMapper.insertDaParamCollection(saveData); |
|
301 |
|
|
302 |
//更新过站记录表出站时间 |
|
303 |
DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection(); |
|
304 |
daPassingStationCollection.setWorkOrderNo(daParamCollection.getWorkOrderNo()); |
1df825
|
305 |
daPassingStationCollection.setLocationCode(daParamCollection.getLocationCode()); |
32483a
|
306 |
List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionMapper.selectDaPassingStationCollectionList(daPassingStationCollection); |
懒 |
307 |
daPassingStationCollections.get(0).setOutboundTime(new Date()); |
|
308 |
int i = daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0)); |
|
309 |
|
8f0f8d
|
310 |
// OPCUaSubscription.SaveParamData(daParamCollection.getProductBarcode(),"OP",daParamCollection.getLocationCode(),daParamCollection.getWorkOrderNo(),daParamCollection.getProductCode()); |
054a69
|
311 |
|
32483a
|
312 |
//给opc发21 |
7bee80
|
313 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+daParamCollection.getLocationCode()+".RecordDataDone").value(21).build()); |
237733
|
314 |
if(daParamCollection.getLocationCode().equals("OP240")){ |
A |
315 |
RestfulService.getWorkReportResultFeedback(daParamCollection.getProductBarcode(),"OP230",format.format(new Date())); |
|
316 |
} |
32483a
|
317 |
} catch (Exception e) { |
懒 |
318 |
throw new RuntimeException(e); |
|
319 |
} |
|
320 |
} |
|
321 |
} |
8f0f8d
|
322 |
|
懒 |
323 |
@Override |
|
324 |
public void insertBatch(List<DaParamCollection> confList){ |
|
325 |
try{ |
|
326 |
this.saveBatch(confList); |
|
327 |
}catch (Exception e){ |
|
328 |
return; |
|
329 |
} |
|
330 |
|
|
331 |
} |
ddb300
|
332 |
|
A |
333 |
@Override |
|
334 |
public void replaceAssemblyCode(DaParamCollection daParamCollection) { |
|
335 |
List<DaParamCollection> list = daParamCollectionService.list(new LambdaQueryWrapper<DaParamCollection>() |
2c7661
|
336 |
.eq(DaParamCollection::getSfcCode, daParamCollection.getYzSfcCode()) |
ddb300
|
337 |
); |
A |
338 |
if(list.size() > 0){ |
|
339 |
for (DaParamCollection paramCollection : list) { |
2c7661
|
340 |
paramCollection.setSfcCode(daParamCollection.getSfcCode()); |
ddb300
|
341 |
daParamCollectionService.saveOrUpdate(paramCollection); |
A |
342 |
} |
|
343 |
} |
|
344 |
|
|
345 |
} |
4a5f2a
|
346 |
|
A |
347 |
@Override |
|
348 |
public void yzAddBasicParameters(DaParamCollection daParamCollection) { |
|
349 |
// 假设这是从数据库或其他地方获取的参数数据 |
|
350 |
Map<String, String> map = new HashMap<>(); |
|
351 |
// map.put("GC", "南浔工厂"); |
|
352 |
// map.put("CXBH", "Pack线"); |
|
353 |
// map.put("SBBH", "设备001"); |
|
354 |
// map.put("YGBH", "员工001"); |
|
355 |
// map.put("GDBH", daParamCollection.getWorkOrderNo()); |
|
356 |
// map.put("CPXH", daParamCollection.getModel()); |
|
357 |
map.put("INT", DateUtil.formatDateTime(new Date())); |
|
358 |
|
|
359 |
map.forEach((key, value) -> { |
|
360 |
DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf(); |
|
361 |
daCollectionParamConf.setProcessesCode(daParamCollection.getLocationCode()); |
|
362 |
daCollectionParamConf.setCollectParameterId(key); |
|
363 |
List<DaCollectionParamConf> daCollectionParamConfs = daCollectionParamConfMapper.selectDaCollectionParamConfList(daCollectionParamConf); |
|
364 |
DaParamCollection saveData = new DaParamCollection(); |
|
365 |
saveData.setWorkOrderNo(daParamCollection.getWorkOrderNo()); |
|
366 |
saveData.setProductCode(daParamCollection.getProductCode()); |
|
367 |
saveData.setLocationCode(daParamCollection.getLocationCode()); |
|
368 |
saveData.setSfcCode(daParamCollection.getProductBarcode()); |
|
369 |
saveData.setParamCode(daCollectionParamConfs.get(0).getCollectParameterId()); |
|
370 |
saveData.setParamName(daCollectionParamConfs.get(0).getCollectParameterName()); |
|
371 |
saveData.setCollectionTime(new Date()); |
|
372 |
saveData.setParamValue(value); |
|
373 |
daParamCollectionMapper.insertDaParamCollection(saveData); |
|
374 |
}); |
|
375 |
} |
1c84ae
|
376 |
|
A |
377 |
@Override |
|
378 |
public void jrmSaveCampaignTimeParameters(DaParamCollection daParamCollection) { |
|
379 |
DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf(); |
|
380 |
daCollectionParamConf.setProcessesCode(daParamCollection.getLocationCode()); |
|
381 |
daCollectionParamConf.setCollectParameterId("OUTT"); |
|
382 |
List<DaCollectionParamConf> daCollectionParamConfs = daCollectionParamConfMapper.selectDaCollectionParamConfList(daCollectionParamConf); |
|
383 |
DaParamCollection saveData = new DaParamCollection(); |
|
384 |
saveData.setWorkOrderNo(daParamCollection.getWorkOrderNo()); |
|
385 |
saveData.setProductCode(daParamCollection.getProductCode()); |
|
386 |
saveData.setLocationCode(daParamCollection.getLocationCode()); |
|
387 |
saveData.setSfcCode(daParamCollection.getProductBarcode()); |
|
388 |
saveData.setParamCode(daCollectionParamConfs.get(0).getCollectParameterId()); |
|
389 |
saveData.setParamName(daCollectionParamConfs.get(0).getCollectParameterName()); |
|
390 |
saveData.setCollectionTime(new Date()); |
|
391 |
saveData.setParamValue(DateUtil.formatDateTime(new Date())); |
|
392 |
daParamCollectionMapper.insertDaParamCollection(saveData); |
|
393 |
|
|
394 |
//更新过站记录表出站时间 |
|
395 |
DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection(); |
|
396 |
daPassingStationCollection.setWorkOrderNo(daParamCollection.getWorkOrderNo()); |
|
397 |
daPassingStationCollection.setLocationCode(daParamCollection.getLocationCode()); |
|
398 |
List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionMapper.selectDaPassingStationCollectionList(daPassingStationCollection); |
|
399 |
daPassingStationCollections.get(0).setOutboundTime(new Date()); |
|
400 |
int i = daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0)); |
|
401 |
|
|
402 |
// OPCUaSubscription.SaveParamData(daParamCollection.getProductBarcode(),"OP",daParamCollection.getLocationCode(),daParamCollection.getWorkOrderNo(),daParamCollection.getProductCode()); |
|
403 |
|
|
404 |
//给opc发21 |
|
405 |
try { |
|
406 |
// miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+daParamCollection.getLocationCode()+".RecordDataDone").value(21).build()); |
1ccd69
|
407 |
String strA = daParamCollection.getLocationCode(); |
1c84ae
|
408 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+strA+".RecordDataDone").value(21).build()); |
A |
409 |
} catch (Exception e) { |
|
410 |
throw new RuntimeException(e); |
|
411 |
} |
|
412 |
} |
6a462f
|
413 |
|
W |
414 |
|
|
415 |
public void sendToFactoryMes(String stationCode,String productNum ){ |
a846f2
|
416 |
// String url = "https://imes-uat-group.geelycv-test.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
A |
417 |
String url = "https://imes-group.geelycv.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
6a462f
|
418 |
ParentVO vo =new ParentVO(); |
W |
419 |
List<ChildVO> checkList = new ArrayList<>(); |
|
420 |
List<DaParamCollection> list = this.list(new LambdaQueryWrapper<DaParamCollection>() |
|
421 |
.eq(DaParamCollection::getSfcCode, productNum) |
|
422 |
.eq(DaParamCollection::getLocationCode, stationCode)); |
|
423 |
vo.setTotalResult("1"); |
|
424 |
String string = new Random(10).toString(); |
|
425 |
vo.setRecordId(string); |
|
426 |
vo.setProductNum(productNum); |
|
427 |
vo.setSiteCode("3983"); |
|
428 |
vo.setStationCode(stationCode); |
|
429 |
if (CollUtil.isNotEmpty(list)){ |
|
430 |
List<DaParamCollection> collect = list.stream().filter(x -> Constants.NG.equals(x.getParamValue())).collect(Collectors.toList()); |
|
431 |
if (CollUtil.isNotEmpty(collect)){ |
|
432 |
vo.setTotalResult("0"); |
|
433 |
} |
|
434 |
List<BsFormulaChildInfo> bsFormulaChildInfoList = bsFormulaChildInfoService.list(); |
|
435 |
for (DaParamCollection daParamCollection : list) { |
|
436 |
ChildVO childVO = new ChildVO(); |
|
437 |
childVO.setItemCode(daParamCollection.getParamCode()); |
|
438 |
String time = daParamCollection.getCollectionTime() != null ? daParamCollection.getCollectionTime().toString() : ""; |
|
439 |
childVO.setCheckResult("1"); |
|
440 |
if (StrUtil.isNotBlank(daParamCollection.getParamValue())){ |
|
441 |
if (Constants.NG.equals(daParamCollection.getParamValue())){ |
|
442 |
childVO.setCheckResult("0"); |
|
443 |
} |
|
444 |
} |
|
445 |
childVO.setCheckTime(time); |
|
446 |
childVO.setItemValue(daParamCollection.getParamValue()); |
|
447 |
childVO.setItemType("3"); |
|
448 |
childVO.setItemText(daParamCollection.getParamName()); |
|
449 |
if (StrUtil.isNotBlank(daParamCollection.getParamCode())){ |
|
450 |
List<BsFormulaChildInfo> collect1 = bsFormulaChildInfoList.stream().filter(x -> daParamCollection.getParamCode().equals(x.getParamCode())).collect(Collectors.toList()); |
|
451 |
if (CollUtil.isNotEmpty(collect1)){ |
|
452 |
BsFormulaChildInfo bsFormulaChildInfo = collect1.get(0); |
|
453 |
childVO.setItemType(bsFormulaChildInfo.getOperationType()); |
|
454 |
} |
|
455 |
} |
|
456 |
|
|
457 |
checkList.add(childVO); |
|
458 |
} |
|
459 |
} |
|
460 |
vo.setCheckList(checkList); |
|
461 |
HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(vo)).execute(); |
|
462 |
|
|
463 |
} |
5966d6
|
464 |
|
A |
465 |
@Override |
|
466 |
public void pushGeelycvMesFeedback(String packID, String stationCode) { |
d76bba
|
467 |
logger.info("进入人工工位推送工厂MES数据方法-pushGeelycvMesFeedback-工位{}-pack码{}",stationCode,packID); |
5966d6
|
468 |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
a846f2
|
469 |
// String url = "https://imes-uat-group.geelycv-test.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
A |
470 |
String url = "https://imes-group.geelycv.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
5966d6
|
471 |
String totalResult = "0"; |
8cfe20
|
472 |
List<DaParamCollectionTemp> paramList = daParamCollectionTempService.list(new LambdaQueryWrapper<DaParamCollectionTemp>().eq(DaParamCollectionTemp::getSfcCode, packID).eq(DaParamCollectionTemp::getLocationCode, stationCode)); |
A |
473 |
if(paramList.size() > 0){ |
|
474 |
ParentVO parentVO = new ParentVO(); |
|
475 |
parentVO.setSiteCode("3983"); |
|
476 |
parentVO.setRecordId(String.valueOf(Instant.now().toEpochMilli())); |
|
477 |
parentVO.setStationCode(stationCode); |
|
478 |
parentVO.setProductNum(packID); |
|
479 |
parentVO.setTotalResult("1"); |
|
480 |
List<ChildVO> listChildVo = new ArrayList<>(); |
|
481 |
|
|
482 |
for (DaParamCollectionTemp daParamCollection : paramList) { |
|
483 |
ChildVO childVO = new ChildVO(); |
|
484 |
childVO.setItemCode(daParamCollection.getParamCode()); |
|
485 |
// BsFormulaChildInfo childOne = bsFormulaChildInfoService.getOne(new LambdaQueryWrapper<BsFormulaChildInfo>().eq(BsFormulaChildInfo::getParamCode, daParamCollection.getParamCode())); |
|
486 |
// DaCollectionParamConf paramConfOne = daCollectionParamConfService.getOne(new LambdaQueryWrapper<DaCollectionParamConf>().eq(DaCollectionParamConf::getCollectParameterId, daParamCollection.getParamCode())); |
|
487 |
List<DaCollectionParamConf> paramConfOneList = daCollectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>().eq(DaCollectionParamConf::getCollectParameterId, daParamCollection.getParamCode())); |
|
488 |
DaCollectionParamConf paramConfOne = paramConfOneList.get(0); |
|
489 |
// if(childOne!=null){ |
|
490 |
// String operationType = childOne.getOperationType(); |
|
491 |
// if(operationType.equals("1")){ |
|
492 |
// childVO.setItemType("2"); |
|
493 |
// }else if(operationType.equals("2")){ |
|
494 |
// childVO.setItemType("1"); |
|
495 |
// } |
|
496 |
// }else { |
|
497 |
// childVO.setItemType("3"); |
|
498 |
// } |
|
499 |
if(paramConfOne!=null){ |
|
500 |
childVO.setItemType(paramConfOne.getSpareField1()); |
|
501 |
childVO.setItemText(paramConfOne.getCollectParameterName()); |
|
502 |
}else { |
|
503 |
childVO.setItemType("3"); |
|
504 |
childVO.setItemText(""); |
|
505 |
} |
|
506 |
childVO.setItemValue(daParamCollection.getParamValue()); |
|
507 |
|
|
508 |
if(daParamCollection.getParamValue().equals("1")){ |
|
509 |
childVO.setCheckResult("1"); |
|
510 |
}else if(daParamCollection.getParamValue().equals("2")){ |
|
511 |
childVO.setCheckResult("0"); |
|
512 |
parentVO.setTotalResult("0"); |
|
513 |
totalResult = "1"; |
|
514 |
}else { |
|
515 |
childVO.setCheckResult("1"); |
|
516 |
} |
|
517 |
childVO.setCheckTime(format.format(daParamCollection.getCollectionTime())); |
|
518 |
listChildVo.add(childVO); |
|
519 |
|
|
520 |
} |
|
521 |
parentVO.setCheckList(listChildVo); |
d76bba
|
522 |
try{ |
A |
523 |
CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
|
524 |
logger.info("开始执行异步方法"); |
|
525 |
HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(parentVO)).execute(); |
|
526 |
logger.info("异步方法执行结束"); |
|
527 |
logger.info("手动工位传工厂MES异步方法{}"+execute.body()); |
|
528 |
List<Long> idsList = paramList.stream().map(DaParamCollectionTemp::getId).collect(Collectors.toList()); |
|
529 |
Long[] array = idsList.toArray(new Long[0]); |
|
530 |
int i = daParamCollectionTempService.deleteDaParamCollectionTempByIds(array); |
|
531 |
logger.info("删除临时表数据条数{}-工位{}-pack码{}",i,stationCode,packID); |
|
532 |
}); |
|
533 |
}catch (Exception e){ |
|
534 |
System.out.println(e.getMessage()); |
|
535 |
} |
|
536 |
// HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(parentVO)).execute(); |
|
537 |
|
|
538 |
// System.out.println(execute.body()); |
8cfe20
|
539 |
System.out.println("-----------------------"+totalResult); |
d76bba
|
540 |
logger.info("结束人工工位推送工厂MES数据方法-pushGeelycvMesFeedback-工位{}-pack码{}",stationCode,packID); |
8cfe20
|
541 |
} |
A |
542 |
|
|
543 |
} |
|
544 |
|
|
545 |
@Override |
|
546 |
public void automaticWorkstationPushGeelycvMesFeedback(String packID, String stationCode,List<DaParamCollection> paramList) { |
bdb404
|
547 |
logger.info("进入工位{}-工厂MES推送数据方法automaticWorkstationPushGeelycvMesFeedback",stationCode); |
8cfe20
|
548 |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
A |
549 |
// String url = "https://imes-uat-group.geelycv-test.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
|
550 |
String url = "https://imes-group.geelycv.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
|
551 |
String totalResult = "0"; |
5966d6
|
552 |
if(paramList.size() > 0){ |
bdb404
|
553 |
logger.info("进入工位{}-拼数据",stationCode); |
5966d6
|
554 |
ParentVO parentVO = new ParentVO(); |
A |
555 |
parentVO.setSiteCode("3983"); |
|
556 |
parentVO.setRecordId(String.valueOf(Instant.now().toEpochMilli())); |
|
557 |
parentVO.setStationCode(stationCode); |
|
558 |
parentVO.setProductNum(packID); |
|
559 |
parentVO.setTotalResult("1"); |
|
560 |
List<ChildVO> listChildVo = new ArrayList<>(); |
|
561 |
|
|
562 |
for (DaParamCollection daParamCollection : paramList) { |
|
563 |
ChildVO childVO = new ChildVO(); |
|
564 |
childVO.setItemCode(daParamCollection.getParamCode()); |
8cfe20
|
565 |
// BsFormulaChildInfo childOne = bsFormulaChildInfoService.getOne(new LambdaQueryWrapper<BsFormulaChildInfo>().eq(BsFormulaChildInfo::getParamCode, daParamCollection.getParamCode())); |
A |
566 |
// DaCollectionParamConf paramConfOne = daCollectionParamConfService.getOne(new LambdaQueryWrapper<DaCollectionParamConf>().eq(DaCollectionParamConf::getCollectParameterId, daParamCollection.getParamCode())); |
|
567 |
List<DaCollectionParamConf> paramConfOneList = daCollectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>().eq(DaCollectionParamConf::getCollectParameterId, daParamCollection.getParamCode())); |
|
568 |
DaCollectionParamConf paramConfOne = paramConfOneList.get(0); |
237733
|
569 |
// if(childOne!=null){ |
A |
570 |
// String operationType = childOne.getOperationType(); |
|
571 |
// if(operationType.equals("1")){ |
|
572 |
// childVO.setItemType("2"); |
|
573 |
// }else if(operationType.equals("2")){ |
|
574 |
// childVO.setItemType("1"); |
|
575 |
// } |
|
576 |
// }else { |
|
577 |
// childVO.setItemType("3"); |
|
578 |
// } |
5966d6
|
579 |
if(paramConfOne!=null){ |
237733
|
580 |
childVO.setItemType(paramConfOne.getSpareField1()); |
5966d6
|
581 |
childVO.setItemText(paramConfOne.getCollectParameterName()); |
A |
582 |
}else { |
237733
|
583 |
childVO.setItemType("3"); |
5966d6
|
584 |
childVO.setItemText(""); |
A |
585 |
} |
|
586 |
childVO.setItemValue(daParamCollection.getParamValue()); |
|
587 |
|
|
588 |
if(daParamCollection.getParamValue().equals("1")){ |
|
589 |
childVO.setCheckResult("1"); |
|
590 |
}else if(daParamCollection.getParamValue().equals("2")){ |
|
591 |
childVO.setCheckResult("0"); |
|
592 |
parentVO.setTotalResult("0"); |
|
593 |
totalResult = "1"; |
|
594 |
}else { |
|
595 |
childVO.setCheckResult("1"); |
|
596 |
} |
|
597 |
childVO.setCheckTime(format.format(daParamCollection.getCollectionTime())); |
|
598 |
listChildVo.add(childVO); |
|
599 |
} |
|
600 |
parentVO.setCheckList(listChildVo); |
bdb404
|
601 |
logger.info("结束工位{}-拼数据",stationCode); |
A |
602 |
logger.info("进入工位{}-工厂MES推送数据方法HttpResponseSend",stationCode); |
d76bba
|
603 |
try{ |
A |
604 |
CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
|
605 |
logger.info("开始执行异步方法"); |
|
606 |
HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(parentVO)).execute(); |
|
607 |
System.out.println(execute.body()); |
|
608 |
logger.info("异步方法执行结束"); |
|
609 |
logger.info("自动工位传工厂MES异步方法{}"+execute.body()); |
|
610 |
}); |
|
611 |
}catch (Exception e){ |
|
612 |
System.out.println(e.getMessage()); |
|
613 |
} |
|
614 |
// HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(parentVO)).execute(); |
bdb404
|
615 |
logger.info("结束工位{}-工厂MES推送数据方法HttpResponseSend",stationCode); |
5966d6
|
616 |
System.out.println("-----------------------"+totalResult); |
A |
617 |
} |
bdb404
|
618 |
logger.info("结束工位{}-工厂MES推送数据方法automaticWorkstationPushGeelycvMesFeedback",stationCode); |
5966d6
|
619 |
} |
616f98
|
620 |
|
237733
|
621 |
@Override |
A |
622 |
public AjaxResult checkRecordDataDone(DaParamCollection daParamCollection) { |
|
623 |
String result = ""; |
8cfe20
|
624 |
|
A |
625 |
|
237733
|
626 |
try { |
8cfe20
|
627 |
List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>().eq(BsFormulaChildInfo::getSpareField4, "1").eq(BsFormulaChildInfo::getProcessesCode, daParamCollection.getLocationCode())); |
A |
628 |
if(list.size()>0){ |
|
629 |
String results = list.get(0).getResults(); |
|
630 |
if(results!= null && !results.equals("") && results.equals("OK")){ |
|
631 |
result = "21"; |
|
632 |
} |
|
633 |
} |
|
634 |
/*Object recordDataDone = miloService.readFromOpcUa("PACK" + "." + daParamCollection.getLocationCode() + ".RecordDataDone").getValue(); |
237733
|
635 |
if(ObjectUtil.isNotNull(recordDataDone)){ |
A |
636 |
result = recordDataDone.toString(); |
8cfe20
|
637 |
}*/ |
237733
|
638 |
} catch (Exception e) { |
A |
639 |
throw new RuntimeException(e); |
|
640 |
} |
|
641 |
return AjaxResult.success(result); |
|
642 |
} |
|
643 |
|
8cfe20
|
644 |
@Override |
A |
645 |
public void enterWeighing(DaParamCollection daParamCollection) { |
|
646 |
String url = "https://imes-group.geelycv.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
|
647 |
long timestampMillis = Instant.now().toEpochMilli(); |
|
648 |
ParentVO parentVO = new ParentVO(); |
|
649 |
ChildVO childVO = new ChildVO(); |
|
650 |
List<ChildVO> childVOList = new ArrayList<>(); |
|
651 |
childVO.setItemCode("PWD_PW"); |
|
652 |
childVO.setItemType("3"); |
|
653 |
childVO.setItemText("Pack重量值"); |
|
654 |
childVO.setItemValue(daParamCollection.getWeightValue()); |
|
655 |
childVO.setCheckTime(format.format(new Date())); |
|
656 |
childVO.setCheckResult("1"); |
|
657 |
childVOList.add(childVO); |
|
658 |
parentVO.setSiteCode("3983"); |
|
659 |
parentVO.setRecordId(""+timestampMillis); |
|
660 |
parentVO.setStationCode("OP500"); |
|
661 |
parentVO.setProductNum(daParamCollection.getSfcCode()); |
|
662 |
parentVO.setTotalResult("1"); |
|
663 |
parentVO.setCheckList(childVOList); |
|
664 |
HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(parentVO)).execute(); |
d76bba
|
665 |
// try{ |
A |
666 |
// CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
|
667 |
// logger.info("开始执行异步方法"); |
|
668 |
// HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(parentVO)).execute(); |
|
669 |
// System.out.println(execute.body()); |
|
670 |
// logger.info("异步方法执行结束"); |
|
671 |
// logger.info("称重异步方法{}",execute.body()); |
|
672 |
// }); |
|
673 |
// }catch (Exception e){ |
|
674 |
// System.out.println(e.getMessage()); |
|
675 |
// } |
8cfe20
|
676 |
RestfulService.getWorkReportResultFeedback(daParamCollection.getSfcCode(),"OP500",format.format(new Date())); |
A |
677 |
} |
|
678 |
|
e57a89
|
679 |
} |