1
This commit is contained in:
@@ -46,6 +46,8 @@ public interface RakutenProductRepository extends JpaRepository<RakutenProductEn
|
||||
*/
|
||||
List<RakutenProductEntity> findByOriginalShopNameOrderByCreatedAtAscIdAsc(String originalShopName);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 检查指定店铺在指定时间后是否有数据
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
package com.tashow.erp.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.tashow.erp.entity.RakutenProductEntity;
|
||||
import com.tashow.erp.model.RakutenProduct;
|
||||
import com.tashow.erp.repository.RakutenProductRepository;
|
||||
@@ -10,7 +8,6 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -61,7 +58,7 @@ public class RakutenCacheServiceImpl implements IRakutenCacheService {
|
||||
return entity;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
repository.saveAll(entities);
|
||||
log.info("保存产品数据,sessionId: {},数量: {}", sessionId, products.size());
|
||||
}
|
||||
@@ -114,17 +111,17 @@ public class RakutenCacheServiceImpl implements IRakutenCacheService {
|
||||
if (products == null || products.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 根据产品的唯一标识(如productUrl)来查找并更新对应的数据库记录
|
||||
List<String> productUrls = products.stream()
|
||||
.map(RakutenProduct::getProductUrl)
|
||||
.filter(url -> url != null && !url.trim().isEmpty())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
if (productUrls.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
List<RakutenProductEntity> entities = repository.findByProductUrlIn(productUrls);
|
||||
entities.forEach(entity -> {
|
||||
if (!newSessionId.equals(entity.getSessionId())) {
|
||||
@@ -132,7 +129,7 @@ public class RakutenCacheServiceImpl implements IRakutenCacheService {
|
||||
entity.setUpdatedAt(LocalDateTime.now());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
repository.saveAll(entities);
|
||||
log.info("更新特定产品sessionId,数量: {} -> {}", entities.size(), newSessionId);
|
||||
}
|
||||
|
||||
@@ -81,15 +81,17 @@ public class ExcelExportUtil {
|
||||
* 填充行数据 - 需要子类实现具体逻辑
|
||||
*/
|
||||
private static void fillRowData(Row dataRow, Map<String, Object> rowData, String[] headers, int rowIndex) {
|
||||
// 这里可以根据不同的数据类型进行扩展
|
||||
int colIndex = 0;
|
||||
for (String header : headers) {
|
||||
if (!header.equals("商品图片")) { // 跳过图片列
|
||||
String key = getKeyByHeader(header);
|
||||
if (key != null) {
|
||||
Object value = rowData.get(key);
|
||||
dataRow.createCell(colIndex).setCellValue(formatValue(value, header));
|
||||
if (!header.equals("商品图片")) {
|
||||
Object value = rowData.get(header);
|
||||
if (value == null) {
|
||||
String key = getKeyByHeader(header);
|
||||
if (key != null) {
|
||||
value = rowData.get(key);
|
||||
}
|
||||
}
|
||||
dataRow.createCell(colIndex).setCellValue(formatValue(value, header));
|
||||
}
|
||||
colIndex++;
|
||||
}
|
||||
@@ -121,12 +123,16 @@ public class ExcelExportUtil {
|
||||
headerKeyMap.put("店铺名", "originalShopName");
|
||||
headerKeyMap.put("商品链接", "productUrl");
|
||||
headerKeyMap.put("排名", "ranking");
|
||||
headerKeyMap.put("商品标题", "productTitle"); // 添加缺失的商品标题映射
|
||||
headerKeyMap.put("商品标题", "productTitle");
|
||||
headerKeyMap.put("价格", "price");
|
||||
headerKeyMap.put("1688识图链接", "image1688Url");
|
||||
headerKeyMap.put("1688价格", "median");
|
||||
headerKeyMap.put("1688识图链接", "mapRecognitionLink");
|
||||
headerKeyMap.put("1688运费", "freight");
|
||||
headerKeyMap.put("1688中位价", "median");
|
||||
headerKeyMap.put("1688最低价", "1688最低价");
|
||||
headerKeyMap.put("1688中间价", "1688中间价");
|
||||
headerKeyMap.put("1688最高价", "1688最高价");
|
||||
headerKeyMap.put("1688重量", "weight");
|
||||
|
||||
|
||||
return headerKeyMap.get(header);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user