ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
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
package com.vci.server.cache;
 
import com.vci.common.exception.VciExceptionTool;
import com.vci.common.log.ServerWithLog4j;
import com.vci.corba.common.VCIError;
import com.vci.server.base.exception.ExceptionLocalHandler;
import com.vci.server.cache.object.PLCacheRecordEnt;
 
public class BaseCacheTimer {
 
    protected long currentTime;
    
    protected BaseCacheTimer(String objType){
        ServerWithLog4j.logger.debug(String.format("启动【%s】缓存!", objType));
    }
    
    public long getCurrentTime() {
        return currentTime;
    }
 
    public void setCurrentTime(long currentTime) {
        this.currentTime = currentTime;
    }
    
    public PLCacheRecordEnt[] getUpdatedCacheData(String objType) throws VCIError {
//        if (!CacheConfUtil.getEveryTimeRefresh()) {
//            return null;
//        }
        //ServerWithLog4j.logger.debug(String.format("查询【%s】是否存在更新", objType));
        
        try {
            return PLCacheRecordService.getInstance().getCacheRecordByObjType(objType).toArray(new PLCacheRecordEnt[0]);
        } catch (Throwable e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return null;
        }
    }
    
    protected VCIError getLocalVciError(String key, Throwable e) {
        VCIError error = new VCIError(key, new String[]{VciExceptionTool.getExceptionStr(e), VciExceptionTool.getExceptionDetail(e)});
        VCIError rsError = ExceptionLocalHandler.getInstance().getLocalString(error, "VCICacheService");
        return rsError;
    }
    
    
    public Long getDataBaseCurrtenttime() throws VCIError{
        Long time;
        try {
            return PLCacheRecordService.getInstance().getDataBaseCurrtenttime();
        } catch (Throwable e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
 
        return null;
    }
    
    protected void     resetCache(String type) {
        PLCacheRecordService.getInstance().resetObjType(type);
    }
}