客户端代码提交
This commit is contained in:
parent
8848abc18e
commit
456275ab99
@ -2,6 +2,7 @@ package com.small.client.Schedule;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.small.client.Utils.CommonUtil;
|
||||
import com.small.client.dto.CommentModel;
|
||||
import com.small.client.dto.DataBaseInfo;
|
||||
import com.small.client.service.SxDataService;
|
||||
@ -93,11 +94,23 @@ public class DynamicTaskScheduler {
|
||||
if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){
|
||||
commentModel.setSyncTime(DateUtil.formatDateTime(dataBaseInfo.getRefreshTime()));
|
||||
}
|
||||
|
||||
sxDataService.syncStoreData(dataBaseInfo,commentModel);
|
||||
sxDataService.SyncBranchList(dataBaseInfo,commentModel);
|
||||
sxDataService.SyncCategory(dataBaseInfo,commentModel);
|
||||
sxDataService.SyncGoods(dataBaseInfo,commentModel);//todo 暂时同步全部的商品如果后期修改,需要增加服务器的字段
|
||||
try {
|
||||
if(ObjectUtil.isNotEmpty(dataBaseInfo.getShopGapTime())){
|
||||
long sleepTime= CommonUtil.convertExpressionToLong(dataBaseInfo.getShopGapTime());
|
||||
Thread.sleep(sleepTime);//两分钟之后执行
|
||||
}else {
|
||||
Thread.sleep(1000*30);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
sxDataService.SyncVipList(dataBaseInfo,commentModel);
|
||||
sxDataService.syncAtive(dataBaseInfo,commentModel);
|
||||
sxDataService.syncAtiveShops(dataBaseInfo,commentModel);
|
||||
isRuning=false;
|
||||
}
|
||||
|
||||
@ -140,4 +140,21 @@ public class CommonUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 乘法转long,如100*10*10
|
||||
* @param expression
|
||||
* @return
|
||||
*/
|
||||
public static long convertExpressionToLong(String expression) {
|
||||
// 移除空格并按乘号分割
|
||||
String[] parts = expression.replace(" ", "").split("\\*");
|
||||
|
||||
long result = 1L;
|
||||
for (String part : parts) {
|
||||
// 逐段转换为 long 并累乘
|
||||
result *= Long.parseLong(part);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -38,4 +38,7 @@ public class DataBaseInfo {
|
||||
|
||||
@ApiModelProperty(value = "刷新时间")
|
||||
private Date refreshTime;
|
||||
|
||||
@ApiModelProperty(value = "间隔时间")
|
||||
private String shopGapTime;
|
||||
}
|
||||
|
||||
@ -68,4 +68,7 @@ public class StoreDbConfig implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "是否双向同步(0:否,1:是)")
|
||||
private String isTowSync="1";
|
||||
|
||||
@ApiModelProperty("商品同步间隔时间")
|
||||
private String shopGapTime;
|
||||
}
|
||||
|
||||
@ -682,6 +682,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
dataBaseInfo.setCategoryName(storeDbConfig.getCategoryName());
|
||||
dataBaseInfo.setRefreshTime(storeDbConfig.getRefreshTime());
|
||||
dataBaseInfo.setIsTowSync(storeDbConfig.getIsTowSync());
|
||||
dataBaseInfo.setShopGapTime(storeDbConfig.getShopGapTime());
|
||||
return dataBaseInfo;
|
||||
}
|
||||
return new DataBaseInfo();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user