From 2b340111292201a410884f96253fc364aaa8fd13 Mon Sep 17 00:00:00 2001 From: caixiang <939387484@qq.com> Date: Wed, 20 Jul 2022 15:33:30 +0800 Subject: [PATCH] mark for pull --- pom.xml | 1 + .../java/com/cnbm/common/vo/ApiErrorCode.java | 105 +++++++++++ .../java/com/cnbm/common/vo/CommonVo.java | 78 ++++++++ .../java/com/cnbm/common/vo/DictDataVo.java | 24 +++ .../java/com/cnbm/common/vo/IErrorCode.java | 63 +++++++ .../java/com/cnbm/common/vo/IdListVo.java | 33 ++++ .../main/java/com/cnbm/common/vo/IdVo.java | 32 ++++ .../src/main/java/com/cnbm/common/vo/R.java | 102 +++++++++++ .../java/com/cnbm/common/vo/SelectVo.java | 26 +++ .../com/cnbm/common/vo/SmsSignCodeVo.java | 26 +++ .../java/com/cnbm/common/vo/WhetherVo.java | 30 ++++ ym-gateway/pom.xml | 8 +- .../java/com/cnbm/config/SwaggerConfig.java | 16 ++ .../cnbm/generator/build/CodeGenerator.java | 2 +- .../influx/controller/S7DemoController.java | 2 - ym-process-inspection/pom.xml | 36 ++++ .../XBarRCoefficients.java | 2 +- .../XBarSCoefficients.java | 3 +- .../MeanStandardDeviationGraph.java | 46 +++++ .../common/StatisticalControlledTest.java | 167 +++++++++++++++--- 20 files changed, 767 insertions(+), 35 deletions(-) create mode 100644 ym-common/src/main/java/com/cnbm/common/vo/ApiErrorCode.java create mode 100644 ym-common/src/main/java/com/cnbm/common/vo/CommonVo.java create mode 100644 ym-common/src/main/java/com/cnbm/common/vo/DictDataVo.java create mode 100644 ym-common/src/main/java/com/cnbm/common/vo/IErrorCode.java create mode 100644 ym-common/src/main/java/com/cnbm/common/vo/IdListVo.java create mode 100644 ym-common/src/main/java/com/cnbm/common/vo/IdVo.java create mode 100644 ym-common/src/main/java/com/cnbm/common/vo/R.java create mode 100644 ym-common/src/main/java/com/cnbm/common/vo/SelectVo.java create mode 100644 ym-common/src/main/java/com/cnbm/common/vo/SmsSignCodeVo.java create mode 100644 ym-common/src/main/java/com/cnbm/common/vo/WhetherVo.java create mode 100644 ym-process-inspection/pom.xml rename {ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/constant => ym-process-inspection/src/main/java/com/cnbm/processInspection/controlCoefficientConstant}/XBarRCoefficients.java (99%) rename {ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/constant => ym-process-inspection/src/main/java/com/cnbm/processInspection/controlCoefficientConstant}/XBarSCoefficients.java (98%) create mode 100644 ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/MeanStandardDeviationGraph.java diff --git a/pom.xml b/pom.xml index 2858adf..a12076f 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,7 @@ ym-schedule-task ym-influx ym-quality-planning + ym-process-inspection pom diff --git a/ym-common/src/main/java/com/cnbm/common/vo/ApiErrorCode.java b/ym-common/src/main/java/com/cnbm/common/vo/ApiErrorCode.java new file mode 100644 index 0000000..e5ce8fe --- /dev/null +++ b/ym-common/src/main/java/com/cnbm/common/vo/ApiErrorCode.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.cnbm.common.vo; + + +/** + * REST API 错误码 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +public enum ApiErrorCode implements IErrorCode { + + /** + * 成功 + */ + SUCCESSFUL(CODE_SUCCESSFUL, "成功"), + /** + * 失败 + */ + FAILED(CODE_FAILED, "失败"), + /** + * 无效的请求参数 + */ + //INVALID_PARAMETER(CODE_INVALID_PARAMETER, "无效的请求参数"), + INVALID_PARAMETER(CODE_INVALID_PARAMETER, "Invalid request parameter"), + /** + * 数据未授权 + */ + FORBIDDEN_DATA(CODE_FORBIDDEN_DATA, "数据未授权"), + /** + * 用户已存在 + */ + USER_EXISTENT(CODE_USER_EXISTENT, "用户已存在"), + /** + * 用户不存在 + */ + //USER_NON_EXISTENT(CODE_USER_NON_EXISTENT, "用户不存在"), + USER_NON_EXISTENT(CODE_USER_NON_EXISTENT, "User does not exist"), + /** + * 用户已停用 + */ + USER_DISABLED(CODE_FAILED, "用户已停用"), + /** + * 用户不存在或密码错误 + */ + USER_NON_EXISTENT_OR_INVALID_PASSWORD(CODE_FAILED, "The user does not exist or the password is wrong"), + //USER_NON_EXISTENT_OR_INVALID_PASSWORD(CODE_FAILED, "用户不存在或密码错误"), + /** + * 密码错误 + */ + //INVALID_PASSWORD(CODE_FAILED, "密码错误"), + INVALID_PASSWORD(CODE_FAILED, "Wrong password"), + + /** + * 电话号码不能为空 + */ + MOBILE_IS_EMPTY(CODE_FAILED, "手机号码不能为空"), + + /** + * 用户未登录 + */ + UNAUTHORIZED(CODE_UNAUTHORIZED, "用户未登录"), + /** + * 用户未授权 + */ + FORBIDDEN(CODE_FORBIDDEN, "用户未授权"); + + private final int code; + private final String msg; + + ApiErrorCode(final int code, final String msg) { + this.code = code; + this.msg = msg; + } + + public static ApiErrorCode fromCode(int code) { + ApiErrorCode[] apiErrorCodes = ApiErrorCode.values(); + for (ApiErrorCode apiErrorCode : apiErrorCodes) { + if (apiErrorCode.getCode() == code) { + return apiErrorCode; + } + } + return SUCCESSFUL; + } + + @Override + public int getCode() { + return code; + } + + @Override + public String getMsg() { + return msg; + } + + @Override + public String toString() { + return String.format(" ErrorCode:{code=%s, msg=%s} ", code, msg); + } +} diff --git a/ym-common/src/main/java/com/cnbm/common/vo/CommonVo.java b/ym-common/src/main/java/com/cnbm/common/vo/CommonVo.java new file mode 100644 index 0000000..293e963 --- /dev/null +++ b/ym-common/src/main/java/com/cnbm/common/vo/CommonVo.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.cnbm.common.vo; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.time.LocalDateTime; + +/** + * 公共视图对象 + * + * @author jiff + * @date 2018/11/9 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@ApiModel("公共视图对象") +public class CommonVo { + + /** + * 启用状态:0 、停用,1、启用 + */ + @ApiModelProperty(value = "启用状态:0 、停用,1、启用", example = "1", position = Integer.MAX_VALUE - 1) + private Integer enabled; + + /** + * 备注 + */ + @ApiModelProperty(value = "备注", position = Integer.MAX_VALUE - 1) + private String remark; + + + /** + * 创建人 + */ + @ApiModelProperty(value = "创建人", example = "1", position = Integer.MAX_VALUE) + private Long creatorId; + + /** + * 创建人姓名 + */ + @ApiModelProperty(value = "创建人姓名", example = "ulabcare", position = Integer.MAX_VALUE) + private String creatorName; + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间", position = Integer.MAX_VALUE) + private LocalDateTime createTime; + + /** + * 更新人 + */ + @ApiModelProperty(value = "更新人", example = "1", position = Integer.MAX_VALUE) + private Long updaterId; + + /** + * 更新人姓名 + */ + @ApiModelProperty(value = "更新人姓名", example = "ulabcare", position = Integer.MAX_VALUE) + private String updaterName; + + /** + * 更新时间 + */ + @ApiModelProperty(value = "更新时间", position = Integer.MAX_VALUE) + private LocalDateTime updateTime; + +} diff --git a/ym-common/src/main/java/com/cnbm/common/vo/DictDataVo.java b/ym-common/src/main/java/com/cnbm/common/vo/DictDataVo.java new file mode 100644 index 0000000..5f8eb37 --- /dev/null +++ b/ym-common/src/main/java/com/cnbm/common/vo/DictDataVo.java @@ -0,0 +1,24 @@ +package com.cnbm.common.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + *

