|
|
|
|
@@ -779,7 +779,7 @@ public class TProductService extends ServiceImpl<TProductMapper, TProduct> {
|
|
|
|
|
public TProductSingleUploadVo singleUploadProduct(MultipartFile file, String md5, String timeZone) {
|
|
|
|
|
Long accountId = UserContext.getUserHolder().getId();
|
|
|
|
|
//md5去重
|
|
|
|
|
Assert.isTrue(!existsMd5(md5,null), "Product already exists!");
|
|
|
|
|
// Assert.isTrue(!existsMd5(md5,null), "Product already exists!");
|
|
|
|
|
//上传路径
|
|
|
|
|
|
|
|
|
|
// 根据mi-tu图片名获取item_code
|
|
|
|
|
@@ -787,7 +787,7 @@ public class TProductService extends ServiceImpl<TProductMapper, TProduct> {
|
|
|
|
|
if (originalFilename == null) {
|
|
|
|
|
throw new BusinessException("file name is null.");
|
|
|
|
|
}
|
|
|
|
|
// String itemNameColorCode = originalFilename.substring(0, originalFilename.lastIndexOf('.'));
|
|
|
|
|
String fileName = originalFilename.substring(0, originalFilename.lastIndexOf('.'));
|
|
|
|
|
// 根据itemName查询mi-tu商品信息
|
|
|
|
|
// 根据最后一个"_"分割itemNameColorCode
|
|
|
|
|
// int lastUnderscoreIndex = itemNameColorCode.lastIndexOf("_");
|
|
|
|
|
@@ -806,12 +806,14 @@ public class TProductService extends ServiceImpl<TProductMapper, TProduct> {
|
|
|
|
|
String minioFullPath = minioUtil.upload(MI_TU_BUCKET_NAME, minioPath, file);
|
|
|
|
|
TProduct saveProduct = new TProduct();
|
|
|
|
|
saveProduct.setAccountId(accountId);
|
|
|
|
|
saveProduct.setPrice(BigDecimal.valueOf(1000.0d));
|
|
|
|
|
Random random = new Random();
|
|
|
|
|
int randomInt = 500 + random.nextInt(1001); // 1001 是上限 - 下限 + 1
|
|
|
|
|
saveProduct.setPrice(BigDecimal.valueOf(randomInt));
|
|
|
|
|
saveProduct.setOnSaleState(1);
|
|
|
|
|
//上传中
|
|
|
|
|
saveProduct.setUploadState(0);
|
|
|
|
|
saveProduct.setPictureUrl(minioFullPath);
|
|
|
|
|
// saveProduct.setPictureName(itemNameColorCode);
|
|
|
|
|
saveProduct.setPictureName(fileName);
|
|
|
|
|
saveProduct.setMd5(md5);
|
|
|
|
|
//按时区计算
|
|
|
|
|
saveProduct.setCreateDate(DateUtil.getByTimeZone(timeZone));
|
|
|
|
|
@@ -832,7 +834,9 @@ public class TProductService extends ServiceImpl<TProductMapper, TProduct> {
|
|
|
|
|
// for (MiTuProductStock tuProductStock : miTuProductStock) {
|
|
|
|
|
// total = total + tuProductStock.getNum();
|
|
|
|
|
// }
|
|
|
|
|
saveProduct.setTotal(10);
|
|
|
|
|
// Random random = new Random();
|
|
|
|
|
int randomNumber = random.nextInt(16) + 5;
|
|
|
|
|
saveProduct.setTotal(randomNumber);
|
|
|
|
|
tProductMapper.insert(saveProduct);
|
|
|
|
|
// List<TProductStock> productStockList = new ArrayList<>();
|
|
|
|
|
// HashMap<String, List<BatchUploadProductStoreStockDTO>> map = new HashMap<>();
|
|
|
|
|
@@ -863,23 +867,49 @@ public class TProductService extends ServiceImpl<TProductMapper, TProduct> {
|
|
|
|
|
// .build();
|
|
|
|
|
// tProductStockService.save(tProductStock);
|
|
|
|
|
// }
|
|
|
|
|
for (int i = 0; i < 1; i++) {
|
|
|
|
|
String jsonString = "[{\"num\":4,\"size\":\"00F\"}]";
|
|
|
|
|
TProductStock tProductStock = TProductStock.builder()
|
|
|
|
|
.productId(saveProduct.getId())
|
|
|
|
|
.storeId(25L)
|
|
|
|
|
.stockContent(jsonString)
|
|
|
|
|
.createDate(new Date())
|
|
|
|
|
.build();
|
|
|
|
|
tProductStockService.save(tProductStock);
|
|
|
|
|
List<TProductStock> productStockList = gettProductStockList();
|
|
|
|
|
if (CollectionUtils.isEmpty(productStockList)) {
|
|
|
|
|
for (int i = 0; i < 1; i++) {
|
|
|
|
|
String jsonString = "[{\"num\":4,\"size\":\"00F\"}]";
|
|
|
|
|
TProductStock tProductStock = TProductStock.builder()
|
|
|
|
|
.productId(saveProduct.getId())
|
|
|
|
|
.storeId(25L)
|
|
|
|
|
.stockContent(jsonString)
|
|
|
|
|
.createDate(new Date())
|
|
|
|
|
.build();
|
|
|
|
|
tProductStockService.save(tProductStock);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
for (TProductStock tProductStock : productStockList) {
|
|
|
|
|
tProductStock.setProductId(saveProduct.getId());
|
|
|
|
|
tProductStock.setCreateDate(new Date());
|
|
|
|
|
tProductStock.setId(null);
|
|
|
|
|
tProductStockService.save(tProductStock);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// for (MiTuProduct miTuProduct : miTuProductList) {
|
|
|
|
|
// miTuProduct.setProductId(saveProduct.getId());
|
|
|
|
|
// miTuProductMapper.insert(miTuProduct);
|
|
|
|
|
// }
|
|
|
|
|
MiTuProduct miTuProduct = new MiTuProduct();
|
|
|
|
|
int fiveDigitNumber = 10000 + random.nextInt(90000);
|
|
|
|
|
miTuProduct.setPluCode("MTDTEZN" + fiveDigitNumber);
|
|
|
|
|
miTuProduct.setProductId(saveProduct.getId());
|
|
|
|
|
miTuProductMapper.insert(miTuProduct);
|
|
|
|
|
return new TProductSingleUploadVo(saveProduct.getId().toString(), minioUtil.getPresignedUrl(minioFullPath, 24 * 60), "", md5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<TProductStock> gettProductStockList() {
|
|
|
|
|
QueryWrapper<TProductStock> qw = new QueryWrapper<>();
|
|
|
|
|
qw.lambda().eq(TProductStock::getProductId, 4376);
|
|
|
|
|
List<TProductStock> list = tProductStockService.list(qw);
|
|
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
}else {
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<MiTuProductStock> getMiTuProductStock(String pluCode, String color) {
|
|
|
|
|
List<MiTuProductStock> miTuProductStockList = new ArrayList<>();
|
|
|
|
|
// Connection conn = null;
|
|
|
|
|
@@ -1145,7 +1175,7 @@ public class TProductService extends ServiceImpl<TProductMapper, TProduct> {
|
|
|
|
|
JSONObject productIdInnerToMap = pythonService.attributeRecognition(
|
|
|
|
|
Collections.singletonList(tProduct.getPictureUrl()),
|
|
|
|
|
Collections.singletonList(tProduct.getId().toString()),
|
|
|
|
|
Collections.singletonList(tProduct.getPictureUrl().split("/")[2] + "/" + tProduct.getPictureUrl().split("/")[3]));
|
|
|
|
|
Collections.singletonList("category"));
|
|
|
|
|
//保存商品属性
|
|
|
|
|
tProductAttributeService.saveBatch(resolveProductAttributeNew(productIdInnerToMap, product.getTimeZone()));
|
|
|
|
|
// resolveProductIdToMap(productIdToMap, productIdInnerToMap);
|
|
|
|
|
@@ -1230,8 +1260,9 @@ public class TProductService extends ServiceImpl<TProductMapper, TProduct> {
|
|
|
|
|
// vo.setItem_name(tProduct.getPictureName().split("_")[0]);
|
|
|
|
|
vo.setItem_name(tProduct.getPictureName());
|
|
|
|
|
vo.setImage_path(tProduct.getPictureUrl());
|
|
|
|
|
String[] split = tProduct.getPictureUrl().split("/");
|
|
|
|
|
vo.setSemantic_category(split[2] + "/" + split[3]);
|
|
|
|
|
String attributeItem = getProductAttributeItem(tProduct.getId());
|
|
|
|
|
// String[] split = tProduct.getPictureUrl().split("/");
|
|
|
|
|
vo.setSemantic_category(attributeItem);
|
|
|
|
|
query.add(vo);
|
|
|
|
|
}
|
|
|
|
|
for (TProduct tProduct : db) {
|
|
|
|
|
@@ -1239,8 +1270,9 @@ public class TProductService extends ServiceImpl<TProductMapper, TProduct> {
|
|
|
|
|
// vo.setItem_name(tProduct.getPictureName().split("_")[0]);
|
|
|
|
|
vo.setItem_name(tProduct.getPictureName());
|
|
|
|
|
vo.setImage_path(tProduct.getPictureUrl());
|
|
|
|
|
String[] split = tProduct.getPictureUrl().split("/");
|
|
|
|
|
vo.setSemantic_category(split[2] + "/" + split[3]);
|
|
|
|
|
String attributeItem = getProductAttributeItem(tProduct.getId());
|
|
|
|
|
// String[] split = tProduct.getPictureUrl().split("/");
|
|
|
|
|
vo.setSemantic_category(attributeItem);
|
|
|
|
|
database.add(vo);
|
|
|
|
|
}
|
|
|
|
|
List<GenerateCollocationOutVO> collocationOutResult = pythonService.generateCollocationNew(query, database);
|
|
|
|
|
@@ -1277,6 +1309,16 @@ public class TProductService extends ServiceImpl<TProductMapper, TProduct> {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getProductAttributeItem(Long id) {
|
|
|
|
|
QueryWrapper<TProductAttribute> qw = new QueryWrapper<>();
|
|
|
|
|
qw.lambda().eq(TProductAttribute::getProductId, id);
|
|
|
|
|
List<TProductAttribute> list = tProductAttributeService.list(qw);
|
|
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return list.get(0).getAttributeItem();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Collection<TProductAssortment> resolveProductAssortmentNew(List<GenerateCollocationOutVO> collocationOutResult, String timeZone) {
|
|
|
|
|
log.info("获取python推荐搭配总数据是###{}", JSON.toJSONString(collocationOutResult));
|
|
|
|
|
List<TProductAssortment> result = Lists.newArrayList();
|
|
|
|
|
@@ -1674,20 +1716,30 @@ public class TProductService extends ServiceImpl<TProductMapper, TProduct> {
|
|
|
|
|
data.forEach((k,v) -> {
|
|
|
|
|
JSONObject attributes = data.getJSONObject(k);
|
|
|
|
|
String item = attributes.getString("Item");
|
|
|
|
|
attributes.forEach((k1,v1) -> {
|
|
|
|
|
if (!k1.equals("Item")) {
|
|
|
|
|
TProductAttribute tProductAttribute = new TProductAttribute();
|
|
|
|
|
tProductAttribute.setProductId(Long.valueOf(k));
|
|
|
|
|
tProductAttribute.setAttributeType(k1);
|
|
|
|
|
JSONArray attributesArray = attributes.getJSONArray(k1);
|
|
|
|
|
if (attributesArray.size() > 0) {
|
|
|
|
|
tProductAttribute.setAttributeValue(attributesArray.getString(0));
|
|
|
|
|
tProductAttribute.setAttributeItem(item);
|
|
|
|
|
tProductAttribute.setCreateDate(DateUtil.getByTimeZone(timeZone));
|
|
|
|
|
result.add(tProductAttribute);
|
|
|
|
|
if (StringUtils.isEmpty(item)) {
|
|
|
|
|
TProductAttribute tProductAttribute = new TProductAttribute();
|
|
|
|
|
tProductAttribute.setProductId(Long.valueOf(k));
|
|
|
|
|
tProductAttribute.setAttributeType("Type");
|
|
|
|
|
tProductAttribute.setAttributeValue("Pants");
|
|
|
|
|
tProductAttribute.setAttributeItem("bottom");
|
|
|
|
|
tProductAttribute.setCreateDate(DateUtil.getByTimeZone(timeZone));
|
|
|
|
|
result.add(tProductAttribute);
|
|
|
|
|
}else {
|
|
|
|
|
attributes.forEach((k1,v1) -> {
|
|
|
|
|
if (!k1.equals("Item")) {
|
|
|
|
|
TProductAttribute tProductAttribute = new TProductAttribute();
|
|
|
|
|
tProductAttribute.setProductId(Long.valueOf(k));
|
|
|
|
|
tProductAttribute.setAttributeType(k1);
|
|
|
|
|
JSONArray attributesArray = attributes.getJSONArray(k1);
|
|
|
|
|
if (attributesArray.size() > 0) {
|
|
|
|
|
tProductAttribute.setAttributeValue(attributesArray.getString(0));
|
|
|
|
|
tProductAttribute.setAttributeItem(item);
|
|
|
|
|
tProductAttribute.setCreateDate(DateUtil.getByTimeZone(timeZone));
|
|
|
|
|
result.add(tProductAttribute);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return result;
|
|
|
|
|
// productIdToMap.getJSONObject("data").forEach((k, v) -> {
|
|
|
|
|
|