From 29a77ad7df86fbde3e618dd1040ceee00c99772c Mon Sep 17 00:00:00 2001 From: yxw Date: Mon, 23 Oct 2023 09:53:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E7=BA=BF=E5=B7=A5=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../busi/step/jx/SxPlcOutStepService.java | 43 ++++++++++++++++------ 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/step/jx/SxPlcOutStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/step/jx/SxPlcOutStepService.java index e9dd185..18f99d0 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/step/jx/SxPlcOutStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/step/jx/SxPlcOutStepService.java @@ -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}); + } + }