Merge remote-tracking branch 'origin/develop' into dev_shb

# Conflicts:
#	src/main/java/com/ai/da/service/impl/DesignServiceImpl.java
This commit is contained in:
shahaibo
2023-09-13 10:34:09 +08:00
101 changed files with 1597 additions and 346 deletions

View File

@@ -5,13 +5,22 @@ import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
@Configuration
public class WebConfig {
public class WebConfig extends WebMvcConfigurerAdapter {
static final String ORIGINS[] = new String[]{"GET", "POST", "PUT", "DELETE"};
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins("*").allowCredentials(true).allowedMethods(ORIGINS).maxAge(3600);
}
@Bean
public Validator validator() {

View File

@@ -0,0 +1,30 @@
package com.ai.da.common.enums;
import lombok.Getter;
@Getter
public enum GenerateTypeEnum {
/**
* 通过文本生成
*/
TEXT(1,"text"),
/**
* 通过图片生成
*/
IMAGE(2,"image"),
/**
* 通过文本和图片生成
*/
TEXT_IMAGE(2,"text-image");
private Integer code;
private String value;
GenerateTypeEnum(int code,String value) {
this.code = code;
this.value = value;
}
}

View File

@@ -0,0 +1,22 @@
package com.ai.da.common.enums;
import lombok.Getter;
@Getter
public enum ModelNameEnum {
/**
* 使用模型0
*/
MODEL_0("0","model_0");
private String code;
private String modelName;
ModelNameEnum(String code,String modelName) {
this.code = code;
this.modelName = modelName;
}
}

View File

@@ -4,7 +4,7 @@ import java.util.stream.Stream;
/**
* @author yanglei
* @description python调用java 操作数类型 generatePrint ->生成印花 designCollection ->设计collection
* @description python调用java 操作数类型 generatePrint ->生成印花 designCollection ->设计collection generateSketch->设计草图
* @create 2022-10-3 17:33
**/
public enum PythonToJavaApiOperationTypeEnum {
@@ -19,7 +19,12 @@ public enum PythonToJavaApiOperationTypeEnum {
/**
* 设计collection
*/
DESIGN_COLLECTION("designCollection");
DESIGN_COLLECTION("designCollection"),
/**
* 生成草图
*/
GENERATE_SKETCH("generateSketch");
private String realName;

View File

@@ -8,17 +8,12 @@ import com.ai.da.common.utils.LocalCacheUtils;
import com.ai.da.common.utils.MultiReadHttpServletRequest;
import com.ai.da.common.utils.MultiReadHttpServletResponse;
import com.ai.da.model.vo.AuthPrincipalVo;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.NonNull;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.util.StopWatch;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.annotation.Resource;
@@ -28,7 +23,6 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Statement;
import java.util.Arrays;
import java.util.List;
@@ -50,7 +44,10 @@ public class AuthenticationFilter extends OncePerRequestFilter {
Arrays.asList("/favicon.ico","/doc.html","api/account/login","api/account/preLogin","api/account/sendEmail",
"/webjars/","/swagger-resources","/v2/api-docs","api/account/resetPwd",
"/api/python/saveGeneratePicture", "/api/python/getLibraryByUserId",
"/api/third/party/addUser","/api/third/party/editUser","/api/element/initDefaultSysFile");
"/api/third/party/addUser","/api/third/party/editUser","/api/element/initDefaultSysFile",
"/api/python/chatStream",
"/api/python/flush"
);
@Override
protected void doFilterInternal(HttpServletRequest httpServletRequest, @NonNull HttpServletResponse httpServletResponse, @NonNull FilterChain filterChain) throws ServletException, IOException {

View File

@@ -0,0 +1,59 @@
package com.ai.da.common.utils;
public class PantoneUtils {
public static int[] rgbToHsv(int[] rgb) {
//切割rgb数组
int R = rgb[0];
int G = rgb[1];
int B = rgb[2];
//公式运算 /255
float R_1 = R / 255f;
float G_1 = G / 255f;
float B_1 = B / 255f;
//重新拼接运算用数组
float[] all = {R_1, G_1, B_1};
float max = all[0];
float min = all[0];
//循环查找最大值和最小值
for (int i = 0; i < all.length; i++) {
if (max <= all[i]) {
max = all[i];
}
if (min >= all[i]) {
min = all[i];
}
}
float C_max = max;
float C_min = min;
//计算差值
float diff = C_max - C_min;
float hue = 0f;
//判断情况计算色调H
if (diff == 0f) {
hue = 0f;
} else {
if (C_max == R_1) {
hue = (((G_1 - B_1) / diff) % 6) * 60f;
}
if (C_max == G_1) {
hue = (((B_1 - R_1) / diff) + 2f) * 60f;
}
if (C_max == B_1) {
hue = (((R_1 - G_1) / diff) + 4f) * 60f;
}
}
//计算饱和度S
float saturation;
if (C_max == 0f) {
saturation = 0f;
} else {
saturation = diff / C_max;
}
//计算明度V
float value = C_max;
int[] result = {Math.round(hue), Math.round(saturation * 100), Math.round(value * 100)};
return result;
}
}