TASK:模块化;

This commit is contained in:
shahaibo
2025-03-28 11:05:45 +08:00
parent bb00d9a714
commit 63513df053
4 changed files with 38 additions and 9 deletions

View File

@@ -32,4 +32,6 @@ public class ProductImageAttribute implements Serializable {
private String subtype;
private String style;
private Long libraryId;
}

View File

@@ -1,5 +1,6 @@
package com.ai.da.mapper.secondary.entity;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@@ -7,16 +8,39 @@ import java.util.List;
@Data
public class AttributeRecognitionJSON {
private Long id;
@JsonProperty("img_name")
private List<String> imgName;
@JsonProperty("length")
private List<String> length;
@JsonProperty("sleeve_length")
private List<String> sleeveLength;
@JsonProperty("sleeve_shape")
private List<String> sleeveShape;
@JsonProperty("sleeve_shoulder")
private List<String> sleeveShoulder;
@JsonProperty("neckline")
private List<String> neckline;
@JsonProperty("collar")
private List<String> collar;
@JsonProperty("design")
private List<String> design;
@JsonProperty("silhouette")
private List<String> silhouette;
@JsonProperty("type")
private List<String> type;
@JsonProperty("opening_type")
private List<String> openingType;
@JsonProperty("subtype")
private List<String> subtype;
}

View File

@@ -163,7 +163,9 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
QueryWrapper<BrandRelLibrary> qw = new QueryWrapper<>();
qw.lambda().eq(BrandRelLibrary::getBrandId, query.getBrandId());
Set<Long> collect = brandRelLibraryMapper.selectList(qw).stream().map(BrandRelLibrary::getLibraryId).collect(Collectors.toSet());
queryWrapper.in("id", collect);
if (!CollectionUtils.isEmpty(collect)) {
queryWrapper.in("id", collect);
}
}
// 新增分类过滤

View File

@@ -1169,14 +1169,15 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
// 提取sketch
JSONObject jsonObject = pythonService.segProduct(url);
String clothCategory = pythonService.getClothCategory(url, gender);
JSONObject attributeRecognition = pythonService.getAttributeRecognition(url, clothCategory, gender);
JSONObject data = attributeRecognition.getJSONObject("data");
JSONObject attrDict = ((JSONObject) data.getJSONArray("list").get(0)).getJSONObject("attr_dict");
AttributeRecognitionJSON attrDictJSON = attrDict.toJavaObject(AttributeRecognitionJSON.class);
ProductImageAttribute productImageAttribute = toAttrDict(attrDictJSON);
productImageAttributeMapper.insert(productImageAttribute);
JSONArray data = jsonObject.getJSONArray("data");
for (int i = 0; i < data.size(); i++) {
JSONObject jsonObject1 = data.getJSONObject(i);
JSONObject attribute = jsonObject1.getJSONObject("attribute");
AttributeRecognitionJSON attrDictJSON = attribute.toJavaObject(AttributeRecognitionJSON.class);
ProductImageAttribute productImageAttribute = toAttrDict(attrDictJSON);
productImageAttribute.setLibraryId(library.getId());
productImageAttributeMapper.insert(productImageAttribute);
}
}
return null;
}