yangys
2024-11-15 d66fe6d46cdbaeb88e68ad96da6deb0b35cd131b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.qianwen.smartman.modules.mdc.service;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.List;
import com.qianwen.smartman.common.constant.ExtCacheConstant;
import com.qianwen.core.mp.support.Query;
import com.qianwen.core.redis.lock.RedisLock;
import com.qianwen.smartman.modules.mdc.dto.WorkstationEndAndStartImmediateFeedBackDTO;
import com.qianwen.smartman.modules.mdc.dto.WorkstationEndImmediateFeedBackDTO;
import com.qianwen.smartman.modules.mdc.dto.WorkstationImmediateFeedBackDTO;
import com.qianwen.smartman.modules.mdc.dto.WorkstationNoImmediateFeedBackDTO;
import com.qianwen.smartman.modules.mdc.entity.WorkstationFeedback;
import com.qianwen.smartman.modules.mdc.vo.StatusRecordVO;
import com.qianwen.smartman.modules.mdc.vo.WorkstationFeedbackInfoVO;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
 
public interface IWorkstationFeedbackService extends IService<WorkstationFeedback> {
    /**
     * 一天缓存 blade:feedback#86400
     */
    public static final String WORK_FEEDBACK_EXP = "blade:feedback#86400";
    
    /**
     * 3天缓存 blade:feedback#259200
     */
    public static final String WORK_FEEDBACK_EXP3 = "blade:feedback#259200";
 
    IPage<WorkstationFeedbackInfoVO> workstationPage(Query query, boolean excludeImmediate);
 
    @Cacheable(cacheNames = {WORK_FEEDBACK_EXP}, key = "'immediate:list'")
    List<WorkstationFeedback> getImmediateFeedback();
 
    @Cacheable(cacheNames = {WORK_FEEDBACK_EXP}, key = "'immediate:workstationId:' + #workstationId")
    WorkstationFeedback getImmediateFeedback(final Serializable workstationId);
 
    @CacheEvict(cacheNames = {ExtCacheConstant.WORK_FEEDBACK}, key = "'immediate:list'")
    boolean startFeedbackByImmediate(WorkstationImmediateFeedBackDTO workstationImmediateFeedBackDTO);
 
    boolean startFeedbackByNoImmediate(WorkstationNoImmediateFeedBackDTO dto);
 
    @Caching(evict = {@CacheEvict(cacheNames = {ExtCacheConstant.WORK_FEEDBACK}, key = "'id:'.concat(#dto.feedbackId)"), @CacheEvict(cacheNames = {ExtCacheConstant.WORK_FEEDBACK}, key = "'immediate:list'"), @CacheEvict(cacheNames = {ExtCacheConstant.WORK_FEEDBACK}, key = "'immediate:workstationId:'.concat(#dto.workstationId)")})
    @RedisLock(value = ExtCacheConstant.WORK_FEEDBACK, param = "#dto.workstationId")
    boolean endFeedback(WorkstationEndImmediateFeedBackDTO dto);
 
    @Caching(evict = {@CacheEvict(cacheNames = {ExtCacheConstant.WORK_FEEDBACK}, key = "'id:'.concat(#dto.endFeedbackId)"), @CacheEvict(cacheNames = {ExtCacheConstant.WORK_FEEDBACK}, key = "'immediate:list'"), @CacheEvict(cacheNames = {ExtCacheConstant.WORK_FEEDBACK}, key = "'immediate:workstationId:'.concat(#dto.workstationId)")})
    @RedisLock(value = ExtCacheConstant.WORK_FEEDBACK, param = "#dto.workstationId")
    boolean endAndStartAgainFeedback(WorkstationEndAndStartImmediateFeedBackDTO dto);
 
    /**
     * 从反馈的redis缓存中获取状态记录的数据
     * @param statusTime
     * @param workstationIds
     * @param statusRecordList
     * @return
     */
    List<StatusRecordVO> groupStatusRecordWithFeedbackCache(final LocalDate statusTime, final Long workstationIds, final List<StatusRecordVO> statusRecordList);
 
    @Cacheable(cacheNames = {WORK_FEEDBACK_EXP}, key = "'id:'.concat(#id)")
    default WorkstationFeedback cachedById(Serializable id) {
        return (WorkstationFeedback) getById(id);
    }
}