提交 | 用户 | 时间
|
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.MmItemOutputDao; |
5c6007
|
6 |
import com.iailab.module.model.mcs.pre.dto.MmItemOutputDTO; |
7fd198
|
7 |
import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; |
潘 |
8 |
import com.iailab.module.model.mcs.pre.service.MmItemOutputService; |
bdab69
|
9 |
import org.apache.commons.lang3.StringUtils; |
5c6007
|
10 |
import org.springframework.beans.factory.annotation.Autowired; |
7fd198
|
11 |
import org.springframework.stereotype.Service; |
373ab1
|
12 |
import org.springframework.util.CollectionUtils; |
7fd198
|
13 |
|
潘 |
14 |
import java.util.List; |
|
15 |
import java.util.Map; |
a4891a
|
16 |
import java.util.concurrent.ConcurrentHashMap; |
7fd198
|
17 |
|
潘 |
18 |
/** |
|
19 |
* @author PanZhibao |
|
20 |
* @date 2021年04月27日 9:22 |
|
21 |
*/ |
5c6007
|
22 |
@Service |
L |
23 |
public class MmItemOutputServiceImpl extends ServiceImpl<MmItemOutputDao, MmItemOutputEntity> implements MmItemOutputService { |
7fd198
|
24 |
|
5c6007
|
25 |
@Autowired |
L |
26 |
private MmItemOutputDao mmItemOutputDao; |
a4891a
|
27 |
|
潘 |
28 |
private static Map<String, MmItemOutputEntity> outputMap = new ConcurrentHashMap<>(); |
373ab1
|
29 |
|
潘 |
30 |
private static Map<String, List<MmItemOutputEntity>> itemMap = new ConcurrentHashMap<>(); |
5c6007
|
31 |
|
7fd198
|
32 |
@Override |
69bd5e
|
33 |
public void saveMmItemOutput(List<MmItemOutputEntity> mmItemOutput) { |
9c21cd
|
34 |
mmItemOutput.forEach(e -> { |
D |
35 |
e.setId(e.getId().replace("+","").replace("-","")); |
|
36 |
}); |
5c6007
|
37 |
mmItemOutputDao.insert(mmItemOutput); |
a4891a
|
38 |
// 清空缓存 |
373ab1
|
39 |
clearCache(); |
7fd198
|
40 |
} |
潘 |
41 |
|
|
42 |
@Override |
|
43 |
public void update(MmItemOutputEntity mmItemOutput) { |
5c6007
|
44 |
mmItemOutputDao.updateById(mmItemOutput); |
a4891a
|
45 |
// 清空缓存 |
373ab1
|
46 |
clearCache(); |
7fd198
|
47 |
} |
潘 |
48 |
|
|
49 |
public void deleteBatch(String[] itemIds) { |
f283ee
|
50 |
QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper<>(); |
7fd198
|
51 |
queryWrapper.in("itemid", itemIds); |
5c6007
|
52 |
mmItemOutputDao.delete(queryWrapper); |
a4891a
|
53 |
// 清空缓存 |
373ab1
|
54 |
clearCache(); |
潘 |
55 |
} |
|
56 |
|
|
57 |
private void clearCache() { |
a4891a
|
58 |
outputMap.clear(); |
373ab1
|
59 |
itemMap.clear(); |
7fd198
|
60 |
} |
潘 |
61 |
|
|
62 |
@Override |
373ab1
|
63 |
public List<MmItemOutputEntity> getByItemid(String itemId) { |
潘 |
64 |
if (itemMap.containsKey(itemId)) { |
|
65 |
return itemMap.get(itemId); |
|
66 |
} |
b368e6
|
67 |
QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper<>(); |
373ab1
|
68 |
queryWrapper.eq("itemid", itemId).orderByAsc("outputorder"); |
5c6007
|
69 |
List<MmItemOutputEntity> list = mmItemOutputDao.selectList(queryWrapper); |
373ab1
|
70 |
if (CollectionUtils.isEmpty(list)) { |
潘 |
71 |
return null; |
|
72 |
} |
|
73 |
itemMap.put(itemId, list); |
|
74 |
return itemMap.get(itemId); |
69bd5e
|
75 |
} |
D |
76 |
|
|
77 |
@Override |
bdab69
|
78 |
public MmItemOutputEntity getByItemid(String itemid, String resultstr, String resultIndex) { |
b368e6
|
79 |
QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper<>(); |
bd9085
|
80 |
queryWrapper.eq("itemid", itemid) |
潘 |
81 |
.eq("resultstr", resultstr) |
bdab69
|
82 |
.eq(StringUtils.isNotBlank(resultIndex), "result_index", resultIndex); |
b368e6
|
83 |
return mmItemOutputDao.selectOne(queryWrapper); |
潘 |
84 |
} |
|
85 |
|
|
86 |
@Override |
69bd5e
|
87 |
public void deleteByItemId(String itemId) { |
f283ee
|
88 |
QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper<>(); |
69bd5e
|
89 |
queryWrapper.eq("itemid", itemId); |
D |
90 |
mmItemOutputDao.delete(queryWrapper); |
7fd198
|
91 |
} |
潘 |
92 |
|
|
93 |
@Override |
|
94 |
public List<MmItemOutputDTO> queryList(Map<String, Object> params) { |
5c6007
|
95 |
return mmItemOutputDao.queryList(params); |
7fd198
|
96 |
} |
潘 |
97 |
|
|
98 |
@Override |
a4891a
|
99 |
public MmItemOutputEntity getOutPutById(String outputid) { |
潘 |
100 |
if (outputMap.containsKey(outputid)) { |
|
101 |
return outputMap.get(outputid); |
7fd198
|
102 |
} |
a4891a
|
103 |
MmItemOutputEntity entity = mmItemOutputDao.selectById(outputid); |
潘 |
104 |
outputMap.put(outputid, entity); |
|
105 |
return entity; |
7fd198
|
106 |
} |
潘 |
107 |
} |