+ * + *

+ * + * @author FanYi + * @date 2020/7/6 + * @since 1.0 + */ +@ApiModel("字典值对象") +@Data +public class DictDataVo { + @ApiModelProperty("字典编码") + private String code; + + @ApiModelProperty("字典名称") + private String name; +} diff --git a/ym-common/src/main/java/com/cnbm/common/vo/IErrorCode.java b/ym-common/src/main/java/com/cnbm/common/vo/IErrorCode.java new file mode 100644 index 0000000..24b1b92 --- /dev/null +++ b/ym-common/src/main/java/com/cnbm/common/vo/IErrorCode.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.cnbm.common.vo; + + +/** + * api错误码定义 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +public interface IErrorCode { + /** + * 成功 + */ + int CODE_SUCCESSFUL = 0; + /** + * 失败 + */ + int CODE_FAILED = 1; + /** + * 无效的请求参数 + */ + int CODE_INVALID_PARAMETER = 2; + /** + * 数据未授权 + */ + int CODE_FORBIDDEN_DATA = 9; + /** + * 用户已存在 + */ + int CODE_USER_EXISTENT = 10; + /** + * 用户不存在 + */ + int CODE_USER_NON_EXISTENT = 11; + /** + * 用户未登录 + */ + int CODE_UNAUTHORIZED = 401; + /** + * 用户未授权 + */ + int CODE_FORBIDDEN = 403; + + /** + * 错误编码:0、成功 否则失败 + * + * @return 错误码:0、成功 否则失败 + */ + int getCode(); + + /** + * 错误描述 + * + * @return 错误描述 + */ + String getMsg(); +} diff --git a/ym-common/src/main/java/com/cnbm/common/vo/IdListVo.java b/ym-common/src/main/java/com/cnbm/common/vo/IdListVo.java new file mode 100644 index 0000000..f63cbb2 --- /dev/null +++ b/ym-common/src/main/java/com/cnbm/common/vo/IdListVo.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.cnbm.common.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.util.List; + + +/** + * 主键列表对象 + * + * @author jiff + * @date 2018/11/14 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel("主键列表视图对象") +public class IdListVo { + @ApiModelProperty(value = "主键列表", required = true, example = "[1]", notes = "根据实际接口返回不同对象的主键列表") + private List ids; +} diff --git a/ym-common/src/main/java/com/cnbm/common/vo/IdVo.java b/ym-common/src/main/java/com/cnbm/common/vo/IdVo.java new file mode 100644 index 0000000..8a31782 --- /dev/null +++ b/ym-common/src/main/java/com/cnbm/common/vo/IdVo.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.cnbm.common.vo; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + + +/** + * 主键对象 + * + * @author jiff + * @date 2018/11/7 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel("主键视图对象") +public class IdVo { + @ApiModelProperty(value = "主键", required = true, example = "1", notes = "根据实际接口返回不同对象的主键") + private Long id; +} diff --git a/ym-common/src/main/java/com/cnbm/common/vo/R.java b/ym-common/src/main/java/com/cnbm/common/vo/R.java new file mode 100644 index 0000000..752cf61 --- /dev/null +++ b/ym-common/src/main/java/com/cnbm/common/vo/R.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.cnbm.common.vo; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.*; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 处理结果类 + * + * @param 返回的数据类型 + * @author jiff + * @date 2018/11/7 + * @since 1.0 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@ToString +@ApiModel("处理结果类") +@Accessors +public class R implements Serializable { + @NonNull + @ApiModelProperty(value = "结果码", example = "0") + private int code = IErrorCode.CODE_SUCCESSFUL; + @ApiModelProperty(value = "结果说明", example = "成功") + private String msg; + @ApiModelProperty(value = "业务数据") + private T data; + + public R code(int code) { + this.code = code; + return this; + } + + public R msg(String msg) { + this.msg = msg; + return this; + } + + public R data(T data) { + this.data = data; + return this; + } + + public boolean ok() { + return code == IErrorCode.CODE_SUCCESSFUL; + } + + public static R failed() { + return failed("系统错误!"); + } + + public static R failed(String msg) { + return failed(ApiErrorCode.FAILED.getCode(), msg); + } + + public static R failed(int code, String msg) { + return failed(code, msg, null); + } + + public static R failed(int code, String msg, T data) { + return r(code == ApiErrorCode.SUCCESSFUL.getCode() ? ApiErrorCode.FAILED.getCode() : code, msg, data); + } + + public static R failed(IErrorCode errorCode) { + return r(errorCode, null); + } + + public static R r(IErrorCode errorCode, T data) { + return r(errorCode.getCode(), errorCode.getMsg(), data); + } + + public static R r(int code, String msg, T data) { + return new R().code(code).msg(msg).data(data); + } + + public static R unauthorized() { + return failed(ApiErrorCode.UNAUTHORIZED); + } + + public static R forbidden() { + return failed(ApiErrorCode.FORBIDDEN); + } + + public static R ok(T data) { + return new R().data(data); + } + + public static R ok(String msg, T data) { + return new R().msg(msg).data(data); + } + +} diff --git a/ym-common/src/main/java/com/cnbm/common/vo/SelectVo.java b/ym-common/src/main/java/com/cnbm/common/vo/SelectVo.java new file mode 100644 index 0000000..6011c7d --- /dev/null +++ b/ym-common/src/main/java/com/cnbm/common/vo/SelectVo.java @@ -0,0 +1,26 @@ +package com.cnbm.common.vo; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * + *

+ * + * @author FanYi + * @date 2020/7/6 + * @since 1.0 + */ +@ApiModel("下拉选择列表对象") +@Data +public class SelectVo { + @ApiModelProperty("key值,用于传给后端") + private Object k; + + @ApiModelProperty("value值,用于前端显示") + private Object v; +} diff --git a/ym-common/src/main/java/com/cnbm/common/vo/SmsSignCodeVo.java b/ym-common/src/main/java/com/cnbm/common/vo/SmsSignCodeVo.java new file mode 100644 index 0000000..7c8dc50 --- /dev/null +++ b/ym-common/src/main/java/com/cnbm/common/vo/SmsSignCodeVo.java @@ -0,0 +1,26 @@ +package com.cnbm.common.vo; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * + *

