Merge branch 'master' of http://git.picaiba.com/CaiXiang/SPC into yanyang
Conflicts: ym-baisc/src/main/java/com/cnbm/basic/mapper/ProductTypeMapper.java
This commit is contained in:
commit
3a77498965
23
pom.xml
23
pom.xml
@ -15,6 +15,7 @@
|
|||||||
<module>ym-baisc</module>
|
<module>ym-baisc</module>
|
||||||
<module>ym-schedule-task</module>
|
<module>ym-schedule-task</module>
|
||||||
<module>ym-influx</module>
|
<module>ym-influx</module>
|
||||||
|
<module>ym-quality-planning</module>
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
@ -92,17 +93,17 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- influx start-->
|
<!-- influx start-->
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>org.springframework.boot</groupId>
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
|
<!-- <artifactId>spring-boot-actuator-autoconfigure</artifactId>-->
|
||||||
<optional>true</optional>
|
<!-- <optional>true</optional>-->
|
||||||
<exclusions>
|
<!-- <exclusions>-->
|
||||||
<exclusion>
|
<!-- <exclusion>-->
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<!-- <groupId>com.fasterxml.jackson.core</groupId>-->
|
||||||
<artifactId>jackson-databind</artifactId>
|
<!-- <artifactId>jackson-databind</artifactId>-->
|
||||||
</exclusion>
|
<!-- </exclusion>-->
|
||||||
</exclusions>
|
<!-- </exclusions>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
|
|
||||||
<!-- influx end-->
|
<!-- influx end-->
|
||||||
|
|
||||||
|
@ -1,5 +1,75 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.cnbm.generator.code.mapper.ProductTypeMapper">
|
<mapper namespace="com.cnbm.basic.mapper.ProductTypeMapper">
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id,
|
||||||
|
`name`,
|
||||||
|
code,
|
||||||
|
descs,
|
||||||
|
`status`,
|
||||||
|
remark,
|
||||||
|
`valid`,
|
||||||
|
creator_id,
|
||||||
|
creator_name,
|
||||||
|
create_time,
|
||||||
|
updater_id,
|
||||||
|
updater_name,
|
||||||
|
update_time,
|
||||||
|
version
|
||||||
|
</sql>
|
||||||
|
<resultMap id="BaseResultMap" type="com.cnbm.basic.entity.ProductType">
|
||||||
|
<result column="id" property="id"/>
|
||||||
|
<result column="name" property="name"/>
|
||||||
|
<result column="code" property="code"/>
|
||||||
|
<result column="descs" property="descs"/>
|
||||||
|
<result column="status" property="status"/>
|
||||||
|
<result column="remark" property="remark"/>
|
||||||
|
<result column="valid" property="valid"/>
|
||||||
|
<result column="creator_id" property="creatorId"/>
|
||||||
|
<result column="creator_name" property="creatorName"/>
|
||||||
|
<result column="create_time" property="createTime"/>
|
||||||
|
<result column="updater_id" property="updaterId"/>
|
||||||
|
<result column="updater_name" property="updaterName"/>
|
||||||
|
<result column="update_time" property="updateTime"/>
|
||||||
|
<result column="version" property="version"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!--auto generated by MybatisCodeHelper on 2022-07-05-->
|
||||||
|
<insert id="insertList">
|
||||||
|
INSERT INTO product_type(
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
code,
|
||||||
|
descs,
|
||||||
|
status,
|
||||||
|
remark,
|
||||||
|
valid,
|
||||||
|
creator_id,
|
||||||
|
creator_name,
|
||||||
|
create_time,
|
||||||
|
updater_id,
|
||||||
|
updater_name,
|
||||||
|
update_time,
|
||||||
|
version
|
||||||
|
)VALUES
|
||||||
|
<foreach collection="list" item="element" index="index" separator=",">
|
||||||
|
(
|
||||||
|
#{element.id},
|
||||||
|
#{element.name},
|
||||||
|
#{element.code},
|
||||||
|
#{element.descs},
|
||||||
|
#{element.status},
|
||||||
|
#{element.remark},
|
||||||
|
#{element.valid},
|
||||||
|
#{element.creatorId},
|
||||||
|
#{element.creatorName},
|
||||||
|
#{element.createTime},
|
||||||
|
#{element.updaterId},
|
||||||
|
#{element.updaterName},
|
||||||
|
#{element.updateTime},
|
||||||
|
#{element.version}
|
||||||
|
)
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.cnbm.generator.code.mapper.UnitMapper">
|
<mapper namespace="com.cnbm.basic.mapper.UnitMapper">
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
101
ym-common/src/main/java/com/cnbm/common/spc/math/Math.java
Normal file
101
ym-common/src/main/java/com/cnbm/common/spc/math/Math.java
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
package com.cnbm.common.spc.math;
|
||||||
|
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
public class Math {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// try(Scanner input = new Scanner(System.in);) {
|
||||||
|
// System.out.print("Enter ten numbers: ");
|
||||||
|
// double[] numbers = new double[10];
|
||||||
|
// for (int i = 0; i < numbers.length; i++)
|
||||||
|
// numbers[i] = input.nextDouble();
|
||||||
|
//
|
||||||
|
// System.out.println("The mean is "+getMean(numbers)+
|
||||||
|
// "\nThe stand deviation is "+getStandDeviation(numbers));
|
||||||
|
// }
|
||||||
|
|
||||||
|
//8.1 10.6 9.8 9.0 9.4 9.3 10.2 11.7
|
||||||
|
double[] d = new double[8];
|
||||||
|
d[0] = new Double(8.1) ;
|
||||||
|
d[1] = new Double(10.6);
|
||||||
|
d[2] = new Double(9.8);
|
||||||
|
d[3] = new Double(9.0);
|
||||||
|
d[4] = new Double(9.4);
|
||||||
|
d[5] = new Double(9.3);
|
||||||
|
d[6] = new Double(10.2);
|
||||||
|
d[7] = new Double(11.7);
|
||||||
|
|
||||||
|
;
|
||||||
|
System.out.println("均值: "+getMean(d)+",,标准差:"+StandardDiviation(d)+",极差:"+range(d));
|
||||||
|
}
|
||||||
|
|
||||||
|
//平均值
|
||||||
|
public static double getMean(double...numbers) {
|
||||||
|
return format(getSum(numbers) / numbers.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
//极差
|
||||||
|
public static double range(double[] in) {
|
||||||
|
if (in == null) {
|
||||||
|
throw new NumberFormatException();
|
||||||
|
}
|
||||||
|
double max = Double.MIN_VALUE;
|
||||||
|
double min = Double.MAX_VALUE;
|
||||||
|
for (int i = 0; i < in.length; i++) {
|
||||||
|
max = java.lang.Math.max(max, in[i]);
|
||||||
|
min = java.lang.Math.min(min, in[i]);
|
||||||
|
}
|
||||||
|
return format(max - min);
|
||||||
|
//return Mutil.subtract(max, min);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double format(double value) {
|
||||||
|
DecimalFormat df = new DecimalFormat("0.00");//创建一个df对象,传入0.00表示构造一个保留小数点后两位的df对象
|
||||||
|
df.setRoundingMode(RoundingMode.HALF_UP);//设置规则,这里采用的也是四舍五入规则
|
||||||
|
return Double.parseDouble(df.format(value));//返回value(在返回之前使用df对象的格式化方法将数据格式化)
|
||||||
|
}
|
||||||
|
|
||||||
|
//方差s^2=[(x1-x)^2 +...(xn-x)^2]/n 或者s^2=[(x1-x)^2 +...(xn-x)^2]/(n-1)
|
||||||
|
public static double Variance(double[] x) {
|
||||||
|
int m=x.length;
|
||||||
|
double sum=0;
|
||||||
|
for(int i=0;i<m;i++){//求和
|
||||||
|
sum+=x[i];
|
||||||
|
}
|
||||||
|
double dAve=sum/m;//求平均值
|
||||||
|
double dVar=0;
|
||||||
|
for(int i=0;i<m;i++){//求方差
|
||||||
|
dVar+=(x[i]-dAve)*(x[i]-dAve);
|
||||||
|
}
|
||||||
|
return format(dVar/m);
|
||||||
|
}
|
||||||
|
|
||||||
|
//标准差σ=sqrt(s^2)
|
||||||
|
public static double StandardDiviation(double[] x) {
|
||||||
|
int m=x.length;
|
||||||
|
double sum=0;
|
||||||
|
for(int i=0;i<m;i++){//求和
|
||||||
|
sum+=x[i];
|
||||||
|
}
|
||||||
|
double dAve=sum/m;//求平均值
|
||||||
|
double dVar=0;
|
||||||
|
for(int i=0;i<m;i++){//求方差
|
||||||
|
dVar+=(x[i]-dAve)*(x[i]-dAve);
|
||||||
|
}
|
||||||
|
return format(java.lang.Math.sqrt(dVar/(m-1)));
|
||||||
|
//return Math.sqrt(dVar/m);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//前n项和
|
||||||
|
public static double getSum(double...numbers) {
|
||||||
|
double sum = 0.0;
|
||||||
|
|
||||||
|
for (double i : numbers) {
|
||||||
|
sum += i;
|
||||||
|
}
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.cnbm.influx.common;
|
package com.cnbm.common.spc.util;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -9,9 +9,9 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @Desc: ""
|
* @Desc: ""
|
||||||
* @Author: caixiang
|
* @Author: caixiang
|
||||||
* @DATE: 2022/6/29 16:23
|
* @DATE: 2022/7/12 14:23
|
||||||
*/
|
*/
|
||||||
public class Utils {
|
public class DataUtils {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ArrayList<Integer> arrs = new ArrayList<>();
|
ArrayList<Integer> arrs = new ArrayList<>();
|
||||||
|
|
||||||
@ -64,6 +64,4 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -37,6 +37,11 @@
|
|||||||
<artifactId>ym-influx</artifactId>
|
<artifactId>ym-influx</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cnbm</groupId>
|
||||||
|
<artifactId>ym-quality-planning</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<!-- <dependency>-->
|
<!-- <dependency>-->
|
||||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
<!-- <artifactId>spring-boot-actuator-autoconfigure</artifactId>-->
|
<!-- <artifactId>spring-boot-actuator-autoconfigure</artifactId>-->
|
||||||
|
@ -112,6 +112,22 @@ public class SwaggerConfig {
|
|||||||
.securitySchemes(Arrays.asList(new ApiKey("token", "token", "header")));
|
.securitySchemes(Arrays.asList(new ApiKey("token", "token", "header")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Docket qualityPlanningApi() {
|
||||||
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.groupName("ym-quality-planning")
|
||||||
|
.apiInfo(apiInfos("质量规划", "质量规划模块"))
|
||||||
|
.useDefaultResponseMessages(true)
|
||||||
|
.forCodeGeneration(false)
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.basePackage("com.cnbm.qualityPlanning"))
|
||||||
|
.paths(PathSelectors.any())
|
||||||
|
.build()
|
||||||
|
.securityContexts(Arrays.asList(securityContext()))
|
||||||
|
// ApiKey的name需与SecurityReference的reference保持一致
|
||||||
|
.securitySchemes(Arrays.asList(new ApiKey("token", "token", "header")));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建该API的基本信息(这些基本信息会展现在文档页面中)
|
* 创建该API的基本信息(这些基本信息会展现在文档页面中)
|
||||||
* 访问地址:http://ip:port/swagger-ui.html
|
* 访问地址:http://ip:port/swagger-ui.html
|
||||||
|
@ -23,7 +23,11 @@
|
|||||||
<artifactId>influxdb-client-java</artifactId>
|
<artifactId>influxdb-client-java</artifactId>
|
||||||
<version>6.3.0</version>
|
<version>6.3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cnbm</groupId>
|
||||||
|
<artifactId>ym-common</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!--- begin -->
|
<!--- begin -->
|
||||||
<!-- <dependency>-->
|
<!-- <dependency>-->
|
||||||
|
@ -60,16 +60,17 @@ public enum InfluxClient {
|
|||||||
* true 服务正常健康
|
* true 服务正常健康
|
||||||
* false 异常
|
* false 异常
|
||||||
*/
|
*/
|
||||||
private boolean ping() {
|
public boolean ping() {
|
||||||
boolean isConnected = false;
|
boolean isConnected = false;
|
||||||
Boolean pong;
|
Boolean pong;
|
||||||
try {
|
try {
|
||||||
pong = influxDBClient.ping();
|
pong = influxDBClient.ping();
|
||||||
if (pong != null) {
|
if (pong != null) {
|
||||||
isConnected = true;
|
isConnected = pong;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return isConnected;
|
return isConnected;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
package com.cnbm.influx.controller;
|
package com.cnbm.influx.controller;
|
||||||
|
|
||||||
|
import com.cnbm.common.spc.util.DataUtils;
|
||||||
import com.cnbm.influx.config.InfluxClient;
|
import com.cnbm.influx.config.InfluxClient;
|
||||||
|
import com.cnbm.influx.param.PageInfo;
|
||||||
|
import com.cnbm.influx.param.QueryDataParam;
|
||||||
|
import com.cnbm.influx.param.Range;
|
||||||
|
import com.cnbm.influx.param.Tag;
|
||||||
import com.cnbm.influx.template.Event;
|
import com.cnbm.influx.template.Event;
|
||||||
import com.influxdb.client.InfluxDBClient;
|
import com.influxdb.client.InfluxDBClient;
|
||||||
import com.influxdb.client.domain.WritePrecision;
|
import com.influxdb.client.domain.WritePrecision;
|
||||||
import com.influxdb.client.write.Point;
|
import com.influxdb.client.write.Point;
|
||||||
|
import com.influxdb.query.FluxRecord;
|
||||||
|
import com.influxdb.query.FluxTable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -12,47 +19,88 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/influx")
|
@RequestMapping("/influx")
|
||||||
public class S7DemoController {
|
public class S7DemoController {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(S7DemoController.class);
|
private static final Logger logger = LoggerFactory.getLogger(S7DemoController.class);
|
||||||
|
|
||||||
@Autowired
|
|
||||||
InfluxDBClient influxDBClient;
|
|
||||||
|
|
||||||
|
|
||||||
// try (WriteApi writeApi = influxDBClient.makeWriteApi()) {
|
|
||||||
// Temperature temperature = new Temperature();
|
|
||||||
// temperature.setLocation("east");
|
|
||||||
// temperature.setValue(106.2D);
|
|
||||||
// temperature.setTime(Instant.now());
|
|
||||||
// writeApi.writeMeasurement(WritePrecision.NS,temperature);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// try (WriteApi writeApi = influxDBClient.makeWriteApi()) {
|
|
||||||
// Point point = Point.measurement("temperature")
|
|
||||||
// .addTag("location","south")
|
|
||||||
// .addTag("owner","wxm")
|
|
||||||
// .addField("wxm",230.8);
|
|
||||||
// writeApi.writePoint(point);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/insertBatch")
|
@PostMapping("/insertBatch")
|
||||||
public void insertBatch() throws InterruptedException {
|
public void insertBatch() throws InterruptedException {
|
||||||
// List<Event> list = new ArrayList<>();
|
List<Event> list = new ArrayList<>();
|
||||||
//
|
|
||||||
// for(int i=0;i<99;i++){
|
for(int i=0;i<99;i++){
|
||||||
// //Thread.sleep(1000);
|
Thread.sleep(100);
|
||||||
// Event event = new Event();
|
Event event = new Event();
|
||||||
// event.time = Instant.now();
|
event.setTime(Instant.now());
|
||||||
// event.transationId = "asas"+i;
|
event.setTransationId("asas"+i);
|
||||||
// event.argName = "arg5";
|
event.setArgName("arg7");
|
||||||
// event.argValue = new Double(i);
|
event.setArgValue(new Double(i));
|
||||||
// list.add(event);
|
list.add(event);
|
||||||
// }
|
}
|
||||||
// influxService.batchInsert(list);
|
InfluxClient.Client.batchInsert(list,"ASProcessCompleteEventAS");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试连接是否正常
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* true 服务正常健康
|
||||||
|
* false 异常
|
||||||
|
*/
|
||||||
|
@PostMapping("/ping")
|
||||||
|
public void ping() throws InterruptedException {
|
||||||
|
boolean ping = InfluxClient.Client.ping();
|
||||||
|
System.out.println(ping);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/query")
|
||||||
|
public void query() throws InterruptedException {
|
||||||
|
List<Event> list = new ArrayList<>();
|
||||||
|
|
||||||
|
QueryDataParam queryDataParam = new QueryDataParam();
|
||||||
|
queryDataParam.setBucket("qgs-bucket");
|
||||||
|
queryDataParam.setMeasurement("ASProcessCompleteEventAS");
|
||||||
|
queryDataParam.setDropedTagName("transationId");
|
||||||
|
queryDataParam.setTag(new Tag("argName","arg6"));
|
||||||
|
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(),Instant.now()));
|
||||||
|
queryDataParam.setPageInfo(new PageInfo(1,10));
|
||||||
|
List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
||||||
|
|
||||||
|
|
||||||
|
for (FluxTable fluxTable : query) {
|
||||||
|
List<FluxRecord> records = fluxTable.getRecords();
|
||||||
|
for (FluxRecord fluxRecord : records) {
|
||||||
|
System.out.println("value: " + fluxRecord.getValueByKey("_value"));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
List<Event> list = new ArrayList<>();
|
||||||
|
|
||||||
|
QueryDataParam queryDataParam = new QueryDataParam();
|
||||||
|
queryDataParam.setBucket("qgs-bucket");
|
||||||
|
queryDataParam.setMeasurement("ASProcessCompleteEventAS");
|
||||||
|
queryDataParam.setDropedTagName("transationId");
|
||||||
|
queryDataParam.setTag(new Tag("argName","arg7"));
|
||||||
|
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(),Instant.now()));
|
||||||
|
queryDataParam.setPageInfo(new PageInfo(2,10));
|
||||||
|
List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
||||||
|
|
||||||
|
|
||||||
|
for (FluxTable fluxTable : query) {
|
||||||
|
List<FluxRecord> records = fluxTable.getRecords();
|
||||||
|
for (FluxRecord fluxRecord : records) {
|
||||||
|
System.out.println("value: " + fluxRecord.getValueByKey("_value"));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -71,8 +119,8 @@ public class S7DemoController {
|
|||||||
event.setTime(Instant.now());
|
event.setTime(Instant.now());
|
||||||
event.setTransationId("asasd11");
|
event.setTransationId("asasd11");
|
||||||
event.setArgName("argName11");
|
event.setArgName("argName11");
|
||||||
event.setArgValue(7d);
|
event.setArgValue(900001d);
|
||||||
Point asProcessCompleteEvent = insert(event, "ASProcessCompleteEvent");
|
Point asProcessCompleteEvent = insert(event, "ASProcessCompleteEvent");
|
||||||
influxDBClient.makeWriteApi().writePoint(asProcessCompleteEvent);
|
InfluxClient.Client.insert(event,"ASProcessCompleteEvent");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* The MIT License
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package com.cnbm.influx.health;
|
|
||||||
|
|
||||||
import com.influxdb.client.InfluxDBClient;
|
|
||||||
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
|
|
||||||
import org.springframework.boot.actuate.health.Health;
|
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link //HealthIndicator} for InfluxDB 2.
|
|
||||||
*
|
|
||||||
* @author Jakub Bednar (bednar@github)
|
|
||||||
*/
|
|
||||||
public class InfluxDB2HealthIndicator extends AbstractHealthIndicator {
|
|
||||||
|
|
||||||
private final InfluxDBClient influxDBClient;
|
|
||||||
|
|
||||||
public InfluxDB2HealthIndicator(final InfluxDBClient influxDBClient) {
|
|
||||||
super("InfluxDBClient 2 health check failed");
|
|
||||||
Assert.notNull(influxDBClient, "InfluxDBClient must not be null");
|
|
||||||
|
|
||||||
this.influxDBClient = influxDBClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doHealthCheck(final Health.Builder builder) {
|
|
||||||
boolean success = this.influxDBClient.ping();
|
|
||||||
|
|
||||||
if (success) {
|
|
||||||
builder.up();
|
|
||||||
} else {
|
|
||||||
builder.down();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* The MIT License
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package com.cnbm.influx.health;
|
|
||||||
|
|
||||||
import com.cnbm.influx.influx.InfluxDB2AutoConfiguration;
|
|
||||||
import com.influxdb.client.InfluxDBClient;
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.health.CompositeHealthContributorConfiguration;
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
|
|
||||||
import org.springframework.boot.actuate.health.HealthContributor;
|
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link EnableAutoConfiguration Auto-configuration} for {@link InfluxDB2HealthIndicator}.
|
|
||||||
*
|
|
||||||
* @author Jakub Bednar
|
|
||||||
*/
|
|
||||||
@Configuration(proxyBeanMethods = false)
|
|
||||||
@ConditionalOnClass(InfluxDBClient.class)
|
|
||||||
@ConditionalOnBean(InfluxDBClient.class)
|
|
||||||
@ConditionalOnEnabledHealthIndicator("influx")
|
|
||||||
@AutoConfigureAfter(InfluxDB2AutoConfiguration.class)
|
|
||||||
public class InfluxDB2HealthIndicatorAutoConfiguration
|
|
||||||
extends CompositeHealthContributorConfiguration<InfluxDB2HealthIndicator, InfluxDBClient> {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnMissingBean(name = { "influxDB2HealthIndicator", "influxDB2HealthContributor" })
|
|
||||||
public HealthContributor influxDbHealthContributor(final Map<String, InfluxDBClient> influxDBClients) {
|
|
||||||
return createContributor(influxDBClients);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* The MIT License
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package com.cnbm.influx.influx;
|
|
||||||
|
|
||||||
import com.influxdb.client.InfluxDBClientOptions;
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.Protocol;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Jakub Bednar (04/08/2021 11:41)
|
|
||||||
*/
|
|
||||||
abstract class AbstractInfluxDB2AutoConfiguration {
|
|
||||||
protected final InfluxDB2Properties properties;
|
|
||||||
protected final InfluxDB2OkHttpClientBuilderProvider builderProvider;
|
|
||||||
|
|
||||||
protected AbstractInfluxDB2AutoConfiguration(final InfluxDB2Properties properties,
|
|
||||||
final InfluxDB2OkHttpClientBuilderProvider builderProvider) {
|
|
||||||
this.properties = properties;
|
|
||||||
this.builderProvider = builderProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
protected InfluxDBClientOptions.Builder makeBuilder() {
|
|
||||||
OkHttpClient.Builder okHttpBuilder;
|
|
||||||
if (builderProvider == null) {
|
|
||||||
okHttpBuilder = new OkHttpClient.Builder()
|
|
||||||
.protocols(Collections.singletonList(Protocol.HTTP_1_1))
|
|
||||||
.readTimeout(properties.getReadTimeout())
|
|
||||||
.writeTimeout(properties.getWriteTimeout())
|
|
||||||
.connectTimeout(properties.getConnectTimeout());
|
|
||||||
} else {
|
|
||||||
okHttpBuilder = builderProvider.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
InfluxDBClientOptions.Builder influxBuilder = InfluxDBClientOptions.builder()
|
|
||||||
.url(properties.getUrl())
|
|
||||||
.bucket(properties.getBucket())
|
|
||||||
.org(properties.getOrg())
|
|
||||||
.okHttpClient(okHttpBuilder);
|
|
||||||
|
|
||||||
if (StringUtils.hasLength(properties.getToken())) {
|
|
||||||
influxBuilder.authenticateToken(properties.getToken().toCharArray());
|
|
||||||
} else if (StringUtils.hasLength(properties.getUsername()) && StringUtils.hasLength(properties.getPassword())) {
|
|
||||||
influxBuilder.authenticate(properties.getUsername(), properties.getPassword().toCharArray());
|
|
||||||
}
|
|
||||||
return influxBuilder;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
/*
|
|
||||||
* The MIT License
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package com.cnbm.influx.influx;
|
|
||||||
|
|
||||||
import com.influxdb.client.InfluxDBClient;
|
|
||||||
import com.influxdb.client.InfluxDBClientFactory;
|
|
||||||
import com.influxdb.client.InfluxDBClientOptions;
|
|
||||||
import org.springframework.beans.factory.ObjectProvider;
|
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link EnableAutoConfiguration Auto-configuration} for InfluxDB 2.
|
|
||||||
*
|
|
||||||
* @author Jakub Bednar (bednar@github) (06/05/2019 13:09)
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
@ConditionalOnClass(InfluxDBClient.class)
|
|
||||||
@EnableConfigurationProperties(InfluxDB2Properties.class)
|
|
||||||
public class InfluxDB2AutoConfiguration extends AbstractInfluxDB2AutoConfiguration {
|
|
||||||
|
|
||||||
public InfluxDB2AutoConfiguration(final InfluxDB2Properties properties,
|
|
||||||
final ObjectProvider<InfluxDB2OkHttpClientBuilderProvider> builderProvider) {
|
|
||||||
super(properties, builderProvider.getIfAvailable());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnProperty("influx.url")
|
|
||||||
@ConditionalOnMissingBean(InfluxDBClient.class)
|
|
||||||
public InfluxDBClient influxDBClient() {
|
|
||||||
|
|
||||||
InfluxDBClientOptions.Builder influxBuilder = makeBuilder();
|
|
||||||
|
|
||||||
return InfluxDBClientFactory.create(influxBuilder.build()).setLogLevel(properties.getLogLevel());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* The MIT License
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package com.cnbm.influx.influx;
|
|
||||||
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provide the {@link OkHttpClient.Builder OkHttpClient.Builder} to use to
|
|
||||||
* customize the auto-configured {@link com.influxdb.client.InfluxDBClient} instance.
|
|
||||||
*
|
|
||||||
* @author Jakub Bednar (bednar@github) (06/05/2019 13:11)
|
|
||||||
*/
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface InfluxDB2OkHttpClientBuilderProvider extends Supplier<OkHttpClient.Builder> {
|
|
||||||
|
|
||||||
}
|
|
@ -1,178 +0,0 @@
|
|||||||
/*
|
|
||||||
* The MIT License
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package com.cnbm.influx.influx;
|
|
||||||
|
|
||||||
import com.cnbm.influx.constant.Constant;
|
|
||||||
import com.influxdb.LogLevel;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration properties for InfluxDB 2.
|
|
||||||
*
|
|
||||||
* @author Jakub Bednar (bednar@github) (06/05/2019 12:54)
|
|
||||||
*/
|
|
||||||
@ConfigurationProperties(prefix = "influx")
|
|
||||||
public class InfluxDB2Properties {
|
|
||||||
|
|
||||||
// public InfluxDB2Properties{
|
|
||||||
// this.bucket = Constant.bucket;
|
|
||||||
// this.url = Constant.url;
|
|
||||||
// this.org = Constant.org;
|
|
||||||
// this.token = Constant.token;
|
|
||||||
// this.username = Constant.username;
|
|
||||||
// this.password = Constant.password;
|
|
||||||
// }
|
|
||||||
|
|
||||||
private static final int DEFAULT_TIMEOUT = 10_000;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* URL to connect to InfluxDB.
|
|
||||||
*/
|
|
||||||
private String url = Constant.url;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Username to use in the basic auth.
|
|
||||||
*/
|
|
||||||
private String username = Constant.username;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Password to use in the basic auth.
|
|
||||||
*/
|
|
||||||
private String password = Constant.password;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Token to use for the authorization.
|
|
||||||
*/
|
|
||||||
private String token = Constant.token;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default destination organization for writes and queries.
|
|
||||||
*/
|
|
||||||
private String org = Constant.org;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default destination bucket for writes.
|
|
||||||
*/
|
|
||||||
private String bucket = Constant.bucket;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The log level for logging the HTTP request and HTTP response.
|
|
||||||
*/
|
|
||||||
private LogLevel logLevel = LogLevel.NONE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read timeout for {@code OkHttpClient}.
|
|
||||||
*/
|
|
||||||
private Duration readTimeout = Duration.ofMillis(DEFAULT_TIMEOUT);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write timeout for {@code OkHttpClient}.
|
|
||||||
*/
|
|
||||||
private Duration writeTimeout = Duration.ofMillis(DEFAULT_TIMEOUT);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Connection timeout for {@code OkHttpClient}.
|
|
||||||
*/
|
|
||||||
private Duration connectTimeout = Duration.ofMillis(DEFAULT_TIMEOUT);
|
|
||||||
|
|
||||||
public String getUrl() {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUrl(final String url) {
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsername(final String username) {
|
|
||||||
this.username = username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassword(final String password) {
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getToken() {
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToken(final String token) {
|
|
||||||
this.token = token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LogLevel getLogLevel() {
|
|
||||||
return logLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLogLevel(final LogLevel logLevel) {
|
|
||||||
this.logLevel = logLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOrg() {
|
|
||||||
return org;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrg(final String org) {
|
|
||||||
this.org = org;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBucket() {
|
|
||||||
return bucket;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBucket(final String bucket) {
|
|
||||||
this.bucket = bucket;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Duration getReadTimeout() {
|
|
||||||
return readTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReadTimeout(final Duration readTimeout) {
|
|
||||||
this.readTimeout = readTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Duration getWriteTimeout() {
|
|
||||||
return writeTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWriteTimeout(final Duration writeTimeout) {
|
|
||||||
this.writeTimeout = writeTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Duration getConnectTimeout() {
|
|
||||||
return connectTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConnectTimeout(final Duration connectTimeout) {
|
|
||||||
this.connectTimeout = connectTimeout;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
influx:
|
|
||||||
url: http://192.168.0.170:8086 # URL to connect to InfluxDB.
|
|
||||||
username: caixiang # Username to use in the basic auth.
|
|
||||||
password: 251128856 # Password to use in the basic auth.
|
|
||||||
token: lkBsC27QZr1W50BSPlGxpTqNNpwuUk5uz1dZZRPSPbCG5VmNDDUo8P3UkZIhGWwfJwkuz6ZGZ7Et4_KBaG3gHw== # Token to use for the authorization.
|
|
||||||
org: qgs # Default destination organization for writes and queries.
|
|
||||||
bucket: qgs-bucket # Default destination bucket for writes.
|
|
||||||
logLevel: BODY # The log level for logging the HTTP request and HTTP response. (Default: NONE)
|
|
||||||
readTimeout: 5s # Read timeout for OkHttpClient. (Default: 10s)
|
|
||||||
writeTimeout: 5s # Write timeout for OkHttpClient. (Default: 10s)
|
|
||||||
connectTimeout: 5s # Connection timeout for OkHttpClient. (Default: 10s)
|
|
||||||
|
|
||||||
# management.health.influx.enabled=true # Whether to enable InfluxDB 2.x health check.
|
|
||||||
management:
|
|
||||||
health:
|
|
||||||
influxdb:
|
|
||||||
enabled: true
|
|
25
ym-quality-planning/pom.xml
Normal file
25
ym-quality-planning/pom.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>ym-pass</artifactId>
|
||||||
|
<groupId>com.cnbm</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>ym-quality-planning</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cnbm</groupId>
|
||||||
|
<artifactId>ym-common</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@ -0,0 +1,257 @@
|
|||||||
|
package com.cnbm.qualityPlanning.common;
|
||||||
|
|
||||||
|
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
||||||
|
import com.cnbm.qualityPlanning.entity.Point;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Desc: "检测参数统计受控 检验类"
|
||||||
|
* @Author: caixiang
|
||||||
|
* @DATE: 2022/7/11 15:27
|
||||||
|
*/
|
||||||
|
public class StatisticalControlledTest {
|
||||||
|
private static final Integer rule1Number = 1;
|
||||||
|
private static final Integer rule2Number = 2;
|
||||||
|
private static final Integer rule3Number = 3;
|
||||||
|
private static final Integer rule4Number = 4;
|
||||||
|
private static final Integer rule5Number = 5;
|
||||||
|
private static final Integer rule6Number = 6;
|
||||||
|
private static final Integer rule7Number = 7;
|
||||||
|
private static final Integer rule8Number = 8;
|
||||||
|
private static final Integer rule9Number = 9;
|
||||||
|
private static final Integer rule10Number = 10;
|
||||||
|
|
||||||
|
public static List<Point> createData(){
|
||||||
|
Point point = new Point(1,new Double(1));
|
||||||
|
Point point2 = new Point(2,new Double(2));
|
||||||
|
Point point3 = new Point(3,new Double(3));
|
||||||
|
Point point4 = new Point(4,new Double(4));
|
||||||
|
Point point5 = new Point(5,new Double(5));
|
||||||
|
Point point6 = new Point(6,new Double(6));
|
||||||
|
Point point7 = new Point(7,new Double(7));
|
||||||
|
Point point8 = new Point(8,new Double(8));
|
||||||
|
Point point9 = new Point(9,new Double(9));
|
||||||
|
Point point10 = new Point(10,new Double(10));
|
||||||
|
Point point11 = new Point(11,new Double(11));
|
||||||
|
Point point12 = new Point(12,new Double(12));
|
||||||
|
List<Point> list = new ArrayList<>();
|
||||||
|
list.add(point);
|
||||||
|
list.add(point2);
|
||||||
|
list.add(point3);
|
||||||
|
list.add(point4);
|
||||||
|
list.add(point5);
|
||||||
|
list.add(point6);
|
||||||
|
list.add(point7);
|
||||||
|
list.add(point8);
|
||||||
|
list.add(point9);
|
||||||
|
list.add(point10);
|
||||||
|
list.add(point11);
|
||||||
|
list.add(point12);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
List<Point> list = createData();
|
||||||
|
ControlLimit controlLimit = new ControlLimit(new Double(12),new Double(2),new Double(1));
|
||||||
|
|
||||||
|
//TEST FOR RULE1
|
||||||
|
Boolean aBoolean1 = rule1(list, controlLimit);
|
||||||
|
|
||||||
|
//TEST FOR RULE2
|
||||||
|
Boolean aBoolean2 = rule2(list, controlLimit, 9);
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
|
||||||
|
//TEST FOR RULE3
|
||||||
|
Boolean aBoolean3 = rule3(list, 3);
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name : 规则1
|
||||||
|
* desc : 控制图上有 1 个点位于三倍标准差以外(对中心线来说)(母体的 $\sigma$ )
|
||||||
|
*
|
||||||
|
* return : 返回的 就是不满足 规则1 的点。
|
||||||
|
* */
|
||||||
|
private static Boolean rule1(List<Point> data, ControlLimit controlLimit){
|
||||||
|
for(Point i:data){
|
||||||
|
if(i.getValue() > controlLimit.getUCL() || i.getValue() < controlLimit.getLCL()){
|
||||||
|
i.getUnsatisfiedRules().add(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void markUnsatisfiedRulesByKeys(List<Point> data,List<Integer> keys,Integer ruleNumber){
|
||||||
|
for (Integer key:keys){
|
||||||
|
data.get(key).getUnsatisfiedRules().add(ruleNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name : 规则2
|
||||||
|
* desc : 连续 n 点落在中心线的用一侧 (默认:9)
|
||||||
|
*
|
||||||
|
* return : 返回的 就是不满足 规则2 的点。
|
||||||
|
* */
|
||||||
|
private static Boolean rule2(List<Point> data, ControlLimit controlLimit,Integer n){
|
||||||
|
List<Point> upList = new ArrayList<>();
|
||||||
|
List<Point> downList = new ArrayList<>();
|
||||||
|
for(Point i:data){
|
||||||
|
if(i.getValue() > controlLimit.getCL()){
|
||||||
|
upList.add(i);
|
||||||
|
}else if(i.getValue() < controlLimit.getCL()){
|
||||||
|
downList.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//上侧的情况
|
||||||
|
Integer upi = 0;
|
||||||
|
Integer uptime = 0;
|
||||||
|
//标注不合格的 参数
|
||||||
|
List<Point> forMarkPoints = new ArrayList<>();
|
||||||
|
while((upi+1) < upList.size()){
|
||||||
|
//if((upList.get(upi).getPosition()+1)==upList.get(upi+1).getPosition()){
|
||||||
|
if(isBetween(upList.get(upi),upList.get(upi+1))){
|
||||||
|
uptime +=1;
|
||||||
|
forMarkPoints.add(upList.get(upi));
|
||||||
|
//只要到达n 了,就return,防止中间段到达 后面又被重置了
|
||||||
|
if(uptime>=n){
|
||||||
|
//1.
|
||||||
|
for (Point key:forMarkPoints){
|
||||||
|
for(Point j:data){
|
||||||
|
if(key.getPosition()== j.getPosition()){
|
||||||
|
j.getUnsatisfiedRules().add(rule2Number);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//2.
|
||||||
|
// markUnsatisfiedRulesByKeys(data,forMarkKey,rule2Number);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
forMarkPoints = new ArrayList<>();
|
||||||
|
uptime = 0;
|
||||||
|
}
|
||||||
|
upi++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//下侧的情况
|
||||||
|
Integer downi = 0;
|
||||||
|
Integer downtime = 0;
|
||||||
|
forMarkPoints = new ArrayList<>();
|
||||||
|
while((downi+1) < downList.size()){
|
||||||
|
if(isBetween(downList.get(upi),downList.get(upi+1))){
|
||||||
|
downtime +=1;
|
||||||
|
forMarkPoints.add(downList.get(downi));
|
||||||
|
if(downtime>=n){
|
||||||
|
|
||||||
|
for (Point key:forMarkPoints){
|
||||||
|
for(Point j:data){
|
||||||
|
if(key.getPosition()== j.getPosition()){
|
||||||
|
j.getUnsatisfiedRules().add(rule2Number);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
forMarkPoints = new ArrayList<>();
|
||||||
|
downtime = 0;
|
||||||
|
}
|
||||||
|
downi++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name : 规则3
|
||||||
|
* desc : 连续 n 点递增或者递减 (默认:6)
|
||||||
|
*
|
||||||
|
* return : 返回的 就是不满足 规则2 的点。
|
||||||
|
* */
|
||||||
|
private static Boolean rule3(List<Point> data, Integer n){
|
||||||
|
|
||||||
|
//递增情况
|
||||||
|
Integer upi = 0;
|
||||||
|
Integer uptime = 0;
|
||||||
|
List<Integer> forMarkKey = new ArrayList<>();
|
||||||
|
while((upi+1) < data.size()){
|
||||||
|
if((isBetween( data.get(upi),data.get(upi+1) )) && isSmall( data.get(upi),data.get(upi+1) ) ){
|
||||||
|
uptime +=1;
|
||||||
|
forMarkKey.add(upi);
|
||||||
|
if(uptime>=n){
|
||||||
|
for(Integer key:forMarkKey){
|
||||||
|
data.get(key).getUnsatisfiedRules().add(rule3Number);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
uptime = 0;
|
||||||
|
forMarkKey = new ArrayList<>();
|
||||||
|
}
|
||||||
|
upi++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//递减情况
|
||||||
|
Integer downi = 0;
|
||||||
|
Integer downtime = 0;
|
||||||
|
forMarkKey = new ArrayList<>();
|
||||||
|
while((downi+1) < data.size()){
|
||||||
|
if((isBetween( data.get(downi),data.get(downi+1) )) && isBig( data.get(downi),data.get(downi+1) ) ){
|
||||||
|
downtime +=1;
|
||||||
|
forMarkKey.add(downi);
|
||||||
|
if(downtime>=n){
|
||||||
|
for(Integer key:forMarkKey){
|
||||||
|
data.get(key).getUnsatisfiedRules().add(rule3Number);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
downtime = 0;
|
||||||
|
forMarkKey = new ArrayList<>();
|
||||||
|
}
|
||||||
|
downi++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 如果 这两个点是相邻的 ==》 true
|
||||||
|
* */
|
||||||
|
private static boolean isBetween(Point head,Point after){
|
||||||
|
return (head.getPosition()+1) == after.getPosition();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 如果 head 小于 after ==》 true
|
||||||
|
* */
|
||||||
|
private static boolean isSmall(Point head,Point after){
|
||||||
|
return (head.getValue()- after.getValue()) < 0;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 如果 head 大于 after ==》 true
|
||||||
|
* */
|
||||||
|
private static boolean isBig(Point head,Point after){
|
||||||
|
return (head.getValue()- after.getValue()) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,261 @@
|
|||||||
|
package com.cnbm.qualityPlanning.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Desc: " "x bar - R" 控制系数 "
|
||||||
|
* @Author: caixiang
|
||||||
|
* @DATE: 2022/6/30 10:44
|
||||||
|
*/
|
||||||
|
public class XBarRCoefficients {
|
||||||
|
public static Double getA2(Integer sampleSize){
|
||||||
|
if(sampleSize<=1){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Double res = null;
|
||||||
|
switch(sampleSize){
|
||||||
|
//P92
|
||||||
|
case 2:
|
||||||
|
res = new Double(1.880);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
res = new Double(1.023);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
res = new Double(0.729);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
res = new Double(0.577);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
res = new Double(0.483);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
res = new Double(0.419);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
res = new Double(0.373);
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
res = new Double(0.337);
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
res = new Double(0.308);
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
res = new Double(0.285);
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
res = new Double(0.266);
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
res = new Double(0.249);
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
res = new Double(0.235);
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
res = new Double(0.223);
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
res = new Double(0.212);
|
||||||
|
break;
|
||||||
|
case 17:
|
||||||
|
res = new Double(0.203);
|
||||||
|
break;
|
||||||
|
case 18:
|
||||||
|
res = new Double(0.194);
|
||||||
|
break;
|
||||||
|
case 19:
|
||||||
|
res = new Double(0.187);
|
||||||
|
break;
|
||||||
|
case 20:
|
||||||
|
res = new Double(0.180);
|
||||||
|
break;
|
||||||
|
case 21:
|
||||||
|
res = new Double(0.173);
|
||||||
|
break;
|
||||||
|
case 22:
|
||||||
|
res = new Double(0.167);
|
||||||
|
break;
|
||||||
|
case 23:
|
||||||
|
res = new Double(0.162);
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
res = new Double(0.157);
|
||||||
|
break;
|
||||||
|
//大于等于25 都是用0.153
|
||||||
|
default :
|
||||||
|
res = new Double(0.153);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Double getD3(Integer sampleSize){
|
||||||
|
if(sampleSize<=1){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Double res = null;
|
||||||
|
switch(sampleSize){
|
||||||
|
//P92
|
||||||
|
case 2:
|
||||||
|
res = new Double(0);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
res = new Double(0);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
res = new Double(0);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
res = new Double(0);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
res = new Double(0);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
res = new Double(0.076);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
res = new Double(0.136);
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
res = new Double(0.184);
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
res = new Double(0.223);
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
res = new Double(0.256);
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
res = new Double(0.283);
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
res = new Double(0.307);
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
res = new Double(0.328);
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
res = new Double(0.347);
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
res = new Double(0.363);
|
||||||
|
break;
|
||||||
|
case 17:
|
||||||
|
res = new Double(0.378);
|
||||||
|
break;
|
||||||
|
case 18:
|
||||||
|
res = new Double(0.391);
|
||||||
|
break;
|
||||||
|
case 19:
|
||||||
|
res = new Double(0.403);
|
||||||
|
break;
|
||||||
|
case 20:
|
||||||
|
res = new Double(0.415);
|
||||||
|
break;
|
||||||
|
case 21:
|
||||||
|
res = new Double(0.425);
|
||||||
|
break;
|
||||||
|
case 22:
|
||||||
|
res = new Double(0.434);
|
||||||
|
break;
|
||||||
|
case 23:
|
||||||
|
res = new Double(0.443);
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
res = new Double(0.451);
|
||||||
|
break;
|
||||||
|
//大于等于25 都是用0.459
|
||||||
|
default :
|
||||||
|
res = new Double(0.459);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Double getD4(Integer sampleSize){
|
||||||
|
if(sampleSize<=1){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Double res = null;
|
||||||
|
switch(sampleSize){
|
||||||
|
//P92
|
||||||
|
case 2:
|
||||||
|
res = new Double(3.267);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
res = new Double(2.574);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
res = new Double(2.282);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
res = new Double(2.114);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
res = new Double(2.004);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
res = new Double(1.924);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
res = new Double(1.864);
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
res = new Double(1.816);
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
res = new Double(1.777);
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
res = new Double(1.744);
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
res = new Double(1.717);
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
res = new Double(1.693);
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
res = new Double(1.672);
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
res = new Double(1.653);
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
res = new Double(1.637);
|
||||||
|
break;
|
||||||
|
case 17:
|
||||||
|
res = new Double(1.622);
|
||||||
|
break;
|
||||||
|
case 18:
|
||||||
|
res = new Double(1.608);
|
||||||
|
break;
|
||||||
|
case 19:
|
||||||
|
res = new Double(1.597);
|
||||||
|
break;
|
||||||
|
case 20:
|
||||||
|
res = new Double(1.585);
|
||||||
|
break;
|
||||||
|
case 21:
|
||||||
|
res = new Double(1.575);
|
||||||
|
break;
|
||||||
|
case 22:
|
||||||
|
res = new Double(1.566);
|
||||||
|
break;
|
||||||
|
case 23:
|
||||||
|
res = new Double(1.557);
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
res = new Double(1.548);
|
||||||
|
break;
|
||||||
|
//大于等于25 都是用1.541
|
||||||
|
default :
|
||||||
|
res = new Double(1.541);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,257 @@
|
|||||||
|
package com.cnbm.qualityPlanning.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Desc: " "x bar - s" 控制系数 "
|
||||||
|
* @Author: caixiang
|
||||||
|
* @DATE: 2022/6/30 10:44
|
||||||
|
*/
|
||||||
|
public class XBarSCoefficients {
|
||||||
|
public static Double getAS(Integer sampleSize){
|
||||||
|
if(sampleSize<=1){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Double res = null;
|
||||||
|
switch(sampleSize){
|
||||||
|
case 2:
|
||||||
|
res = new Double(2.659);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
res = new Double(1.954);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
res = new Double(1.628);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
res = new Double(1.427);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
res = new Double(1.287);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
res = new Double(1.182);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
res = new Double(1.099);
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
res = new Double(1.032);
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
res = new Double(0.975);
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
res = new Double(0.972);
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
res = new Double(0.866);
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
res = new Double(0.850);
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
res = new Double(0.817);
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
res = new Double(0.789);
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
res = new Double(0.763);
|
||||||
|
break;
|
||||||
|
case 17:
|
||||||
|
res = new Double(0.739);
|
||||||
|
break;
|
||||||
|
case 18:
|
||||||
|
res = new Double(0.718);
|
||||||
|
break;
|
||||||
|
case 19:
|
||||||
|
res = new Double(0.698);
|
||||||
|
break;
|
||||||
|
case 20:
|
||||||
|
res = new Double(0.680);
|
||||||
|
break;
|
||||||
|
case 21:
|
||||||
|
res = new Double(0.663);
|
||||||
|
break;
|
||||||
|
case 22:
|
||||||
|
res = new Double(0.647);
|
||||||
|
break;
|
||||||
|
case 23:
|
||||||
|
res = new Double(0.633);
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
res = new Double(0.619);
|
||||||
|
break;
|
||||||
|
//大于等于25 都是用0.606
|
||||||
|
default :
|
||||||
|
res = new Double(0.606);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Double getBU(Integer sampleSize){
|
||||||
|
if(sampleSize<=1){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Double res = null;
|
||||||
|
switch(sampleSize){
|
||||||
|
case 2:
|
||||||
|
res = new Double(3.267);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
res = new Double(2.568);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
res = new Double(2.266);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
res = new Double(2.089);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
res = new Double(1.970);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
res = new Double(1.882);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
res = new Double(1.815);
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
res = new Double(1.761);
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
res = new Double(1.716);
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
res = new Double(1.679);
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
res = new Double(1.646);
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
res = new Double(1.618);
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
res = new Double(1.594);
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
res = new Double(1.572);
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
res = new Double(1.552);
|
||||||
|
break;
|
||||||
|
case 17:
|
||||||
|
res = new Double(1.534);
|
||||||
|
break;
|
||||||
|
case 18:
|
||||||
|
res = new Double(1.518);
|
||||||
|
break;
|
||||||
|
case 19:
|
||||||
|
res = new Double(1.503);
|
||||||
|
break;
|
||||||
|
case 20:
|
||||||
|
res = new Double(1.490);
|
||||||
|
break;
|
||||||
|
case 21:
|
||||||
|
res = new Double(1.477);
|
||||||
|
break;
|
||||||
|
case 22:
|
||||||
|
res = new Double(1.466);
|
||||||
|
break;
|
||||||
|
case 23:
|
||||||
|
res = new Double(1.455);
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
res = new Double(1.445);
|
||||||
|
break;
|
||||||
|
//大于等于25 都是用1.435
|
||||||
|
default :
|
||||||
|
res = new Double(1.435);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Double getBL(Integer sampleSize){
|
||||||
|
if(sampleSize<=1){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Double res = null;
|
||||||
|
switch(sampleSize){
|
||||||
|
case 2:
|
||||||
|
res = new Double(0);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
res = new Double(0);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
res = new Double(0);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
res = new Double(0);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
res = new Double(0.030);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
res = new Double(0.118);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
res = new Double(0.185);
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
res = new Double(0.239);
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
res = new Double(0.284);
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
res = new Double(0.321);
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
res = new Double(0.354);
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
res = new Double(0.382);
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
res = new Double(0.406);
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
res = new Double(0.428);
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
res = new Double(0.448);
|
||||||
|
break;
|
||||||
|
case 17:
|
||||||
|
res = new Double(0.466);
|
||||||
|
break;
|
||||||
|
case 18:
|
||||||
|
res = new Double(0.482);
|
||||||
|
break;
|
||||||
|
case 19:
|
||||||
|
res = new Double(0.497);
|
||||||
|
break;
|
||||||
|
case 20:
|
||||||
|
res = new Double(0.510);
|
||||||
|
break;
|
||||||
|
case 21:
|
||||||
|
res = new Double(0.523);
|
||||||
|
break;
|
||||||
|
case 22:
|
||||||
|
res = new Double(0.534);
|
||||||
|
break;
|
||||||
|
case 23:
|
||||||
|
res = new Double(0.545);
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
res = new Double(0.555);
|
||||||
|
break;
|
||||||
|
//大于等于25 都是用0.565
|
||||||
|
default :
|
||||||
|
res = new Double(0.565);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.cnbm.qualityPlanning.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Desc: ""
|
||||||
|
* @Author: caixiang
|
||||||
|
* @DATE: 2022/7/12 15:17
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ControlLimit {
|
||||||
|
//控制上限
|
||||||
|
private Double UCL;
|
||||||
|
//控制中心线
|
||||||
|
private Double CL;
|
||||||
|
//控制下限
|
||||||
|
private Double LCL;
|
||||||
|
|
||||||
|
public ControlLimit(Double UCL,Double CL,Double LCL){
|
||||||
|
this.UCL = UCL;
|
||||||
|
this.CL = CL;
|
||||||
|
this.LCL = LCL;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.cnbm.qualityPlanning.entity;
|
||||||
|
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Desc: ""
|
||||||
|
* @Author: caixiang
|
||||||
|
* @DATE: 2022/7/12 15:12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Point {
|
||||||
|
private Integer position;
|
||||||
|
private Double value;
|
||||||
|
|
||||||
|
//不满足的 规则 例子 : [1,2] => 代表 不满足 规则1 和 规则2
|
||||||
|
private Set<Integer> unsatisfiedRules;
|
||||||
|
|
||||||
|
public Point(Integer position , Double value){
|
||||||
|
this.position = position;
|
||||||
|
this.value = value;
|
||||||
|
this.unsatisfiedRules = new HashSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.cnbm.qualityPlanning.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Desc: ""
|
||||||
|
* @Author: caixiang
|
||||||
|
* @DATE: 2022/7/12 15:19
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SpecificationLimit {
|
||||||
|
//规格上限
|
||||||
|
private Double USL;
|
||||||
|
//规格中心线
|
||||||
|
private Double SL;
|
||||||
|
//规格下限
|
||||||
|
private Double LSL;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user