|
|
|
@ -1,30 +1,27 @@
|
|
|
|
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.step.jx;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.station.SxPutPalletModuleService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.station.jx.SxNoumenonSnPopUpOnlineModuleService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.step.SxPutPalletInitProdTypeStepService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.SxPutPalletModuleModel;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.SxPutPalletPlcDataModel;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.actor.shipping.dispatch.IFsmCommonService;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.IStepCommonMethodService;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.base.BaseStepService;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.util.LocaleUtil;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.platform.plugin.opc.iservice.IOpcUAService;
|
|
|
|
|
import cn.estsh.i3plus.platform.plugin.opc.service.OpcUAService;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.hardswitch.bean.OpcUAParam;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesPlc;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProdRouteOptParam;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesPlcRepository;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.text.MessageFormat;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -45,6 +42,9 @@ public class SxPlcOutStepService extends BaseStepService {
|
|
|
|
|
private IFsmCommonService fsmCommonService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesPlcRepository plcRepository;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private SxNoumenonSnPopUpOnlineModuleService snPopUpOnlineModuleService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -69,12 +69,12 @@ public class SxPlcOutStepService extends BaseStepService {
|
|
|
|
|
if (StringUtils.isEmpty(plcCode)) {
|
|
|
|
|
return execNonCompleteAndSendMsgReturn(reqBean, resultBean, stepResult, "当前工位未维护PLC代码");
|
|
|
|
|
}
|
|
|
|
|
MesPlc plc = snPopUpOnlineModuleService.getPlc(reqBean.getOrganizeCode(), plcCode);
|
|
|
|
|
MesPlc plc = getPlc(reqBean.getOrganizeCode(), plcCode);
|
|
|
|
|
if (plc == null) {
|
|
|
|
|
return execNonCompleteAndSendMsgReturn(reqBean, resultBean, stepResult, String.format("PLC代码[%s]不存在", plcCode));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Boolean writeResult = snPopUpOnlineModuleService.doWriteOpcParamValue(plc, plcOutData);
|
|
|
|
|
Boolean writeResult = doWriteOpcParamValue(plc, plcOutData);
|
|
|
|
|
|
|
|
|
|
log.info("SxPlcOutStepService --- 放行结果:{} ", writeResult);
|
|
|
|
|
|
|
|
|
@ -82,4 +82,25 @@ public class SxPlcOutStepService extends BaseStepService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Boolean doWriteOpcParamValue(MesPlc plc, String value) {
|
|
|
|
|
IOpcUAService opcService = new OpcUAService();
|
|
|
|
|
String tagAddress = MessageFormat.format("{0}.{1}.{2}", plc.getChannel(), plc.getDevice(), plc.getTagAddress());
|
|
|
|
|
OpcUAParam opcParam = new OpcUAParam();
|
|
|
|
|
opcParam.setServerUrl(plc.getOpcUrl());
|
|
|
|
|
opcParam.setTagAddress(tagAddress);
|
|
|
|
|
opcParam.setNamespaceIndex(plc.getNameSpaceIndex());
|
|
|
|
|
opcParam.setTagValueType(plc.getDataType());
|
|
|
|
|
opcParam.setTagValue(value);
|
|
|
|
|
Boolean result = opcService.editOpcParamValue(opcParam);
|
|
|
|
|
opcService.disConnection();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MesPlc getPlc(String organizeCode, String plcCode) {
|
|
|
|
|
|
|
|
|
|
return plcRepository.getByProperty(
|
|
|
|
|
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.PLC_CODE},
|
|
|
|
|
new Object[]{organizeCode, CommonEnumUtil.IS_VAILD.VAILD.getValue(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), plcCode});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|