Selaa lähdekoodia

feat: 提交首次

Jayhaw 5 kuukautta sitten
commit
042cefdf00

+ 2 - 0
.gitattributes

@@ -0,0 +1,2 @@
+/mvnw text eol=lf
+*.cmd text eol=crlf

+ 33 - 0
.gitignore

@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/

+ 107 - 0
pom.xml

@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>cn.sciento</groupId>
+        <artifactId>stong-parent</artifactId>
+        <version>1.2.0-RELEASE</version>
+    </parent>
+
+    <groupId>cn.sciento.deploy</groupId>
+    <artifactId>wf-platform-equipment-automation-demo</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>wf-platform-equipment-automation-demo</name>
+    <description>wf-platform-equipment-automation-demo</description>
+    <properties>
+        <java.version>1.8</java.version>
+        <logback.contrib.version>0.1.5</logback.contrib.version>
+    </properties>
+
+    <dependencies>
+        <!--配置中心来做配置管理-->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+        </dependency>
+        <!--配置中心来做配置管理-->
+        <!-- 智能控制开始 -->
+        <dependency>
+            <groupId>cn.sciento.farm</groupId>
+            <artifactId>wf-platform-equipment-automation</artifactId>
+            <version>1.3.8-SNAPSHOT</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-tomcat</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <!-- 智能控制结束 -->
+        <!-- 服务合并开始 -->
+        <dependency>
+            <groupId>cn.sciento.starter</groupId>
+            <artifactId>stong-starter-local-ribbon</artifactId>
+        </dependency>
+        <!-- 服务合并结束 -->
+
+        <!--配置中心来做配置管理-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-undertow</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <version>1.2.3</version>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+    <repositories>
+        <repository>
+            <id>StongPublic</id>
+            <name>StongCentral</name>
+            <url>https://nexus.sciento.cn/repository/maven-public/</url>
+            <releases>
+                <enabled>true</enabled>
+                <updatePolicy>always</updatePolicy>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+                <updatePolicy>always</updatePolicy>
+            </snapshots>
+        </repository>
+    </repositories>
+
+    <distributionManagement>
+        <!--发布版本仓库-->
+        <repository>
+            <!--nexus服务器中用户名:在settings.xml中和<server>的id一致-->
+            <id>StongReleases</id>
+            <!--自定义名称-->
+            <name>StongReleases</name>
+            <!--仓库地址-->
+            <url>https://nexus.sciento.cn/repository/maven-releases/</url>
+        </repository>
+        <!--快照版本仓库-->
+        <snapshotRepository>
+            <!--nexus服务器中用户名:在settings.xml中和<server>的id一致-->
+            <id>StongSnapshots</id>
+            <!--自定义名称-->
+            <name>StongSnapshots</name>
+            <!--仓库地址-->
+            <url>https://nexus.sciento.cn/repository/maven-snapshots/</url>
+        </snapshotRepository>
+    </distributionManagement>
+
+</project>

+ 19 - 0
src/main/java/cn/sciento/deploy/WfPlatformEquipmentAutomationDemoApplication.java

@@ -0,0 +1,19 @@
+package cn.sciento.deploy;
+
+import cn.sciento.farm.autoconfigure.automation.EnableEquipmentAutomationPlatform;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGenerator;
+
+@SpringBootApplication
+@EnableEquipmentAutomationPlatform
+public class WfPlatformEquipmentAutomationDemoApplication {
+
+    public static void main(String[] args) {
+        SpringApplication springApplication = new SpringApplication(WfPlatformEquipmentAutomationDemoApplication.class);
+        // bean命名生成规则,配置使用全限定类名
+        springApplication.setBeanNameGenerator(new FullyQualifiedAnnotationBeanNameGenerator());
+        springApplication.run(args);
+    }
+
+}

+ 150 - 0
src/main/resources/application.yml

