提交 | 用户 | 时间
|
bbc1ee
|
1 |
package com.iailab.module.model.mcs.sche.service.impl; |
潘 |
2 |
|
|
3 |
import com.iailab.framework.common.service.impl.BaseServiceImpl; |
|
4 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
5 |
import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX; |
|
6 |
import com.iailab.module.model.mcs.sche.dao.StScheduleModelParamDao; |
|
7 |
import com.iailab.module.model.mcs.sche.entity.StScheduleModelParamEntity; |
|
8 |
import com.iailab.module.model.mcs.sche.service.StScheduleModelParamService; |
|
9 |
import com.iailab.module.model.mcs.sche.vo.StScheduleModelParamSaveReqVO; |
|
10 |
import org.springframework.stereotype.Service; |
|
11 |
import org.springframework.util.CollectionUtils; |
|
12 |
|
|
13 |
import java.util.List; |
45520a
|
14 |
import java.util.Map; |
bbc1ee
|
15 |
import java.util.UUID; |
45520a
|
16 |
import java.util.concurrent.ConcurrentHashMap; |
bbc1ee
|
17 |
|
潘 |
18 |
/** |
|
19 |
* @author PanZhibao |
|
20 |
* @Description |
|
21 |
* @createTime 2024年09月06日 |
|
22 |
*/ |
|
23 |
@Service |
|
24 |
public class StScheduleModelParamServiceImpl extends BaseServiceImpl<StScheduleModelParamDao, StScheduleModelParamEntity> |
|
25 |
implements StScheduleModelParamService { |
45520a
|
26 |
|
D |
27 |
private static Map<String, List<StScheduleModelParamEntity>> modelInputParamMap = new ConcurrentHashMap<>(); |
bbc1ee
|
28 |
|
潘 |
29 |
@Override |
|
30 |
public List<StScheduleModelParamEntity> getByModelId(String modelId) { |
|
31 |
return baseDao.selectList( |
|
32 |
new LambdaQueryWrapperX<StScheduleModelParamEntity>() |
|
33 |
.likeIfPresent(StScheduleModelParamEntity::getModelid, modelId) |
|
34 |
.orderByAsc(StScheduleModelParamEntity::getModelparamportorder) |
|
35 |
.orderByAsc(StScheduleModelParamEntity::getModelparamorder) |
|
36 |
); |
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
public void deleteByModelId(String modelId) { |
|
41 |
baseDao.delete(new LambdaQueryWrapperX<StScheduleModelParamEntity>() |
|
42 |
.likeIfPresent(StScheduleModelParamEntity::getModelid, modelId) |
|
43 |
); |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public void saveList(String modelId, List<StScheduleModelParamSaveReqVO> saveList) { |
|
48 |
deleteByModelId(modelId); |
|
49 |
if (CollectionUtils.isEmpty(saveList)) { |
|
50 |
return; |
|
51 |
} |
|
52 |
saveList.forEach(item -> { |
|
53 |
StScheduleModelParamEntity entity = BeanUtils.toBean(item, StScheduleModelParamEntity.class); |
|
54 |
entity.setId(UUID.randomUUID().toString()); |
056470
|
55 |
entity.setModelid(modelId); |
bbc1ee
|
56 |
baseDao.insert(entity); |
潘 |
57 |
}); |
45520a
|
58 |
clearCache(); |
D |
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
public List<StScheduleModelParamEntity> getByModelidFromCache(String modelId) { |
|
63 |
if (!modelInputParamMap.containsKey(modelId)) { |
|
64 |
List<StScheduleModelParamEntity> list = getByModelId(modelId); |
|
65 |
if (list != null) { |
|
66 |
modelInputParamMap.put(modelId, list); |
|
67 |
} else { |
|
68 |
return null; |
|
69 |
} |
|
70 |
} |
|
71 |
return modelInputParamMap.get(modelId); |
|
72 |
} |
|
73 |
|
|
74 |
public void clearCache() { |
|
75 |
modelInputParamMap.clear(); |
bbc1ee
|
76 |
} |
潘 |
77 |
} |