+ * + * @author FanYi + * @date 2020/4/28 + * @since 1.0 + */ +@Data +public class SmsSignCodeVo { + private Long sceneId; + + private String signName; + + private String templateCode; + + private Integer templateType; + + private String templateContent; +} diff --git a/ym-common/src/main/java/com/cnbm/common/vo/WhetherVo.java b/ym-common/src/main/java/com/cnbm/common/vo/WhetherVo.java new file mode 100644 index 0000000..e76068f --- /dev/null +++ b/ym-common/src/main/java/com/cnbm/common/vo/WhetherVo.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.cnbm.common.vo; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.experimental.Accessors; + + +/** + * 是否对象 + * + * @author jiff + * @date 2018/11/11 + * @since 1.0 + */ +@Data +@Accessors(chain = true) +@Builder +@ApiModel("是否对象") +public class WhetherVo { + @ApiModelProperty(value = "是否:true、是,false、否", required = true, example = "true") + private Boolean whether; +} diff --git a/ym-gateway/pom.xml b/ym-gateway/pom.xml index 46ed380..79ca07b 100644 --- a/ym-gateway/pom.xml +++ b/ym-gateway/pom.xml @@ -42,7 +42,13 @@ ym-quality-planning 1.0-SNAPSHOT - + + com.cnbm + ym-process-inspection + 1.0-SNAPSHOT + + + diff --git a/ym-gateway/src/main/java/com/cnbm/config/SwaggerConfig.java b/ym-gateway/src/main/java/com/cnbm/config/SwaggerConfig.java index c7b3426..2154162 100644 --- a/ym-gateway/src/main/java/com/cnbm/config/SwaggerConfig.java +++ b/ym-gateway/src/main/java/com/cnbm/config/SwaggerConfig.java @@ -128,6 +128,22 @@ public class SwaggerConfig { .securitySchemes(Arrays.asList(new ApiKey("token", "token", "header"))); } + @Bean + public Docket processInspectionApi() { + return new Docket(DocumentationType.SWAGGER_2) + .groupName("ym-process-inspection") + .apiInfo(apiInfos("过程检验", "过程检验模块")) + .useDefaultResponseMessages(true) + .forCodeGeneration(false) + .select() + .apis(RequestHandlerSelectors.basePackage("com.cnbm.processInspection")) + .paths(PathSelectors.any()) + .build() + .securityContexts(Arrays.asList(securityContext())) + // ApiKey的name需与SecurityReference的reference保持一致 + .securitySchemes(Arrays.asList(new ApiKey("token", "token", "header"))); + } + /** * 创建该API的基本信息(这些基本信息会展现在文档页面中) * 访问地址:http://ip:port/swagger-ui.html diff --git a/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java b/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java index 4f80800..8f5f41f 100644 --- a/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java +++ b/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java @@ -27,7 +27,7 @@ public class CodeGenerator { @Test public void test(){ - mybatisPlusGenerator(new String[]{"product_type"}); + mybatisPlusGenerator(new String[]{"product_features"}); } public static void mybatisPlusGenerator(String[] include){ diff --git a/ym-influx/src/main/java/com/cnbm/influx/controller/S7DemoController.java b/ym-influx/src/main/java/com/cnbm/influx/controller/S7DemoController.java index 02cd253..2262ff5 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/controller/S7DemoController.java +++ b/ym-influx/src/main/java/com/cnbm/influx/controller/S7DemoController.java @@ -7,14 +7,12 @@ 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.influxdb.client.InfluxDBClient; import com.influxdb.client.domain.WritePrecision; import com.influxdb.client.write.Point; import com.influxdb.query.FluxRecord; import com.influxdb.query.FluxTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/ym-process-inspection/pom.xml b/ym-process-inspection/pom.xml new file mode 100644 index 0000000..612eb5f --- /dev/null +++ b/ym-process-inspection/pom.xml @@ -0,0 +1,36 @@ + + + + ym-pass + com.cnbm + 1.0-SNAPSHOT + + 4.0.0 + + ym-process-inspection + + + 8 + 8 + + + + + com.cnbm + ym-influx + 1.0-SNAPSHOT + + + com.cnbm + ym-baisc + 1.0-SNAPSHOT + + + com.cnbm + ym-common + 1.0-SNAPSHOT + + + \ No newline at end of file diff --git a/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/constant/XBarRCoefficients.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/controlCoefficientConstant/XBarRCoefficients.java similarity index 99% rename from ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/constant/XBarRCoefficients.java rename to ym-process-inspection/src/main/java/com/cnbm/processInspection/controlCoefficientConstant/XBarRCoefficients.java index 5fba1e2..0668f1d 100644 --- a/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/constant/XBarRCoefficients.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/controlCoefficientConstant/XBarRCoefficients.java @@ -1,4 +1,4 @@ -package com.cnbm.qualityPlanning.constant; +package com.cnbm.processInspection.controlCoefficientConstant; /** * @Desc: " "x bar - R" 控制系数 " diff --git a/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/constant/XBarSCoefficients.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/controlCoefficientConstant/XBarSCoefficients.java similarity index 98% rename from ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/constant/XBarSCoefficients.java rename to ym-process-inspection/src/main/java/com/cnbm/processInspection/controlCoefficientConstant/XBarSCoefficients.java index e25f844..abacbd5 100644 --- a/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/constant/XBarSCoefficients.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/controlCoefficientConstant/XBarSCoefficients.java @@ -1,6 +1,7 @@ -package com.cnbm.qualityPlanning.constant; +package com.cnbm.processInspection.controlCoefficientConstant; /** + * 均值-标准差 控制图 常数系数 * @Desc: " "x bar - s" 控制系数 " * @Author: caixiang * @DATE: 2022/6/30 10:44 diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/MeanStandardDeviationGraph.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/MeanStandardDeviationGraph.java new file mode 100644 index 0000000..20b4c38 --- /dev/null +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/MeanStandardDeviationGraph.java @@ -0,0 +1,46 @@ +package com.cnbm.processInspection.graphAnalyzed; + +import com.cnbm.processInspection.controlCoefficientConstant.XBarSCoefficients; + +/** + * @Desc: "" + * @Author: caixiang + * @DATE: 2022/7/20 14:26 + * + * 步骤: + * ① 先读mysql表,查询 product_features 表,先读到 sample_size(样本量) + * ② 再依据 influx.argName == mysql.product_feature.name && 时间段 查询所有的 参数数据 + * ③ 拿到参数数据后,分组 整合成List, + * 计算控制限 + * 计算 母体 的 \sigma 、 bar{x} 。。。 + * 计算CPK 、CPU 、CPL这些 + * ④ 如果配置了判读方案,还要 调用 StatisticalControlledTest Function 检验。 + * ⑤ + */ + +public class MeanStandardDeviationGraph { + private Double sbar; + private Double xbarbar; + private Double as; + private Double bu; + private Double bl; + private Integer sampleSize; + private String argName; + + MeanStandardDeviationGraph(Integer sampleSize){ + this.sampleSize = sampleSize; + this.as = XBarSCoefficients.getAS(sampleSize); + this.bu = XBarSCoefficients.getBU(sampleSize); + this.bl = XBarSCoefficients.getBU(sampleSize); + } + + /** + * name : 初始化数据函数 + * desc : 从influxdb 里面读取数据,然后 加工处理成 我需要的 + * 步骤: + * ① + * */ + public void initialDate(){ + + } +} diff --git a/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/common/StatisticalControlledTest.java b/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/common/StatisticalControlledTest.java index 632d866..24b6ff5 100644 --- a/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/common/StatisticalControlledTest.java +++ b/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/common/StatisticalControlledTest.java @@ -4,13 +4,13 @@ package com.cnbm.qualityPlanning.common; import com.cnbm.qualityPlanning.entity.ControlLimit; import com.cnbm.qualityPlanning.entity.ControlLimitDetail; import com.cnbm.qualityPlanning.entity.Point; -import io.swagger.models.auth.In; import java.util.*; /** * @Desc: "检测参数统计受控 检验类" * @Author: caixiang + * todo : ① 开头第一组,和最后一组 是否漏掉 问题;② 中间情况 时候把最后一个元素漏掉。 * @DATE: 2022/7/11 15:27 */ public class StatisticalControlledTest { @@ -26,18 +26,18 @@ public class StatisticalControlledTest { private static final Integer rule10Number = 10; public static List createData(){ - Point point = new Point(1,new Double(1.7)); - Point point2 = new Point(2,new Double(8)); - Point point3 = new Point(3,new Double(8)); - Point point4 = new Point(4,new Double(1.7)); - Point point5 = new Point(5,new Double(1.7)); - Point point6 = new Point(6,new Double(1.7)); //3 - Point point7 = new Point(7,new Double(1.7)); //3 - Point point8 = new Point(8,new Double(1.7)); //3 //3 - Point point9 = new Point(9,new Double(1.7)); - Point point10 = new Point(10,new Double(1.7)); - Point point11 = new Point(11,new Double(1.7)); - Point point12 = new Point(12,new Double(1.7)); + Point point = new Point(1,new Double(0.7)); + Point point2 = new Point(2,new Double(0.7)); + Point point3 = new Point(3,new Double(3.7)); + Point point4 = new Point(4,new Double(0.7)); + Point point5 = new Point(5,new Double(0.7)); + Point point6 = new Point(6,new Double(3.7)); //3 + Point point7 = new Point(7,new Double(3.7)); //3 + Point point8 = new Point(8,new Double(3.7)); //3 //3 + Point point9 = new Point(9,new Double(3.7)); + Point point10 = new Point(10,new Double(3.7)); + Point point11 = new Point(11,new Double(3.7)); + Point point12 = new Point(12,new Double(3.7)); List list = new ArrayList<>(); list.add(point); list.add(point2); @@ -62,8 +62,8 @@ public class StatisticalControlledTest { // Boolean aBoolean1 = rule1(list, controlLimit); // //TEST FOR RULE2 - Boolean aBoolean2 = rule2(list, controlLimit, 9); - System.out.println(); +// Boolean aBoolean2 = rule2(list, controlLimit, 9); +// System.out.println(); // // // //TEST FOR RULE3 @@ -72,7 +72,7 @@ public class StatisticalControlledTest { // // // //TEST FOR RULE4 -// Boolean aBoolean4 = rule4(list, 4); +// Boolean aBoolean4 = rule4(list, 5); // System.out.println(); // //TEST FOR RULE5 @@ -88,6 +88,10 @@ public class StatisticalControlledTest { Boolean aBoolean7 = rule7(list, controlLimit,7); System.out.println(); + //TEST FOR RULE8 +// Boolean aBoolean8 = rule8(list, controlLimit,8); +// System.out.println(); + // int[] array={1,2,3,4,5,6}; // int[] ret=new int[3]; // System.arraycopy(array,0,ret,0,3); @@ -123,7 +127,6 @@ public class StatisticalControlledTest { * name : 规则2 * desc : 连续 n 点落在中心线的用一侧 (默认:9) * 注意: 如果存在满足rule2的点,会在原数组 Point.unsatisfiedRules 里标注出来。 - * //todo 存在bug while((upi+1) < data.size()){ ,最后一个点轮询不到 * return : * 存在满足rule2的点 => true * 不存在满足rule2的点 => false @@ -160,7 +163,7 @@ public class StatisticalControlledTest { //1. for (Point key:forMarkPoints){ for(Point j:data){ - if(key.getPosition()== j.getPosition()){ + if(key.getPosition().equals(j.getPosition())){ j.getUnsatisfiedRules().add(rule2Number); continue; } @@ -197,7 +200,7 @@ public class StatisticalControlledTest { for (Point key:forMarkPoints){ for(Point j:data){ - if(key.getPosition()== j.getPosition()){ + if(key.getPosition().equals(j.getPosition())){ j.getUnsatisfiedRules().add(rule2Number); continue; } @@ -280,7 +283,6 @@ public class StatisticalControlledTest { * name : 规则4 * desc : 连续 n 点中 相邻点 交替上下 ( 默认:14 ) * 注意: 如果存在满足rule4的点,会在原数组 Point.unsatisfiedRules 里标注出来。 - * //todo 有bug while((upi+1) < data.size()) 这里 upi+1 会存在问题 * return : * 存在满足rule4的点 => true * 不存在满足rule4的点 => false @@ -301,6 +303,24 @@ public class StatisticalControlledTest { while((upi+1) < data.size()){ if(isBetween( data.get(upi),data.get(upi+1) )){ + // + if(forMarkKey.size()==(n-1)){ + Double u1 = data.get(upi-2).getValue(); + Double u2 = data.get(upi-1).getValue(); + Double u3 = data.get(upi).getValue(); + if(isUpAndDown(u1,u2,u3)){ + forMarkKey.add(upi); + times++; + } + if(times >= n){ + for(Integer key:forMarkKey){ + data.get(key).getUnsatisfiedRules().add(rule4Number); + } + return true; + } + } + + //A-B<0 True //A-B>0 False if(isSmall(data.get(upi),data.get(upi+1))){ @@ -313,7 +333,19 @@ public class StatisticalControlledTest { if (current.equals(nextNeeded)){ times++; forMarkKey.add(upi); - if(times == n){ + //加入最后一个元素的判断 + if((upi+1)==(data.size()-1)){ + Double u0 = data.get(upi - 1).getValue(); + Double u1 = data.get(upi).getValue(); + Double u2 = data.get(upi + 1).getValue(); + if(isUpAndDown(u0,u1,u2)){ + forMarkKey.add(upi+1); + times++; + } + } + + + if(times >= n){ for(Integer key:forMarkKey){ data.get(key).getUnsatisfiedRules().add(rule4Number); } @@ -334,6 +366,8 @@ public class StatisticalControlledTest { return false; } + + /** * name : 规则5 * desc : 连续 m 点中 有 n 点 落在中心线同一侧,B区以外。( 默认 m:3 , n:2 ) @@ -403,7 +437,7 @@ public class StatisticalControlledTest { /** * name : 规则6 * desc : 连续 m 点中 有 n 点 落在中心线同一侧,C区以外。( 默认 m:5 , n:4 ) - * 注意: 如果存在满足rule5的点,会在原数组 Point.unsatisfiedRules 里标注出来。 + * 注意: 如果存在满足rule6的点,会在原数组 Point.unsatisfiedRules 里标注出来。 * return : * 存在满足rule6的点 => true * 不存在满足rule6的点 => false @@ -469,7 +503,7 @@ public class StatisticalControlledTest { /** * name : 规则7 * desc : 连续 n 点 落在中心线两侧的C区内。( 默认 n:15 ) - * 注意: 如果存在满足rule5的点,会在原数组 Point.unsatisfiedRules 里标注出来。 + * 注意: 如果存在满足rule7的点,会在原数组 Point.unsatisfiedRules 里标注出来。 * return : * 存在满足rule7的点 => true * 不存在满足rule7的点 => false @@ -477,7 +511,7 @@ public class StatisticalControlledTest { private static Boolean rule7(List data,ControlLimit controlLimit, Integer n){ - Integer upi = 0; + //Integer upi = 0; ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL()); System.out.println(controlLimitDetail.toString()); Integer times = 0; @@ -486,12 +520,12 @@ public class StatisticalControlledTest { for(int i=0;icontrolLimitDetail.getLC()[0] && point.getValue()controlLimitDetail.getLC()[0] && point.getValue() true + * 不存在满足rule8的点 => false + * */ + private static Boolean rule8(List data,ControlLimit controlLimit, Integer n){ + //Integer upi = 0; + ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL()); + System.out.println(controlLimitDetail.toString()); + Integer times = 0; + List markKey = new ArrayList<>(); + + + for(int i=0;icontrolLimitDetail.getUC()[1] || point.getValue()(); + } + break; + } + + //通常情况 + Point point = data.get(i); + if( isBetween( data.get(i),data.get(i+1) ) ){ + if( point.getValue()>controlLimitDetail.getUC()[1] || point.getValue()(); + } + }else { + times = 0; + markKey = new ArrayList<>(); + } + } + return false; + } + /** * 如果 这两个点是相邻的 ==》 true * */ @@ -549,4 +643,19 @@ public class StatisticalControlledTest { return (head.getValue()- after.getValue()) > 0; } + + /** + * 如果这三个参数 是起伏的 ====> true + * + * */ + private static boolean isUpAndDown(Double u1,Double u2,Double u3){ + Boolean r1 = ((u1-u2)>0); + Boolean r2 = ((u2-u3)>0); + if(!r1.equals(r2)){ + return true; + }else { + return false; + } + } + }