package com.iailab.module.model.mcs.sche.service.impl;
|
|
import com.iailab.framework.common.service.impl.BaseServiceImpl;
|
import com.iailab.framework.common.util.object.BeanUtils;
|
import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.iailab.module.model.mcs.sche.dao.StScheduleModelParamDao;
|
import com.iailab.module.model.mcs.sche.entity.StScheduleModelParamEntity;
|
import com.iailab.module.model.mcs.sche.service.StScheduleModelParamService;
|
import com.iailab.module.model.mcs.sche.vo.StScheduleModelParamSaveReqVO;
|
import org.springframework.stereotype.Service;
|
import org.springframework.util.CollectionUtils;
|
|
import java.util.List;
|
import java.util.Map;
|
import java.util.UUID;
|
import java.util.concurrent.ConcurrentHashMap;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2024年09月06日
|
*/
|
@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) {
|
return baseDao.selectList(
|
new LambdaQueryWrapperX<StScheduleModelParamEntity>()
|
.likeIfPresent(StScheduleModelParamEntity::getModelid, modelId)
|
.orderByAsc(StScheduleModelParamEntity::getModelparamportorder)
|
.orderByAsc(StScheduleModelParamEntity::getModelparamorder)
|
);
|
}
|
|
@Override
|
public void deleteByModelId(String modelId) {
|
baseDao.delete(new LambdaQueryWrapperX<StScheduleModelParamEntity>()
|
.likeIfPresent(StScheduleModelParamEntity::getModelid, modelId)
|
);
|
}
|
|
@Override
|
public void saveList(String modelId, List<StScheduleModelParamSaveReqVO> saveList) {
|
deleteByModelId(modelId);
|
if (CollectionUtils.isEmpty(saveList)) {
|
return;
|
}
|
saveList.forEach(item -> {
|
StScheduleModelParamEntity entity = BeanUtils.toBean(item, StScheduleModelParamEntity.class);
|
entity.setId(UUID.randomUUID().toString());
|
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();
|
}
|
}
|