提交 | 用户 | 时间
|
7fd198
|
1 |
package com.iailab.module.model.mcs.pre.service.impl; |
潘 |
2 |
|
|
3 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
5c6007
|
4 |
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
7fd198
|
5 |
import com.iailab.module.model.mcs.pre.dao.MmModelArithSettingsDao; |
潘 |
6 |
import com.iailab.module.model.mcs.pre.entity.MmModelArithSettingsEntity; |
|
7 |
import com.iailab.module.model.mcs.pre.service.MmModelArithSettingsService; |
5c6007
|
8 |
import org.springframework.beans.factory.annotation.Autowired; |
7fd198
|
9 |
import org.springframework.stereotype.Service; |
潘 |
10 |
import org.springframework.util.CollectionUtils; |
|
11 |
|
|
12 |
import java.util.*; |
214275
|
13 |
import java.util.concurrent.ConcurrentHashMap; |
7fd198
|
14 |
|
潘 |
15 |
/** |
|
16 |
* @author PanZhibao |
|
17 |
* @date 2021年04月27日 9:24 |
|
18 |
*/ |
|
19 |
@Service |
5c6007
|
20 |
public class MmModelArithSettingsServiceImpl extends ServiceImpl<MmModelArithSettingsDao, MmModelArithSettingsEntity> |
7fd198
|
21 |
implements MmModelArithSettingsService { |
潘 |
22 |
|
5c6007
|
23 |
@Autowired |
L |
24 |
private MmModelArithSettingsDao mmModelArithSettingsDao; |
e6753e
|
25 |
|
214275
|
26 |
private static Map<String, List<MmModelArithSettingsEntity>> modelIdMap = new ConcurrentHashMap<>(); |
潘 |
27 |
|
7fd198
|
28 |
@Override |
潘 |
29 |
public void saveList(List<MmModelArithSettingsEntity> list) { |
|
30 |
QueryWrapper<MmModelArithSettingsEntity> queryWrapper = new QueryWrapper(); |
|
31 |
queryWrapper.eq("modelid", list.get(0).getModelid()); |
5c6007
|
32 |
mmModelArithSettingsDao.delete(queryWrapper); |
7fd198
|
33 |
list.forEach(item -> { |
潘 |
34 |
item.setId(UUID.randomUUID().toString()); |
|
35 |
}); |
5c6007
|
36 |
mmModelArithSettingsDao.insertList(list); |
7fd198
|
37 |
|
214275
|
38 |
// 清空缓存 |
潘 |
39 |
modelIdMap.clear(); |
7fd198
|
40 |
} |
潘 |
41 |
|
|
42 |
@Override |
|
43 |
public List<MmModelArithSettingsEntity> getByModelId(String modelId) { |
214275
|
44 |
if (modelIdMap.containsKey(modelId)) { |
潘 |
45 |
return modelIdMap.get(modelId); |
|
46 |
} |
|
47 |
Map<String, Object> params = new HashMap<>(1); |
1a2b62
|
48 |
params.put("modelid", modelId); |
214275
|
49 |
List<MmModelArithSettingsEntity> list = mmModelArithSettingsDao.getMmModelArithSettings(params); |
潘 |
50 |
if (CollectionUtils.isEmpty(list)) { |
|
51 |
list = new ArrayList<>(); |
|
52 |
} |
|
53 |
modelIdMap.put(modelId, list); |
|
54 |
return list; |
7fd198
|
55 |
} |
826d35
|
56 |
|
D |
57 |
@Override |
|
58 |
public void updatePyFile(String pyModule, String fileName) { |
56e36d
|
59 |
baseMapper.updatePyFile(pyModule + "." + fileName.substring(0,fileName.lastIndexOf("_")+1),pyModule + "." + fileName); |
826d35
|
60 |
} |
7fd198
|
61 |
} |