阿里云工业互联网企业级平台(数字化工厂)通过统一系统平台、统一门户入口、统一权限管理和统一的数据模型来集成制造企业从产品研发、生产、销售、物流到售后整个价值链过程中需要的所有应用。依据数字工厂的集成指南进行改造的工业应用,就能实现整合到数字工厂中,为企业用户提供业务服务。
集成开发
阿里云工业互联网企业级平台(数字化工厂)通过统一系统平台、统一门户入口、统一权限管理和统一的数据模型来集成制造企业从产品研发、生产、销售、物流到售后整个价值链过程中需要的所有应用。依据数字工厂的集成指南进行改造的工业应用,就能实现整合到数字工厂中,为企业用户提供业务服务。
集成到数字工厂的工业应用是指使用阿里云物联网应用托管服务,能够快速部署和分发的面向制造业务场景的多租户的应用,应用分类的定义请参看应用分类参考。完成物联网应用托管的工业应用,再根据集成工作概述中定义不同应用类型免登方式与数字工厂进行集成。
在集成工作概述中定义了应用类型以及介绍了不同的应用类型的免登方式,以及数据变更通知订阅的基本数据获取方式。
注:集成中所有的接口都需要获得授权,获取授权需要在应用托管的应用配置中进行权限声明,声明了权限声明后客户购买后将授权应用使用该接口,否则调用接口将返回请求被禁止的(错误代码:403)错误。
- 交互框架集成:交互框架集成是指工业应用需要集成到数字工厂统一的门户中,需要通过完成以下几步,来实现统一交互:
为保证工业应用的交互统一,组件层要求使用阿里云提供的标准组件库(基于可视化企业级中后台UI的解决方案 Fusion Design)和相关的视觉规范。前端工具链和数据层建议使用UmiJs,如果是Node应用,建议使用Egg。
- 基础数据集成:工业应用能直接使用数字工厂提供的主数据、工厂模型、工艺路径和库存地点,实现多应用的标准统一的基础数据来进行业务服务数据的交互:
- 应用服务集成:工业应用可以集成数字工厂提供的服务,最终为数字工厂用户提供完整的业务功能,服务包括以下几类:
- 业务数据集成:数字工厂提供以下标准经营分析功能,工业应用通过以下工业服务接口上报业务数据,用户可以直接通过经营驾驶舱查看对应经营分析结果:
应用需要授权才能获得调用数字工厂提供的工业服务权限,权限的申请查看应用授权。
调试和验证
完成以上集成工作的开发后,可以申请数字工厂账号,然后通过应用部署来调试和验证集成后的效果;
- 应用JVM的CPU、磁盘、内存、网卡吞吐、线程池、GC情况
- 前端页面访问情况
- 免登接口心跳
需要使用数字工厂开放的SDK,Git库代码http://gitlab.alibaba-inc.com/iotx-industry/iotx-industry-alimonitor-client
第一步,在启动类中加上 @ServletComponentScan(basePackages={"com.aliyun.iotx.industry.alimonitor.jmonitor.websuppert.items"})
/**
* @ServletComponentScan 自动扫描我们SpringBoot项目内的有关Servlet配置,自动装配到我们的项目中。
*/
@ServletComponentScan(basePackages={"com.aliyun.iotx.industry.alimonitor.jmonitor.websuppert.items"})
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
参数名称 | 是否必选 | 介绍 |
---|---|---|
Jmonitor_OMP_AppKey | 是 | 调用工业服务接口所使用的appKey |
Jmonitor_OMP_AppSecret | 是 | 调用工业服务接口所使用的appSecret |
Jmonitor_OMP_Host | 是 | 调用工业服务接口所使用的endpoint地址,线上环境是 api.link.aliyun.com |
Jmonitor_Collect_Period | 否 | 配置采集周期,单位秒,默认是60秒,配置该参数需要大于60秒 |
Jmonitor_Instance_Id | 否 | 对于实例分发类型的应用,需要传instanceId用来区别应用实例 |
package com.aliyun.iotx;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
/**
* @author zhengxiang.zzx
* @version Id:WebContextConfiguration, v0.1 2020年06月23日 6:01 下午 zhengxiang.zzx Exp $
*/
@Configuration
public class WebContextConfiguration {
@Value("${api.gateway.appkey:}")
protected String appKey;
@Value("${api.gateway.appsecret:}")
protected String appSecret;
@Value("${api.gateway.host:}")
private String iotGatewayHost;
@Value("${api.gateway.stage:}")
private String iotGatewayStage;
public final static String JMONITOR_OMP_APPKEY = "Jmonitor_OMP_AppKey";
public final static String JMONITOR_OMP_APPSECRET = "Jmonitor_OMP_AppSecret";
public final static String JMONITOR_OMP_HOST = "Jmonitor_OMP_Host";
public final static String JMONITOR_OMP_STAGE = "Jmonitor_OMP_Stage";
public final static String JMONITOR_COLLECT_PERIOD = "Jmonitor_Collect_Period";
public final static String JMONITOR_INSTANCE_ID = "Jmonitor_Instance_Id";
@Autowired
private Environment env;
@Bean
public ServletContextInitializer servletContextInitializer() {
return new ServletContextInitializer() {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
// 优先使用环境变量传入的参数
String key = env.getProperty("iot.hosting.appKey", appKey);
String secret = env.getProperty("iot.hosting.appSecret", appSecret);
String host = env.getProperty("iot.hosting.api.domain", iotGatewayHost);
String stage = env.getProperty("api.gateway.stage", iotGatewayStage);
servletContext.setInitParameter(JMONITOR_OMP_APPKEY, key);
servletContext.setInitParameter(JMONITOR_OMP_APPSECRET, secret);
servletContext.setInitParameter(JMONITOR_OMP_HOST, host);
servletContext.setInitParameter(JMONITOR_OMP_STAGE, stage);
// 采集周期 60 秒
servletContext.setInitParameter(JMONITOR_COLLECT_PERIOD, "60");
// test
servletContext.setInitParameter(JMONITOR_INSTANCE_ID, "Rock-PC");
}
};
}
}
第三步,设置依赖,在module目录新建一个libs目录,把iotx-industry-alimonitor-client-1.0.0.jar放入该目录在该module的pom.xml中增加如下dependency:
<!-- 在dependencies中添加dependency -->
<dependencies>
<dependency>
<groupId>com.aliyun.iotx</groupId>
<artifactId>iotx-industry-alimonitor-client</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${pom.basedir}/libs/iotx-industry-alimonitor-client-1.0.0.jar</systemPath>
</dependency>
</dependencies>
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.82</version>
</dependency>
<dependency>
<groupId>com.aliyun.api.gateway</groupId>
<artifactId>sdk-core-java</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>com.aliyun.iotx</groupId>
<artifactId>iotx-api-gateway-client</artifactId>
<version>1.0.3</version>
</dependency>
- 针对SPA⻚⾯,⽀持⾃动监听上报数据,⻚⾯切换即时上报
- 主动上报接⼝,⽤户可以⾃定义上报数据
代码示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script src="https://g.alicdn.com/iotx-industry-fe/iotx-fe-logger/1.0.0/index.aio.min.js"></script>
<script>
// 引入Logger
const Logger = window['iotx-fe-logger'].default;
// 初始化Logger
const log = new Logger({
autoSendPv: true, // 是否自动上报
appType: 'THIRD_APP',
appKey: '25219625', //三方应用appKey
});
// 调用主动上报接口
log.api({
// appconfig 定义每个页面的pageId
pageId: '/dashboard',
});
</script>
</body>
</html>