智慧厨房-超时自动离柜
This commit is contained in:
parent
3b00f4033c
commit
63533ab29f
|
|
@ -5,14 +5,14 @@ import com.bonus.canteen.core.kitchen.domain.KitchenSampleDishesRecord;
|
|||
|
||||
/**
|
||||
* 留样机留样清单Mapper接口
|
||||
*
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-06-16
|
||||
*/
|
||||
public interface KitchenSampleDishesRecordMapper {
|
||||
/**
|
||||
* 查询留样机留样清单
|
||||
*
|
||||
*
|
||||
* @param recordId 留样机留样清单主键
|
||||
* @return 留样机留样清单
|
||||
*/
|
||||
|
|
@ -20,7 +20,7 @@ public interface KitchenSampleDishesRecordMapper {
|
|||
|
||||
/**
|
||||
* 查询留样机留样清单列表
|
||||
*
|
||||
*
|
||||
* @param kitchenSampleDishesRecord 留样机留样清单
|
||||
* @return 留样机留样清单集合
|
||||
*/
|
||||
|
|
@ -28,7 +28,7 @@ public interface KitchenSampleDishesRecordMapper {
|
|||
|
||||
/**
|
||||
* 新增留样机留样清单
|
||||
*
|
||||
*
|
||||
* @param kitchenSampleDishesRecord 留样机留样清单
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -36,7 +36,7 @@ public interface KitchenSampleDishesRecordMapper {
|
|||
|
||||
/**
|
||||
* 修改留样机留样清单
|
||||
*
|
||||
*
|
||||
* @param kitchenSampleDishesRecord 留样机留样清单
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -44,7 +44,7 @@ public interface KitchenSampleDishesRecordMapper {
|
|||
|
||||
/**
|
||||
* 删除留样机留样清单
|
||||
*
|
||||
*
|
||||
* @param recordId 留样机留样清单主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -52,9 +52,16 @@ public interface KitchenSampleDishesRecordMapper {
|
|||
|
||||
/**
|
||||
* 批量删除留样机留样清单
|
||||
*
|
||||
*
|
||||
* @param recordIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteKitchenSampleDishesRecordByRecordIds(Long[] recordIds);
|
||||
|
||||
/**
|
||||
* 判断留样是否超时
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int handleKitchenSampleDishesTimeOut();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,4 +57,11 @@ public interface IKitchenSampleDishesRecordService {
|
|||
* @return 结果
|
||||
*/
|
||||
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.domain.KitchenSampleDishesRecord;
|
||||
import com.bonus.canteen.core.kitchen.service.IKitchenSampleDishesRecordService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 留样机留样清单Service业务层处理
|
||||
|
|
@ -138,4 +139,10 @@ public class KitchenSampleDishesRecordServiceImpl implements IKitchenSampleDishe
|
|||
public int deleteKitchenSampleDishesRecordByRecordId(Long 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}
|
||||
</foreach>
|
||||
</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>
|
||||
Loading…
Reference in New Issue