更新逻辑修改
This commit is contained in:
parent
c8a85d5119
commit
0152518315
@ -99,13 +99,22 @@ public class DynamicTaskScheduler {
|
||||
if(dataBaseInfo==null||StringUtils.isEmpty(dataBaseInfo.getUserName())){
|
||||
return;
|
||||
}
|
||||
String refreshTime="";
|
||||
if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){
|
||||
commentModel.setSyncTime(DateUtil.formatDateTime(dataBaseInfo.getRefreshTime()));
|
||||
refreshTime=DateUtil.formatDateTime(dataBaseInfo.getRefreshTime());
|
||||
commentModel.setSyncTime(refreshTime);
|
||||
}
|
||||
|
||||
sxDataService.syncStoreData(dataBaseInfo,commentModel);
|
||||
if(StringUtils.isNotEmpty(refreshTime)){//有刷新时间,证明不是全量,需要判断是否有新商品,有新商品才同步品牌和分类
|
||||
if(sxDataService.isNewShop(dataBaseInfo,refreshTime)){
|
||||
sxDataService.SyncBranchList(dataBaseInfo,commentModel);
|
||||
sxDataService.SyncCategory(dataBaseInfo,commentModel);
|
||||
}
|
||||
}else {
|
||||
log.info("首次同步,无刷新时间");
|
||||
sxDataService.SyncBranchList(dataBaseInfo,commentModel);
|
||||
sxDataService.SyncCategory(dataBaseInfo,commentModel);
|
||||
}
|
||||
sxDataService.SyncGoods(dataBaseInfo,commentModel);//todo 暂时同步全部的商品如果后期修改,需要增加服务器的字段
|
||||
try {
|
||||
if(ObjectUtil.isNotEmpty(dataBaseInfo.getShopGapTime())){
|
||||
@ -117,9 +126,18 @@ public class DynamicTaskScheduler {
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){
|
||||
commentModel.setSyncTime(refreshTime);
|
||||
}
|
||||
sxDataService.SyncVipList(dataBaseInfo,commentModel);
|
||||
sxDataService.syncAtive(dataBaseInfo,commentModel);
|
||||
boolean isNewActives=sxDataService.syncAtive(dataBaseInfo,commentModel);
|
||||
if(isNewActives){
|
||||
log.info("---有新增的活动,同步活动商品开始--");
|
||||
sxDataService.syncAtiveShops(dataBaseInfo,commentModel);
|
||||
}else {
|
||||
log.info("---无新增的活动,无需同步活动商品--");
|
||||
}
|
||||
|
||||
isRuning=false;
|
||||
}
|
||||
|
||||
|
||||
@ -526,7 +526,7 @@ public class SxDataDao extends BaseDao{
|
||||
if(stock_qty.compareTo(BigDecimal.ZERO)==0){
|
||||
continue;
|
||||
}
|
||||
ProductQuantityConsumptionDto productQuantityConsumptionDto=pqMap.get(itemNo);
|
||||
ProductQuantityConsumptionDto productQuantityConsumptionDto=pqMap.get(key);
|
||||
if(productQuantityConsumptionDto.getSaleAmount().compareTo(BigDecimal.ZERO)==0){
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -42,4 +42,9 @@ public class ItemInfo {
|
||||
* 进货价格
|
||||
*/
|
||||
private BigDecimal price;
|
||||
|
||||
/**
|
||||
* 零售价
|
||||
*/
|
||||
private BigDecimal salePrice;
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ public interface SxDataService {
|
||||
* @param commentModel
|
||||
* @return
|
||||
*/
|
||||
void syncAtive(DataBaseInfo dataBaseInfo,CommentModel commentModel);
|
||||
boolean syncAtive(DataBaseInfo dataBaseInfo,CommentModel commentModel);
|
||||
|
||||
/**
|
||||
* 同步活动商品
|
||||
@ -73,4 +73,12 @@ public interface SxDataService {
|
||||
void syncAtiveShops(DataBaseInfo dataBaseInfo,CommentModel commentModel);
|
||||
|
||||
String getCategoryChildren(DataBaseInfo dataBaseInfo,String parentId);
|
||||
|
||||
/**
|
||||
* 校验是否有新的入库
|
||||
* @param dataBaseInfo
|
||||
* @param refreshTime
|
||||
* @return
|
||||
*/
|
||||
boolean isNewShop(DataBaseInfo dataBaseInfo, String refreshTime);
|
||||
}
|
||||
|
||||
@ -134,10 +134,10 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
break;
|
||||
case "02"://增量 todo test
|
||||
String sycnTime=commentModel.getSyncTime();
|
||||
syncIncrementAddGoods(dataBaseInfo, commentModel);
|
||||
syncIncrementAddGoods(dataBaseInfo, commentModel);//同步新商品
|
||||
// syncIncrementModifyGoods(dataBaseInfo, commentModel);
|
||||
syncIncrementStock(dataBaseInfo, commentModel);
|
||||
syncFlowPrice(dataBaseInfo, commentModel,sycnTime);
|
||||
syncIncrementStock(dataBaseInfo, commentModel);//同步库存
|
||||
syncFlowPrice(dataBaseInfo, commentModel,sycnTime);//同步调价单
|
||||
break;
|
||||
}
|
||||
|
||||
@ -310,6 +310,22 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
return root;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有新增商品,有新增商品才同步分类
|
||||
* @param dataBaseInfo
|
||||
* @param refreshTime
|
||||
* @return
|
||||
*/
|
||||
public boolean isNewShop(DataBaseInfo dataBaseInfo, String refreshTime){
|
||||
String where="where b.status='1' ";
|
||||
where+=" and ( b.modify_date>'"+refreshTime+"' ";
|
||||
where+=" or b.build_date>'"+refreshTime+"') ";
|
||||
dataBaseInfo.setWhere(where);
|
||||
int total = sxDataDao.getTBditemInfoTotal(dataBaseInfo);
|
||||
log.info("判断库存数量,库存数量:{}",total);
|
||||
return total>0;
|
||||
}
|
||||
|
||||
/**
|
||||
*同步所有商品
|
||||
* @param dataBaseInfo
|
||||
@ -340,11 +356,11 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
" shop.item_no " +
|
||||
" from " +
|
||||
" t_pc_price_flow_detail tpfd " +
|
||||
" inner join t_pc_price_flow_master tppfm " +
|
||||
" left join t_pc_price_flow_master tppfm " +
|
||||
" on " +
|
||||
" tpfd.sheet_no = tppfm.sheet_no " +
|
||||
" where " +
|
||||
" tppfm.valid_flag = '2' " +//有效
|
||||
" tppfm.valid_flag = '1' " +//有效
|
||||
" and shop.item_no=tpfd.item_no " +
|
||||
" and tppfm.oper_date >'"+dataBaseInfo.getPriceOperatime()+"' " +
|
||||
" )";
|
||||
@ -622,10 +638,10 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
log.info("文件下载目录: {}", downloadDirectory);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
// headers.set("User-Agent", "Apifox/1.0.0 (https://apifox.com)");
|
||||
headers.setAccept(Collections.singletonList(MediaType.ALL)); // 对应 */*
|
||||
headers.set("Accept-Encoding", "gzip, deflate, br");
|
||||
//headers.setAccept(Collections.singletonList(MediaType.ALL)); // 对应 */*
|
||||
// headers.set("Accept-Encoding", "gzip, deflate, br");
|
||||
// 可以添加其他Apifox可能发送的头部
|
||||
headers.set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8");
|
||||
// headers.set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8");
|
||||
headers.set("Connection", "keep-alive");
|
||||
|
||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(headers);
|
||||
@ -769,10 +785,13 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
JSONObject jsonObject= restTemplate.getForObject(remoteIp+HttpUtils.URL_SYNC_GET_STOR_DATA_RELEASE
|
||||
+"?appKey="+commentModel.getAppKey()
|
||||
+"&sign="+commentModel.getAppId(),JSONObject.class);
|
||||
// String jsonStr="[{\"consumeId\":\"1986611923814223873\",\"orderId\":\"DD_20251107_1\",\"productNumber\":\"31011\",\"unitPrice\":10.90,\"quantity\":1.500,\"saleAmount\":16.35,\"status\":0,\"storeId\":78,\"createTime\":\"2025-11-07 01:49:26\",\"updateTime\":\"2025-11-07 01:49:26\"},{\"consumeId\":\"1986611923814223872\",\"orderId\":\"DD_20251107_2\",\"productNumber\":\"6909409023853\",\"unitPrice\":1.00,\"quantity\":1.000,\"saleAmount\":1.00,\"status\":0,\"storeId\":78,\"createTime\":\"2025-11-07 01:49:26\",\"updateTime\":\"2025-11-07 01:49:26\"},{\"consumeId\":\"1986611923814223874\",\"orderId\":\"DD_20251107_1\",\"productNumber\":\"6909409023853\",\"unitPrice\":1.00,\"quantity\":2.000,\"saleAmount\":2.00,\"status\":0,\"storeId\":78,\"createTime\":\"2025-11-07 01:49:26\",\"updateTime\":\"2025-11-07 01:49:26\"}]";
|
||||
|
||||
if(null!=jsonObject.get("result")){
|
||||
// Map map=(Map)jsonObject.get("result");
|
||||
String jsonStr= jsonObject.getStr("result");
|
||||
List<ProductQuantityConsumptionDto> productQuantityConsumptionDtoList =
|
||||
JSONUtil.toList(jsonObject.getStr("result"),ProductQuantityConsumptionDto.class);
|
||||
JSONUtil.toList(jsonStr,ProductQuantityConsumptionDto.class);
|
||||
if(!productQuantityConsumptionDtoList.isEmpty()){
|
||||
Map map = productQuantityConsumptionDtoList.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
@ -786,17 +805,18 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
Map<String,ProductQuantityConsumptionDto> productQuantityConsumptionDtoMap=new HashMap<>();
|
||||
|
||||
productQuantityConsumptionDtoList.forEach(productQuantityConsumptionDto -> {
|
||||
productQuantityConsumptionDtoMap.put(productQuantityConsumptionDto.getProductNumber(),productQuantityConsumptionDto);
|
||||
productQuantityConsumptionDtoMap.put(productQuantityConsumptionDto.getOrderId()+"-"+productQuantityConsumptionDto.getProductNumber(),productQuantityConsumptionDto);
|
||||
});
|
||||
|
||||
sxDataDao.updateStoreData(dataBaseInfo,map,productQuantityConsumptionDtoMap,productQuantityConsumptionDtoList,commentModel);
|
||||
}else {
|
||||
log.info("无线上流水同步");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncAtive(DataBaseInfo dataBaseInfo, CommentModel commentModel) {
|
||||
public boolean syncAtive(DataBaseInfo dataBaseInfo, CommentModel commentModel) {
|
||||
String where="where 1=1";
|
||||
Integer total =0;
|
||||
if(StringUtils.isNotEmpty(commentModel.getSyncTime())){
|
||||
@ -807,7 +827,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
total = sxDataDao.getNewActiveCount(dataBaseInfo);
|
||||
if(total==0){
|
||||
log.info("暂无活动同步");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
// 总页数
|
||||
int pages = CommonUtil.getPagesCount(total, SxDataDao.PAGESIZE);
|
||||
@ -832,7 +852,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
syncCount+=activeDtos.size();
|
||||
}
|
||||
log.info("成功同步活动数据:"+syncCount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
Reference in New Issue
Block a user