@@ -0,0 +1,150 @@
+spring:
+  application:
+    name: wf-platform-equipment-automation
+  liquibase:
+    enabled: false
+  data:
+    mongodb:
+      host: 192.168.50.20
+      port: 27017
+      database: stong-history
+      username: stong
+      password: stong
+  datasource:
+    url: ${SPRING_DATASOURCE_URL:jdbc:mysql://192.168.50.20:3306/wf_platform_equipment?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8}
+    username: ${SPRING_DATASOURCE_USERNAME:root}
+    password: ${SPRING_DATASOURCE_PASSWORD:666Stkj!}
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    hikari:
+      # 连接池最小空闲连接数
+      minimum-idle: ${SPRING_DATASOURCE_MINIMUM_IDLE:20}
+      # 连接池允许的最大连接数
+      maximum-pool-size: ${SPRING_DATASOURCE_MAXIMUM_POOL_SIZE:200}
+      # 等待连接池分配连接的最大时长(毫秒)
+      connection-timeout: ${SPRING_DATASOURCE_CONNECTION_TIMEOUT:30000}
+  redis:
+    host: ${SPRING_REDIS_HOST:192.168.50.20}
+    port: ${SPRING_REDIS_PORT:6379}
+    database: ${SPRING_REDIS_DATABASE:3}
+    lettuce:
+      pool:
+        # 资源池中最大连接数
+        # 默认8,-1表示无限制;可根据服务并发redis情况及服务端的支持上限调整
+        max-active: ${SPRING_REDIS_POOL_MAX_ACTIVE:50}
+        # 资源池运行最大空闲的连接数
+        # 默认8,-1表示无限制;可根据服务并发redis情况及服务端的支持上限调整,一般建议和max-active保持一致,避免资源伸缩带来的开销
+        max-idle: ${SPRING_REDIS_POOL_MAX_IDLE:50}
+        # 当资源池连接用尽后,调用者的最大等待时间(单位为毫秒)
+        # 默认 -1 表示永不超时,设置5秒
+        max-wait: ${SPRING_REDIS_POOL_MAX_WAIT:5000}
+  activiti:
+    # 禁用activiti自动更新表结构
+    database-schema-update: false
+    # 开启历史日志,正式环境应关闭
+    history-level: none
+    async-executor:
+      max-async-jobs-due-per-acquisition: 100
+  servlet:
+    multipart:
+      # 单个文件上传最大
+      maxFileSize: ${SPRING_SERVLET_MULTIPART_MAX_FILE_SIZE:30MB}
+      # 上传请求最大限制
+      maxRequestSize: ${SPRING_SERVLET_MULTIPART_MAX_REQUEST_SIZE:30MB}
+  thymeleaf:
+    prefix: classpath:/view/
+    mode: LEGACYHTML5
+  resources:
+    # 资源缓存时间,单位秒
+    cache:
+      period: 3600
+    # 启用缓存
+    chain.cache: true
+    # 静态资源映射
+    static-locations: classpath:/static/,classpath:/view/
+  mvc:
+    view:
+      suffix: .html # 返回页面自动拼接.html后缀
+  main:
+    allow-bean-definition-overriding: true
+
+
+server:
+  undertow:
+    # 设置IO线程数, 它主要执行非阻塞的任务,它们会负责多个连接
+    # 默认值为8,建议设置每个CPU核心一个线程
+    threads:
+      io: ${SERVER_UNDERTOW_IO_THREADS:4}
+      # 阻塞任务线程池, 当执行类似servlet请求阻塞操作, undertow会从这个线程池中取得线程
+      # 默认等于 io-threads*8,它的值设置取决于系统的负载,可适当调大该值
+      worker: ${SERVER_UNDERTOW_WORKER_THREADS:128}
+    # 每块buffer的空间大小,越小空间被利用越充分
+    # 不要设置太大,以免影响其他应用,合适即可
+    buffer-size: ${SERVER_UNDERTOW_BUFFER_SIZE:1024}
+    # 是否分配的直接内存(NIO直接分配的堆外内存)
+    # 默认false
+    direct-buffers: true
+    # HTTP POST请求最大的大小
+    # 默认0,无限制,可设置10M
+    max-http-post-size: 10485760
+    allow-unescaped-characters-in-url: true
+
+  servlet:
+    context-path: /wfauto
+feign:
+  hystrix:
+    enabled: true
+
+hystrix:
+  threadpool:
+    default:
+      # 执行命令线程池的核心线程数,也是命令执行的最大并发量
+      # 默认10
+      coreSize: 1000
+      # 最大执行线程数
+      maximumSize: 1000
+  command:
+    default:
+      execution:
+        isolation:
+          thread:
+            # HystrixCommand 执行的超时时间,超时后进入降级处理逻辑。一个接口,理论的最佳响应速度应该在200ms以内,或者慢点的接口就几百毫秒。
+            # 默认 1000 毫秒,最高设置 2000足矣。如果超时,首先看能不能优化接口相关业务、SQL查询等,不要盲目加大超时时间,否则会导致线程堆积过多,hystrix 线程池卡死,最终服务不可用。
+            timeoutInMilliseconds: ${HYSTRIX_COMMAND_TIMEOUT_IN_MILLISECONDS:40000}
+
+ribbon:
+  # 客户端读取超时时间,超时时间要小于Hystrix的超时时间,否则重试机制就无意义了
+  ReadTimeout: ${RIBBON_READ_TIMEOUT:30000}
+  # 客户端连接超时时间
+  ConnectTimeout: ${RIBBON_CONNECT_TIMEOUT:3000}
+  # 访问实例失败(超时),允许自动重试,设置重试次数,失败后会更换实例访问,请一定确保接口的幂等性,否则重试可能导致数据异常。
+  OkToRetryOnAllOperations: true
+  MaxAutoRetries: 1
+  MaxAutoRetriesNextServer: 1
+
+logging:
+  level:
+    org.apache.ibatis: ${LOG_LEVEL:info}
+    io.choerodon: ${LOG_LEVEL:info}
+    cn.sciento.boot.admin: ${LOG_LEVEL:false} # 注册到admin出错不打印
+    cn.sciento: ${LOG_LEVEL:info} # 其他sciento包进行打印
+
+
+mybatis:
+  mapperLocations: classpath*:/mapper/*.xml
+  configuration:
+    map-underscore-to-camel-case: true
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    cache-enabled: false
+
+rocketmq:
+  name-server: 192.168.50.21:9876
+
+# stong配置
+stong:
+  collect-data-expire-duration: 30
+  signal-lock-time: 2
+  device-service-name: wf-platform-equipment
+  strategy-message-topic: wfpe_push_data_gateway_collection
+  strategy-message-group: automation-strategy-group
+  process-recover:
+    enable: false

+ 31 - 0
src/main/resources/bootstrap.yml

@@ -0,0 +1,31 @@
+server:
+  port: 8300
+management:
+  server:
+    port: 8301
+  endpoints:
+    web:
+      exposure:
+        include: '*'
+  metrics:
+    web:
+      server:
+        request:
+          autotime:
+            enabled: true
+
+
+spring:
+  profiles:
+    active: ${SPRING_PROFILES_ACTIVE:default}
+  cloud:
+    nacos:
+      config:
+        server-addr: 192.168.50.11:8848
+        namespace: stong-test-demo1
+        file-extension: yaml
+      discovery:
+        server-addr: 192.168.50.11:8848
+        namespace: stong-test-demo1
+        metadata:
+          VERSION: 1.0.0

+ 13 - 0
src/test/java/cn/sciento/deploy/WfPlatformEquipmentAutomationDemoApplicationTests.java

@@ -0,0 +1,13 @@
+package cn.sciento.deploy;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class WfPlatformEquipmentAutomationDemoApplicationTests {
+
+    @Test
+    void contextLoads() {
+    }
+
+}