客户端代码提交
This commit is contained in:
parent
52c3942346
commit
958786cdf1
@ -2,6 +2,7 @@ package com.small.client.Schedule;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.small.client.Utils.CommonUtil;
|
||||||
import com.small.client.dto.CommentModel;
|
import com.small.client.dto.CommentModel;
|
||||||
import com.small.client.dto.DataBaseInfo;
|
import com.small.client.dto.DataBaseInfo;
|
||||||
import com.small.client.service.SxDataService;
|
import com.small.client.service.SxDataService;
|
||||||
@ -93,11 +94,23 @@ public class DynamicTaskScheduler {
|
|||||||
if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){
|
if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){
|
||||||
commentModel.setSyncTime(DateUtil.formatDateTime(dataBaseInfo.getRefreshTime()));
|
commentModel.setSyncTime(DateUtil.formatDateTime(dataBaseInfo.getRefreshTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
sxDataService.syncStoreData(dataBaseInfo,commentModel);
|
sxDataService.syncStoreData(dataBaseInfo,commentModel);
|
||||||
sxDataService.SyncBranchList(dataBaseInfo,commentModel);
|
sxDataService.SyncBranchList(dataBaseInfo,commentModel);
|
||||||
sxDataService.SyncCategory(dataBaseInfo,commentModel);
|
sxDataService.SyncCategory(dataBaseInfo,commentModel);
|
||||||
sxDataService.SyncGoods(dataBaseInfo,commentModel);//todo 暂时同步全部的商品如果后期修改,需要增加服务器的字段
|
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.SyncVipList(dataBaseInfo,commentModel);
|
||||||
|
sxDataService.syncAtive(dataBaseInfo,commentModel);
|
||||||
sxDataService.syncAtiveShops(dataBaseInfo,commentModel);
|
sxDataService.syncAtiveShops(dataBaseInfo,commentModel);
|
||||||
isRuning=false;
|
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 = "刷新时间")
|
@ApiModelProperty(value = "刷新时间")
|
||||||
private Date refreshTime;
|
private Date refreshTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "间隔时间")
|
||||||
|
private String shopGapTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,4 +68,7 @@ public class StoreDbConfig implements Serializable {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "是否双向同步(0:否,1:是)")
|
@ApiModelProperty(value = "是否双向同步(0:否,1:是)")
|
||||||
private String isTowSync="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.setCategoryName(storeDbConfig.getCategoryName());
|
||||||
dataBaseInfo.setRefreshTime(storeDbConfig.getRefreshTime());
|
dataBaseInfo.setRefreshTime(storeDbConfig.getRefreshTime());
|
||||||
dataBaseInfo.setIsTowSync(storeDbConfig.getIsTowSync());
|
dataBaseInfo.setIsTowSync(storeDbConfig.getIsTowSync());
|
||||||
|
dataBaseInfo.setShopGapTime(storeDbConfig.getShopGapTime());
|
||||||
return dataBaseInfo;
|
return dataBaseInfo;
|
||||||
}
|
}
|
||||||
return new DataBaseInfo();
|
return new DataBaseInfo();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user