yangys
2024-09-04 04c57331cf84c8f606c2838dcb6fe5463fb9b68c
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
package com.qianwen.smartman.common.cache.cps;
 
import java.util.List;
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.qianwen.core.cache.utils.CacheUtil;
import com.qianwen.core.tool.utils.SpringUtil;
import com.qianwen.smartman.common.constant.ExtCacheConstant;
import com.qianwen.smartman.modules.cps.entity.WorkstationOfMachine;
import com.qianwen.smartman.modules.cps.service.IWorkstationOfMachineService;
 
public class WorkstationOfMachineCache {
    private static final String MACHINE_LIST = "machine:list:";
    private static final String MACHINE_ID = "machine:id:";
    private static final String WORKSTATION_ALL = "workstation:all";
    private static final String PARAMNAME = "paramName";
    private static final Boolean TENANT_MODE = Boolean.FALSE;
    private static final IWorkstationOfMachineService machineService;
 
    static {
        machineService = (IWorkstationOfMachineService)SpringUtil.getBean(IWorkstationOfMachineService.class);
     }
 
    public static List<WorkstationOfMachine> getList(String machineId) {
       
        return (List<WorkstationOfMachine>)CacheUtil.get(ExtCacheConstant.WORKSTATION_MACHINE, MACHINE_LIST, machineId, () -> machineService.list(Wrappers.<WorkstationOfMachine>lambdaQuery().eq(WorkstationOfMachine::getMachineId, machineId)), TENANT_MODE);
    }
 
    public static void clearWorkStationMachineCache(List<String> machineIdList) {
        machineIdList.forEach(id -> {
            String key = ExtCacheConstant.POSTING_MACHINE.concat("::").concat(MACHINE_ID).concat(id).concat(WORKSTATION_ALL);
            CacheUtil.clear(key);
        });
    }
 
    public static void clearParamNameCache(String machineId) {
        String key = ExtCacheConstant.POSTING_MACHINE.concat("::").concat(MACHINE_ID).concat(machineId).concat(PARAMNAME);
        CacheUtil.clear(key);
    }
}