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