外食计算优化,异步更新热量加上延迟

This commit is contained in:
xiezhijun
2021-02-24 10:52:56 +08:00
parent 13727e8d39
commit 66957edce0
3 changed files with 10 additions and 4 deletions

View File

@ -27,6 +27,7 @@ public class AsyncCommonServiceImpl implements AsyncCommonService {
@Autowired
private SysFoodHeatStatisticsMapper sysFoodHeatStatisticsMapper;
public static final long sleepTime = 5000; //异步线程睡眠时间,毫秒
/**
* 异步更新每个食材对应的蛋白质、脂肪、碳水的质量
@ -34,6 +35,11 @@ public class AsyncCommonServiceImpl implements AsyncCommonService {
@Override
@Async
public void updateFoodNutritionalQualityAndHeat(Long customerHeatId){
try {
Thread.sleep(sleepTime);
}catch (Exception e){
e.printStackTrace();
}
SysCustomerHeatStatistics sysCustomerHeatStatistics = sysCustomerHeatStatisticsMapper.selectSysCustomerHeatStatisticsById(customerHeatId);
if(sysCustomerHeatStatistics != null && sysCustomerHeatStatistics.getFoodHeatStatisticsList() != null
&& sysCustomerHeatStatistics.getFoodHeatStatisticsList().size() > 0){