提交 | 用户 | 时间
|
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 |
b368e6
|
77 |
public MmItemOutputEntity getByItemid(String itemid, String resultstr) { |
潘 |
78 |
QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper<>(); |
|
79 |
queryWrapper.eq("itemid", itemid).eq("resultstr", resultstr); |
|
80 |
return mmItemOutputDao.selectOne(queryWrapper); |
|
81 |
} |
|
82 |
|
|
83 |
@Override |
69bd5e
|
84 |
public void deleteByItemId(String itemId) { |
f283ee
|
85 |
QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper<>(); |
69bd5e
|
86 |
queryWrapper.eq("itemid", itemId); |
D |
87 |
mmItemOutputDao.delete(queryWrapper); |
7fd198
|
88 |
} |
潘 |
89 |
|
|
90 |
@Override |
|
91 |
public List<MmItemOutputDTO> queryList(Map<String, Object> params) { |
5c6007
|
92 |
return mmItemOutputDao.queryList(params); |
7fd198
|
93 |
} |
潘 |
94 |
|
|
95 |
@Override |
a4891a
|
96 |
public MmItemOutputEntity getOutPutById(String outputid) { |
潘 |
97 |
if (outputMap.containsKey(outputid)) { |
|
98 |
return outputMap.get(outputid); |
7fd198
|
99 |
} |
a4891a
|
100 |
MmItemOutputEntity entity = mmItemOutputDao.selectById(outputid); |
潘 |
101 |
outputMap.put(outputid, entity); |
|
102 |
return entity; |
7fd198
|
103 |
} |
潘 |
104 |
} |