Merge remote-tracking branch 'origin/dev/dev' into dev/dev
This commit is contained in:
@@ -66,6 +66,7 @@ public class AccountTask {
|
||||
}
|
||||
|
||||
/**
|
||||
* !!关闭此定时器!!不再从Code-Create上默认创建AiDA游客
|
||||
* 将Code-Create上注册的用户添加为AiDA的游客
|
||||
*/
|
||||
// @Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
|
||||
|
||||
@@ -28,4 +28,70 @@ public class PantoneUtils {
|
||||
return new int[]{Math.round(hsv[0]), Math.round(hsv[1] * 100), Math.round(hsv[2] * 100)};
|
||||
}
|
||||
|
||||
public static int[] hsvToRgb(int h, int s, int v) {
|
||||
// 确保 h 在 [0, 360) 范围内
|
||||
h = h % 360;
|
||||
if (h < 0) {
|
||||
h += 360;
|
||||
}
|
||||
|
||||
// 确保 s 和 v 在 [0, 100] 范围内
|
||||
s = Math.max(0, Math.min(100, s));
|
||||
v = Math.max(0, Math.min(100, v));
|
||||
|
||||
// 将 s 和 v 映射到 [0, 1] 范围
|
||||
float sNorm = s / 100.0f;
|
||||
float vNorm = v / 100.0f;
|
||||
|
||||
// 计算色相所在的区间
|
||||
int hi = (h / 60) % 6;
|
||||
float f = (h / 60.0f) - hi;
|
||||
float p = vNorm * (1 - sNorm);
|
||||
float q = vNorm * (1 - f * sNorm);
|
||||
float t = vNorm * (1 - (1 - f) * sNorm);
|
||||
|
||||
float r, g, b;
|
||||
switch (hi) {
|
||||
case 0:
|
||||
r = vNorm;
|
||||
g = t;
|
||||
b = p;
|
||||
break;
|
||||
case 1:
|
||||
r = q;
|
||||
g = vNorm;
|
||||
b = p;
|
||||
break;
|
||||
case 2:
|
||||
r = p;
|
||||
g = vNorm;
|
||||
b = t;
|
||||
break;
|
||||
case 3:
|
||||
r = p;
|
||||
g = q;
|
||||
b = vNorm;
|
||||
break;
|
||||
case 4:
|
||||
r = t;
|
||||
g = p;
|
||||
b = vNorm;
|
||||
break;
|
||||
case 5:
|
||||
r = vNorm;
|
||||
g = p;
|
||||
b = q;
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Invalid HSV values");
|
||||
}
|
||||
|
||||
// 将 RGB 值从 [0, 1] 转换为 [0, 255]
|
||||
int red = Math.round(r * 255);
|
||||
int green = Math.round(g * 255);
|
||||
int blue = Math.round(b * 255);
|
||||
|
||||
return new int[]{red, green, blue};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@@ -43,4 +42,15 @@ public class PantoneVO {
|
||||
this.name = name;
|
||||
this.tcx = tcx;
|
||||
}
|
||||
|
||||
public PantoneVO(Integer r, Integer g, Integer b, Integer h, Integer s, Integer v) {
|
||||
this.r = r;
|
||||
this.g = g;
|
||||
this.b = b;
|
||||
this.h = h;
|
||||
this.s = s;
|
||||
this.v = v;
|
||||
this.name = "--";
|
||||
this.tcx = "--";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1338,6 +1338,8 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
|
||||
@Override
|
||||
public DesignItemDetailVO detail(Long designPythonOutfitId, Long designItemId) {
|
||||
log.info("获取design detail -> 【designPythonOutfitId : {}, designItemId : {}】 ", designPythonOutfitId, designItemId);
|
||||
|
||||
// 1、校验
|
||||
DesignItem designItem = designItemService.getById(designItemId);
|
||||
if (Objects.isNull(designItem)) {
|
||||
@@ -1590,6 +1592,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
designItemDetailVO.setDesignItemUrl(designItemUrl);
|
||||
}
|
||||
|
||||
log.info("获取DesignDetail, response: {}", JSONObject.toJSONString(designItemDetailVO));
|
||||
return designItemDetailVO;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,7 +45,7 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
|
||||
queryWrapper.eq("pantone_index", colorLookupTable.getColorIndex());
|
||||
PanTone panTone = panToneMapper.selectOne(queryWrapper);
|
||||
if (Objects.isNull(panTone)) {
|
||||
throw new BusinessException("pantone.not.found");
|
||||
return null;
|
||||
}
|
||||
return coverPanToneToVo(panTone);
|
||||
}
|
||||
@@ -73,8 +73,7 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
|
||||
|
||||
@Override
|
||||
public Map<String, PantoneVO> getPantoneByRgbBatch(List<String> colors) {
|
||||
|
||||
HashMap<Integer, String> colorValueRgb = new HashMap<>();
|
||||
/*HashMap<Integer, String> colorValueRgb = new HashMap<>();
|
||||
HashMap<Integer, String> colorIndexRgb = new HashMap<>();
|
||||
ArrayList<Integer> values = new ArrayList<>();
|
||||
colors.forEach(color -> {
|
||||
@@ -91,12 +90,11 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
|
||||
colorIndexRgb.put(colorValue.getColorIndex(), colorValueRgb.get(colorValue.getColorValue()));
|
||||
});
|
||||
|
||||
List<PanTone> panTones = panToneService.listByIds(colorIndexRgb.keySet());
|
||||
List<PanTone> panTones = panToneService.listByIds(colorIndexRgb.keySet()); // pantone数据不完整,导致有的index无对应pantone值
|
||||
ArrayList<PantoneVO> pantoneVOS = new ArrayList<>();
|
||||
panTones.forEach(panTone -> {
|
||||
pantoneVOS.add(coverPanToneToVo(panTone));
|
||||
});
|
||||
|
||||
HashMap<String, PantoneVO> colorPantoneVO = new HashMap<>();
|
||||
pantoneVOS.forEach(pantoneVO -> {
|
||||
int colorIndex = pantoneVO.getId();
|
||||
@@ -109,7 +107,6 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
|
||||
colorPantoneVO.put(colorIndexRgb.get(pantoneVO.getId()), pantoneVO);
|
||||
}
|
||||
});
|
||||
|
||||
// 覆盖pantone中的rgb值,使用前端传过来的rgb值
|
||||
for (Map.Entry<String, PantoneVO> pantoneVOEntry : colorPantoneVO.entrySet()) {
|
||||
int[] rgb = Arrays.stream(pantoneVOEntry.getKey().split("\\s+")).mapToInt(Integer::parseInt).toArray();
|
||||
@@ -117,6 +114,60 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
|
||||
pantoneVOEntry.getValue().setG(rgb[1]);
|
||||
pantoneVOEntry.getValue().setB(rgb[2]);
|
||||
}
|
||||
return colorPantoneVO;*/
|
||||
// 用于存储 RGB 值对应的 HSV 计算值
|
||||
Map<Integer, String> colorValueRgb = new HashMap<>();
|
||||
// 用于存储 ColorIndex 对应的 RGB 值
|
||||
Map<Integer, String> colorIndexRgb = new HashMap<>();
|
||||
// 存储所有计算出的 HSV 值
|
||||
List<Integer> values = new ArrayList<>();
|
||||
|
||||
// 1. 遍历 colors,计算 HSV 值并存储
|
||||
colors.forEach(color -> {
|
||||
int[] rgb = Arrays.stream(color.split("\\s+")).mapToInt(Integer::parseInt).toArray();
|
||||
int[] hsv = PantoneUtils.rgbToHsv(rgb);
|
||||
int value = (hsv[0] * 101 * 101) + (hsv[1] * 101) + hsv[2];
|
||||
colorValueRgb.put(value, color);
|
||||
values.add(value);
|
||||
});
|
||||
|
||||
// 2. 查询 ColorLookupTable 数据
|
||||
List<ColorLookupTable> colorValueList = colorLoopUpTableService.getByColorValueList(values);
|
||||
colorValueList.forEach(colorValue -> {
|
||||
colorIndexRgb.put(colorValue.getColorIndex(), colorValueRgb.get(colorValue.getColorValue()));
|
||||
});
|
||||
|
||||
// 3. 查询 Pantone 数据
|
||||
Set<Integer> colorIndexes = colorIndexRgb.keySet();
|
||||
List<PanTone> panTones = panToneService.listByIds(colorIndexes);
|
||||
|
||||
// 4. 将 PanTone 转换为 PantoneVO,并处理缺失的 Pantone 数据
|
||||
Map<Integer, PantoneVO> pantoneVOMap = new HashMap<>();
|
||||
panTones.forEach(panTone -> {
|
||||
pantoneVOMap.put(panTone.getPantoneIndex(), coverPanToneToVo(panTone));
|
||||
});
|
||||
|
||||
// 5. 处理缺失的 Pantone 数据,创建默认的 PantoneVO
|
||||
for (Integer colorIndex : colorIndexes) {
|
||||
if (!pantoneVOMap.containsKey(colorIndex)) {
|
||||
String rgbValue = colorIndexRgb.get(colorIndex);
|
||||
int[] rgb = Arrays.stream(rgbValue.split("\\s+")).mapToInt(Integer::parseInt).toArray();
|
||||
PantoneVO defaultPantoneVO = new PantoneVO();
|
||||
defaultPantoneVO.setR(rgb[0]);
|
||||
defaultPantoneVO.setG(rgb[1]);
|
||||
defaultPantoneVO.setB(rgb[2]);
|
||||
pantoneVOMap.put(colorIndex, defaultPantoneVO);
|
||||
}
|
||||
}
|
||||
|
||||
// 6. 构建最终结果
|
||||
Map<String, PantoneVO> colorPantoneVO = new HashMap<>();
|
||||
for (Map.Entry<Integer, PantoneVO> entry : pantoneVOMap.entrySet()) {
|
||||
Integer colorIndex = entry.getKey();
|
||||
PantoneVO pantoneVO = entry.getValue();
|
||||
String rgbValue = colorIndexRgb.get(colorIndex);
|
||||
colorPantoneVO.put(rgbValue, pantoneVO);
|
||||
}
|
||||
|
||||
return colorPantoneVO;
|
||||
}
|
||||
@@ -125,16 +176,19 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
|
||||
@Override
|
||||
public PantoneVO getPantoneByRgb(String color) {
|
||||
GetRgbByHsvBatchDTO getRgbByHsvBatchDTO = new GetRgbByHsvBatchDTO();
|
||||
int[] rgb = Arrays.stream(color.split("\\s+")).mapToInt(Integer::parseInt).toArray();
|
||||
int[] hsv = PantoneUtils.rgbToHsv(rgb);
|
||||
if (!StringUtil.isNullOrEmpty(color)) {
|
||||
int[] rgb = Arrays.stream(color.split("\\s+")).mapToInt(Integer::parseInt).toArray();
|
||||
int[] hsv = PantoneUtils.rgbToHsv(rgb);
|
||||
|
||||
getRgbByHsvBatchDTO.setH(hsv[0]);
|
||||
getRgbByHsvBatchDTO.setS(hsv[1]);
|
||||
getRgbByHsvBatchDTO.setV(hsv[2]);
|
||||
}
|
||||
|
||||
return getByHSV(getRgbByHsvBatchDTO.getH(), getRgbByHsvBatchDTO.getS(), getRgbByHsvBatchDTO.getV());
|
||||
PantoneVO pantoneVO = getByHSV(getRgbByHsvBatchDTO.getH(), getRgbByHsvBatchDTO.getS(), getRgbByHsvBatchDTO.getV());
|
||||
if (Objects.isNull(pantoneVO)) {
|
||||
pantoneVO = new PantoneVO(rgb[0], rgb[1], rgb[2], hsv[0], hsv[1], hsv[2]);
|
||||
}
|
||||
return pantoneVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -164,7 +218,12 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
|
||||
QueryWrapper<PanTone> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("pantone_index", colorLookupTables.stream()
|
||||
.map(ColorLookupTable::getColorIndex).collect(Collectors.toList()));
|
||||
return coverPanToneToVoList(panToneMapper.selectList(queryWrapper), IndexToValue, valueToHsv, hsvBatch);
|
||||
List<PantoneVO> pantoneVOS = coverPanToneToVoList(panToneMapper.selectList(queryWrapper), IndexToValue, valueToHsv, hsvBatch);
|
||||
if (pantoneVOS.isEmpty() && hsvBatch.size() == 1){
|
||||
int[] rgb = PantoneUtils.hsvToRgb(hsvBatch.get(0).getH(), hsvBatch.get(0).getS(), hsvBatch.get(0).getV());
|
||||
pantoneVOS.add(new PantoneVO(rgb[0], rgb[1], rgb[2], hsvBatch.get(0).getH(), hsvBatch.get(0).getS(), hsvBatch.get(0).getV()));
|
||||
}
|
||||
return pantoneVOS;
|
||||
}
|
||||
|
||||
private PantoneVO coverPanToneToVo(PanTone panTone) {
|
||||
@@ -183,7 +242,8 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
|
||||
, Map<Integer, Integer> indexToValue, Map<Integer, GetRgbByHsvBatchDTO> valueToHsv,
|
||||
List<GetRgbByHsvBatchDTO> hsvBatch) {
|
||||
if (CollectionUtil.isEmpty(panTones)) {
|
||||
throw new BusinessException("panTones.not.found", ResultEnum.PROMPT.getCode());
|
||||
return Lists.newArrayList();
|
||||
// throw new BusinessException("panTones.not.found", ResultEnum.PROMPT.getCode());
|
||||
}
|
||||
List<PantoneVO> templateResposne = CopyUtil.copyList(panTones, PantoneVO.class, (o, d) -> {
|
||||
d.setId(o.getPantoneIndex());
|
||||
|
||||
@@ -34,17 +34,17 @@ paypal.webhook_id=1D107312EX592781K
|
||||
#stripe.webhook-sign-secret=whsec_TJcMSnAkh4uktrNY1M6Iy8XaVze4Rzqm
|
||||
|
||||
# kim - test
|
||||
stripe.private-key=sk_test_51LwPrxH7nPZ8bkrNj67TFD7sxucaTANs1lf0KGSu1QSJfxYXcnigq2wTaZyZzST7y0fMbhhvaJZ4LjjFhr95M83a00eXrmOTL0
|
||||
#stripe.private-key=sk_test_51LwPrxH7nPZ8bkrNj67TFD7sxucaTANs1lf0KGSu1QSJfxYXcnigq2wTaZyZzST7y0fMbhhvaJZ4LjjFhr95M83a00eXrmOTL0
|
||||
# prod 端点
|
||||
#stripe.webhook-sign-secret=whsec_GoyVEAaBtuGD5Rt55z83JnPnLDAZTN3u
|
||||
# local 端点
|
||||
#stripe.webhook-sign-secret=whsec_NvwM3hDQiN5GXclYOYekE9IKHLjmROF8
|
||||
# dev 端点
|
||||
stripe.webhook-sign-secret=whsec_pX0pPMQm85PaUSWnFMEzoccb3MGNkjoL
|
||||
#stripe.webhook-sign-secret=whsec_pX0pPMQm85PaUSWnFMEzoccb3MGNkjoL
|
||||
|
||||
# kim - live
|
||||
#stripe.private-key=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
|
||||
stripe.private-key=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
|
||||
# prod 端点
|
||||
#stripe.webhook-sign-secret=whsec_hhGDgdelQRHSg4LmChtQe41crj41eb11
|
||||
stripe.webhook-sign-secret=whsec_hhGDgdelQRHSg4LmChtQe41crj41eb11
|
||||
# dev 端点
|
||||
#stripe.webhook-sign-secret=whsec_cFUtjUOo8wnrIKZmt4GNvt7ZY1bOfrYr
|
||||
|
||||
Reference in New Issue
Block a user