智慧厨房-超时自动离柜
This commit is contained in:
parent
3b00f4033c
commit
63533ab29f
|
|
@ -57,4 +57,11 @@ public interface KitchenSampleDishesRecordMapper {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteKitchenSampleDishesRecordByRecordIds(Long[] recordIds);
|
public int deleteKitchenSampleDishesRecordByRecordIds(Long[] recordIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断留样是否超时
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int handleKitchenSampleDishesTimeOut();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,4 +57,11 @@ public interface IKitchenSampleDishesRecordService {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteKitchenSampleDishesRecordByRecordId(Long recordId);
|
public int deleteKitchenSampleDishesRecordByRecordId(Long recordId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断留样是否超时
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int handleKitchenSampleDishesTimeOut();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import org.springframework.stereotype.Service;
|
||||||
import com.bonus.canteen.core.kitchen.mapper.KitchenSampleDishesRecordMapper;
|
import com.bonus.canteen.core.kitchen.mapper.KitchenSampleDishesRecordMapper;
|
||||||
import com.bonus.canteen.core.kitchen.domain.KitchenSampleDishesRecord;
|
import com.bonus.canteen.core.kitchen.domain.KitchenSampleDishesRecord;
|
||||||
import com.bonus.canteen.core.kitchen.service.IKitchenSampleDishesRecordService;
|
import com.bonus.canteen.core.kitchen.service.IKitchenSampleDishesRecordService;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 留样机留样清单Service业务层处理
|
* 留样机留样清单Service业务层处理
|
||||||
|
|
@ -138,4 +139,10 @@ public class KitchenSampleDishesRecordServiceImpl implements IKitchenSampleDishe
|
||||||
public int deleteKitchenSampleDishesRecordByRecordId(Long recordId) {
|
public int deleteKitchenSampleDishesRecordByRecordId(Long recordId) {
|
||||||
return kitchenSampleDishesRecordMapper.deleteKitchenSampleDishesRecordByRecordId(recordId);
|
return kitchenSampleDishesRecordMapper.deleteKitchenSampleDishesRecordByRecordId(recordId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public int handleKitchenSampleDishesTimeOut() {
|
||||||
|
return kitchenSampleDishesRecordMapper.handleKitchenSampleDishesTimeOut();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.bonus.canteen.core.kitchen.task;
|
||||||
|
|
||||||
|
import com.bonus.canteen.core.common.utils.RedisUtil;
|
||||||
|
import com.bonus.canteen.core.cook.task.CookRecipeTask;
|
||||||
|
import com.bonus.canteen.core.kitchen.service.IKitchenSampleDishesRecordService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class SampleDishesStateTask {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(CookRecipeTask.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IKitchenSampleDishesRecordService kitchenSampleDishesRecordService;
|
||||||
|
|
||||||
|
@Scheduled(fixedDelay = 60 * 60 * 1000)
|
||||||
|
public void cookRecipeHandler() {
|
||||||
|
boolean lock = RedisUtil.setNx("kitchen:sampleDishesState", "1", 3600);
|
||||||
|
if (lock) {
|
||||||
|
logger.info("[定时更新留样菜品状态]开始:{}", LocalDateTime.now());
|
||||||
|
try {
|
||||||
|
kitchenSampleDishesRecordService.handleKitchenSampleDishesTimeOut();
|
||||||
|
logger.info("[定时更新留样菜品状态]结束:{}", LocalDateTime.now());
|
||||||
|
}catch (Exception ex) {
|
||||||
|
logger.error("[定时更新留样菜品状态]异常", ex);
|
||||||
|
}finally {
|
||||||
|
RedisUtil.delete("kitchen:sampleDishesState");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -209,4 +209,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
#{recordId}
|
#{recordId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<update id="handleKitchenSampleDishesTimeOut">
|
||||||
|
update kitchen_sample_dishes_record
|
||||||
|
set save_status = 4 ,
|
||||||
|
leave_cabinet_time = now(),
|
||||||
|
update_time = now()
|
||||||
|
where enter_cabinet_time is not null and leave_cabinet_time is null
|
||||||
|
and enter_cabinet_time <![CDATA[ < ]]> NOW() - INTERVAL 48 HOUR
|
||||||
|
and enter_cabinet_time <![CDATA[ > ]]> NOW() - INTERVAL 72 HOUR
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue