|
|
|
@ -92,9 +92,12 @@ public class JxSnProcessingCollectProductDataStepService extends BaseStepService
|
|
|
|
|
|
|
|
|
|
String[] plcCodeArr = checkPlcCodeIsValid(reqBean, resultBean, plcCodes, key);
|
|
|
|
|
|
|
|
|
|
List<String> plcCodeList = doHandlePlcCodeList(reqBean, resultBean, key);
|
|
|
|
|
String plcCodeListStr = plcExtService.getCachedData(key, MesPcnExtConstWords.PLC_CODE_UC);
|
|
|
|
|
List<String> plcCodeList = !StringUtils.isEmpty(plcCodeListStr) ? JSONObject.parseArray(plcCodeListStr, String.class) : doHandlePlcCodeList(reqBean, resultBean, key);
|
|
|
|
|
|
|
|
|
|
checkObjectCfgIsValid(reqBean, resultBean, plcCodeList, key);
|
|
|
|
|
List<String> plcCodeList2Cfg = checkObjectCfgIsValid(reqBean, resultBean, plcCodeList, key);
|
|
|
|
|
|
|
|
|
|
doHandlePlcCodeList(reqBean, key, plcCodeListStr, plcCodeList, plcCodeList2Cfg);
|
|
|
|
|
|
|
|
|
|
String curExecWorkOrderNo = getCurExecWorkOrderNo(reqBean, resultBean);
|
|
|
|
|
|
|
|
|
@ -128,22 +131,19 @@ public class JxSnProcessingCollectProductDataStepService extends BaseStepService
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<String> doHandlePlcCodeList(StationRequestBean reqBean, StationResultBean resultBean, String key) {
|
|
|
|
|
String value = plcExtService.getCachedData(key, MesPcnExtConstWords.PLC_CODE_UC);
|
|
|
|
|
if (!StringUtils.isEmpty(value)) return JSONObject.parseArray(value, String.class);
|
|
|
|
|
|
|
|
|
|
List<MesPlc> plcList = plcExtService.getPlcDbList(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode());
|
|
|
|
|
plcList = CollectionUtils.isEmpty(plcList) ? null : plcList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getObjectCode()) && !StringUtils.isEmpty(o.getChannel()) && !StringUtils.isEmpty(o.getDevice()) && !StringUtils.isEmpty(o.getTagAddress()))).collect(Collectors.toList());
|
|
|
|
|
plcList = CollectionUtils.isEmpty(plcList) ? null : plcList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getChannel()) && !StringUtils.isEmpty(o.getDevice()) && !StringUtils.isEmpty(o.getTagAddress()))).collect(Collectors.toList());
|
|
|
|
|
if (CollectionUtils.isEmpty(plcList)) execExpSendMsgAndThrowEx(reqBean, resultBean, String.format("生产线[%s]工位[%s]未配置有效的数据位PLC信息!", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode()));
|
|
|
|
|
|
|
|
|
|
plcList.forEach(o -> plcExtService.doCacheData(reqBean.getOrganizeCode(), key, o.getPlcCode(), JSONObject.toJSONString(o)));
|
|
|
|
|
return plcList.stream().filter(o -> null != o).map(MesPlc::getPlcCode).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<String> plcCodeList = plcList.stream().filter(o -> null != o).map(MesPlc::getPlcCode).collect(Collectors.toList());
|
|
|
|
|
plcExtService.doCacheData(reqBean.getOrganizeCode(), key, MesPcnExtConstWords.PLC_CODE_UC, JSONObject.toJSONString(plcCodeList));
|
|
|
|
|
|
|
|
|
|
return plcCodeList;
|
|
|
|
|
private void doHandlePlcCodeList(StationRequestBean reqBean, String key, String plcCodeListStr, List<String> plcCodeList, List<String> plcCodeList2Cfg) {
|
|
|
|
|
if (!StringUtils.isEmpty(plcCodeListStr) && (plcCodeList.containsAll(plcCodeList2Cfg) && plcCodeList2Cfg.containsAll(plcCodeList))) return;
|
|
|
|
|
plcExtService.doCacheData(reqBean.getOrganizeCode(), key, MesPcnExtConstWords.PLC_CODE_UC, JSONObject.toJSONString(plcCodeList2Cfg));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void checkObjectCfgIsValid(StationRequestBean reqBean, StationResultBean resultBean, List<String> plcCodeList, String key) {
|
|
|
|
|
private List<String> checkObjectCfgIsValid(StationRequestBean reqBean, StationResultBean resultBean, List<String> plcCodeList, String key) {
|
|
|
|
|
String value = plcExtService.getCachedData(key, MesPcnExtConstWords.OBJECT_CODE_UC);
|
|
|
|
|
List<MesObjectCfg> objectCfgList = !StringUtils.isEmpty(value) ? JSONObject.parseArray(value, MesObjectCfg.class) : getObjectCfgDbList(reqBean, resultBean, plcCodeList);
|
|
|
|
|
|
|
|
|
@ -151,9 +151,11 @@ public class JxSnProcessingCollectProductDataStepService extends BaseStepService
|
|
|
|
|
plcCodeList2ObjectCfg = CollectionUtils.isEmpty(plcCodeList2ObjectCfg) ? null : plcCodeList2ObjectCfg.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(plcCodeList2ObjectCfg)) execExpSendMsgAndThrowEx(reqBean, resultBean, String.format("生产线[%s]工位[%s]配置的数据位PLC信息未关联有效的对象结构信息!", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode()));
|
|
|
|
|
if (plcCodeList2ObjectCfg.size() != plcCodeList.size()) execExpSendMsgAndThrowEx(reqBean, resultBean, String.format("生产线[%s]工位[%s]配置的部分数据位PLC信息未关联有效的对象结构信息!", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode()));
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(value)) plcExtService.doCacheData(reqBean.getOrganizeCode(), key, MesPcnExtConstWords.OBJECT_CODE_UC, JSONObject.toJSONString(objectCfgList));
|
|
|
|
|
|
|
|
|
|
List<String> plcCodeList2Cfg = objectCfgList.stream().filter(o -> null != o).map(MesObjectCfg::getPlcCode).collect(Collectors.toList());
|
|
|
|
|
return plcCodeList2Cfg.stream().filter(o -> null != o).distinct().collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<MesObjectCfg> getObjectCfgDbList(StationRequestBean reqBean, StationResultBean resultBean, List<String> plcCodeList) {
|
|
|
|
|