diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesEquipmentProductionResultService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesEquipmentProductionResultService.java new file mode 100644 index 0000000..c00d8e0 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesEquipmentProductionResultService.java @@ -0,0 +1,7 @@ +package cn.estsh.i3plus.ext.mes.pcn.api.busi; + +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesAutoLineInterfaceModel; + +public interface IMesEquipmentProductionResultService { + void doCreateEquipmentProductionResult(MesAutoLineInterfaceModel info); +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/config/WebServiceConfig.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/config/WebServiceConfig.java index 4f9f813..11e9ed1 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/config/WebServiceConfig.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/config/WebServiceConfig.java @@ -21,6 +21,7 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.config; import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.webservice.DcsForEquipmentServer; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.webservice.WebServiceServerAutoLineInterface; import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.webservice.WebServiceServerSPS; import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.webservice.WebServiceServerSPS200; import org.apache.cxf.Bus; @@ -72,4 +73,11 @@ public class WebServiceConfig { endpoint.publish("/mes-service-spsEqu200"); return endpoint; } + + @Bean + public Endpoint endpointAutoLineInterface() { + EndpointImpl endpoint = new EndpointImpl(bus, new WebServiceServerAutoLineInterface()); + endpoint.publish("/mes-service-autoLineInterface"); + return endpoint; + } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesEquipmentProductionResultServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesEquipmentProductionResultServiceImpl.java new file mode 100644 index 0000000..d63de98 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesEquipmentProductionResultServiceImpl.java @@ -0,0 +1,88 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi; + +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipmentProductionResultService; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesAutoLineInterfaceDetailModel; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesAutoLineInterfaceModel; +import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; +import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IShippingDispatchService; +import cn.estsh.i3plus.platform.common.convert.ConvertBean; +import cn.estsh.i3plus.platform.common.util.MesPcnConstWords; +import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; +import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil; +import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; +import cn.estsh.i3plus.pojo.mes.bean.MesConfig; +import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentProductionResult; +import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentProductionResultDetail; +import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; +import cn.estsh.i3plus.pojo.mes.repository.MesConfigRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentProductionResultDetailRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentProductionResultRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +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; + +@Service +public class MesEquipmentProductionResultServiceImpl implements IMesEquipmentProductionResultService { + public static final Logger log = LoggerFactory.getLogger(MesEquipmentProductionResultServiceImpl.class); + + @Autowired + private IShippingDispatchService shippingDispatchService; + @Autowired + private MesConfigRepository configRao; + @Autowired + private MesEquipmentProductionResultRepository resultRDao; + @Autowired + private MesEquipmentProductionResultDetailRepository resultDetailRDao; + + @Override + public void doCreateEquipmentProductionResult(MesAutoLineInterfaceModel info) { + String organizeCode = ""; + DdlPackBean packBean = DdlPackBean.getDdlPackBean(); + DdlPreparedPack.getStringEqualPack(MesPcnExtConstWords.CHANG_SHU_AUTO_LINE_INTERFACE,"cfgCode",packBean); + List configList = configRao.findByHqlWhere(packBean); + for (MesConfig mesConfig : configList) { + if (mesConfig.getCfgKey().equals(MesPcnExtConstWords.CHANG_SHU_ORGANIZE_CODE)){ + organizeCode = mesConfig.getCfgValue(); + } + } + if (StringUtils.isEmpty(organizeCode)) { + log.error("没有配置表mes_config,cfg_code为CHANG_SHU_AUTO_LINE_INTERFACE,key为CHANG_SHU_ORGANIZE_CODE没有配置"); + return; + } + StationRequestBean reqBean = new StationRequestBean(organizeCode, info.getWorkCenterCode(), info.getWorkCellCode(), "webservices"); + reqBean.setBusiType(MesPcnEnumUtil.ACTOR_RECEIVE_STRATEGY.WS_CMD_DO_SCAN.getCode()); + reqBean.setInterfaceType(MesPcnConstWords.SHIPPING); + reqBean.setScanInfo(info.getProductSn()); + shippingDispatchService.sendScanQueueNextExec(reqBean); + + MesEquipmentProductionResult result = new MesEquipmentProductionResult(); + result.setOrganizeCode(organizeCode); + result.setWorkCenterCode(info.getWorkCenterCode()); + result.setWorkCellCode(info.getWorkCellCode()); + result.setProductSn(info.getProductSn()); + result.setQty(info.getQty()); + result.setResult(info.getResult()); + ConvertBean.serviceModelInitialize(result, "webservices"); + resultRDao.insert(result); + + if (!CollectionUtils.isEmpty(info.getDetails())) { + for (MesAutoLineInterfaceDetailModel detailModel : info.getDetails()) { + MesEquipmentProductionResultDetail detail = new MesEquipmentProductionResultDetail(); + detail.setOrganizeCode(organizeCode); + detail.setResultId(result.getId()); + detail.setBarCode(detailModel.getBarCode()); + detail.setWorkCellCode(detailModel.getWorkCellCode()); + detail.setType(detailModel.getType()); + detail.setParamName(detailModel.getParamName()); + detail.setParamValue(detailModel.getParamValue()); + ConvertBean.serviceModelInitialize(detail, "webservices"); + resultDetailRDao.insert(detail); + } + } + } +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesEquipmentLProductionResultStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesEquipmentLProductionResultStepService.java new file mode 100644 index 0000000..9ca8c90 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesEquipmentLProductionResultStepService.java @@ -0,0 +1,45 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step; + +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService; +import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext; +import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService; +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 lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @Description : 自动化线接口获取生产数据 + * @Author : jason.niu + **/ +@Slf4j +@Service("mesEquipmentLProductionResultStepService") +public class MesEquipmentLProductionResultStepService extends BaseStepService { + @Autowired + private IMesProductionProcessContextStepService productionProcessContextStepService; + + @Autowired + private IMesProductionDispatchContextStepService productionDispatchContextStepService; + + @Override + public StepResult execute(StationRequestBean reqBean) { + + StationResultBean resultBean = new StationResultBean(); + + StepResult stepResult = StepResult.getSuccessComplete(); + final String organizeCode = reqBean.getOrganizeCode(); + + //获取工位当前设备信息 + MesProductionProcessContext productionProcessContext = productionProcessContextStepService.dispatchCurCellEquipment(reqBean); + + //配置错误 抛出异常 + if (!productionProcessContext.getSuccess()) { + stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage()); + } + + return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "收集自动化线生产结果成功!"); + } +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesStationFeedContainerPackageDetailStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesStationFeedContainerPackageDetailStepService.java index c087eb7..0558272 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesStationFeedContainerPackageDetailStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesStationFeedContainerPackageDetailStepService.java @@ -70,6 +70,8 @@ public class MesStationFeedContainerPackageDetailStepService extends BaseStepSer stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage()); } + // 扫描内容去除前后空格并且转为大写。 + reqBean.trimScanInfo(); //扫描信息置空 String barcode = reqBean.resetScanInfo(reqBean.getScanInfo()); if (StringUtils.isEmpty(barcode)) stepSendGuideAndThrowEx(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), "请扫描原料条码!"); @@ -134,7 +136,7 @@ public class MesStationFeedContainerPackageDetailStepService extends BaseStepSer return false; } String closeSn = config.getCfgValue(); - if (StringUtils.isEmpty(closeSn) || !Objects.equals(closeSn, barcode)) { + if (StringUtils.isEmpty(closeSn) || !Objects.equals(closeSn.toUpperCase(), barcode)) { return false; } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/webservice/WebServiceServerAutoLineInterface.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/webservice/WebServiceServerAutoLineInterface.java new file mode 100644 index 0000000..ed35bbb --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/webservice/WebServiceServerAutoLineInterface.java @@ -0,0 +1,22 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.webservice; + +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipmentProductionResultService; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesAutoLineInterfaceModel; +import cn.estsh.impp.framework.boot.util.SpringContextsUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; + +@WebService(targetNamespace = "http://tempuri.org/services/SyncSPSForEquipmentService") +public class WebServiceServerAutoLineInterface { + public static final Logger log = LoggerFactory.getLogger(WebServiceServerAutoLineInterface.class); + + @WebMethod(action = "sendMessage", operationName = "sendMessage") + public void sendMessage(@WebParam(name = "info") MesAutoLineInterfaceModel info) { + IMesEquipmentProductionResultService service = SpringContextsUtil.getBean(IMesEquipmentProductionResultService.class); + service.doCreateEquipmentProductionResult(info); + } +} diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesAutoLineInterfaceDetailModel.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesAutoLineInterfaceDetailModel.java new file mode 100644 index 0000000..e9ca13b --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesAutoLineInterfaceDetailModel.java @@ -0,0 +1,74 @@ +package cn.estsh.i3plus.ext.mes.pcn.pojo.model; + +import io.swagger.annotations.ApiParam; + +import javax.xml.bind.annotation.XmlElement; + +/** + * @author jason + */ +//@Getter +//@Setter +//@NoArgsConstructor // 显式生成无参构造函数(关键) +//@AllArgsConstructor // 同时保留带参构造函数 +public class MesAutoLineInterfaceDetailModel { + @ApiParam("类型") + private Integer type; + + @ApiParam(value = "工位代码") + private String workCellCode; + + @ApiParam(value = "条码") + private String barCode; + + @ApiParam(value = "参数值") + private String paramValue; + + @ApiParam(value = "参数名") + private String paramName; + + @XmlElement(name = "Type") + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + @XmlElement(name = "Location") + public String getWorkCellCode() { + return workCellCode; + } + + public void setWorkCellCode(String workCellCode) { + this.workCellCode = workCellCode; + } + + @XmlElement(name = "Barcode") + public String getBarCode() { + return barCode; + } + + public void setBarCode(String barCode) { + this.barCode = barCode; + } + + @XmlElement(name = "ParamValue") + public String getParamValue() { + return paramValue; + } + + public void setParamValue(String paramValue) { + this.paramValue = paramValue; + } + + @XmlElement(name = "ParamName") + public String getParamName() { + return paramName; + } + + public void setParamName(String paramName) { + this.paramName = paramName; + } +} diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesAutoLineInterfaceModel.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesAutoLineInterfaceModel.java new file mode 100644 index 0000000..645b6b5 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesAutoLineInterfaceModel.java @@ -0,0 +1,90 @@ +package cn.estsh.i3plus.ext.mes.pcn.pojo.model; + +import io.swagger.annotations.ApiParam; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; + +// 必须添加 @XmlRootElement,指定 XML 根节点名称 +//@XmlRootElement(name = "info") +public class MesAutoLineInterfaceModel { + + public MesAutoLineInterfaceModel() { + + } + + @ApiParam("生产线代码") + private String workCenterCode; + + @ApiParam(value = "工位代码") + private String workCellCode; + + @ApiParam("零件条码") + private String productSn; + + @ApiParam(value = "数量") + private Double qty; + + @ApiParam("结果") + private Integer result; + + private ArrayList details = new ArrayList<>(); + + + @XmlElement(name = "AssemblyLine") + public String getWorkCenterCode() { + return workCenterCode; + } + + public void setWorkCenterCode(String workCenterCode) { + this.workCenterCode = workCenterCode; + } + + @XmlElement(name = "Location") + public String getWorkCellCode() { + return workCellCode; + } + + public void setWorkCellCode(String workCellCode) { + this.workCellCode = workCellCode; + } + + @XmlElement(name = "Barcode") + public String getProductSn() { + return productSn; + } + + public void setProductSn(String productSn) { + this.productSn = productSn; + } + + @XmlElement(name = "Qty") + public Double getQty() { + return qty; + } + + public void setQty(Double qty) { + this.qty = qty; + } + + @XmlElement(name = "Result") + public Integer getResult() { + return result; + } + + public void setResult(Integer result) { + this.result = result; + } + + @XmlElementWrapper(name = "SubParams") // 包装集合的父节点 + @XmlElement(name = "SubParam") // 集合中每个元素的节点名称 + public ArrayList getDetails() { + return details; + } + + public void setDetails(ArrayList details) { + this.details = details; + } +} diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java index ffe29ac..712978a 100644 --- a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java @@ -965,4 +965,7 @@ public class MesPcnExtConstWords { public static final String VOLVO_SEQUENCENUMBER = "sequenceNumber"; public static final String VOLVO_RACKID = "rackId"; public static final String VOLVO_POSITION = "position"; + //常熟自动化线接口工厂代码配置 + public static final String CHANG_SHU_AUTO_LINE_INTERFACE ="CHANG_SHU_AUTO_LINE_INTERFACE"; + public static final String CHANG_SHU_ORGANIZE_CODE ="CHANG_SHU_ORGANIZE_CODE"; }