houzhongjian
2024-12-05 a709abfd8ffec1524cefff30c3581f4425695433
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleModelParamServiceImpl.java
@@ -11,7 +11,9 @@
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
/**
 * @author PanZhibao
@@ -21,6 +23,8 @@
@Service
public class StScheduleModelParamServiceImpl extends BaseServiceImpl<StScheduleModelParamDao, StScheduleModelParamEntity>
        implements StScheduleModelParamService {
    private static Map<String, List<StScheduleModelParamEntity>> modelInputParamMap = new ConcurrentHashMap<>();
    @Override
    public List<StScheduleModelParamEntity> getByModelId(String modelId) {
@@ -51,5 +55,23 @@
            entity.setModelid(modelId);
            baseDao.insert(entity);
        });
        clearCache();
    }
    @Override
    public List<StScheduleModelParamEntity> getByModelidFromCache(String modelId) {
        if (!modelInputParamMap.containsKey(modelId)) {
            List<StScheduleModelParamEntity> list = getByModelId(modelId);
            if (list != null) {
                modelInputParamMap.put(modelId, list);
            } else {
                return null;
            }
        }
        return modelInputParamMap.get(modelId);
    }
    public void clearCache() {
        modelInputParamMap.clear();
    }
}