| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | |
| | | @Autowired |
| | | private MmPredictModelDao mmPredictModelDao; |
| | | |
| | | private static Map<String, MmPredictModelEntity> modelEntityMap = new ConcurrentHashMap<>(); |
| | | |
| | | @Override |
| | | public void savePredictModel(MmPredictModelEntity predictModel) { |
| | | predictModel.setId(UUID.randomUUID().toString()); |
| | | mmPredictModelDao.insert(predictModel); |
| | | clearCache(); |
| | | } |
| | | |
| | | @Override |
| | | public void update(MmPredictModelEntity predictModel) { |
| | | this.updateById(predictModel); |
| | | clearCache(); |
| | | } |
| | | |
| | | @Override |
| | | public MmPredictModelEntity getInfoFromCatch(String id) { |
| | | if (!modelEntityMap.containsKey(id)) { |
| | | MmPredictModelEntity modelEntity = getInfo(id); |
| | | if (modelEntity != null) { |
| | | modelEntityMap.put(id, modelEntity); |
| | | } |
| | | } |
| | | return modelEntityMap.get(id); |
| | | } |
| | | |
| | | @Override |
| | | public void clearCache() { |
| | | modelEntityMap.clear(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | QueryWrapper<MmPredictModelEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.in("itemid", itemIds); |
| | | mmPredictModelDao.delete(queryWrapper); |
| | | clearCache(); |
| | | } |
| | | |
| | | public MmPredictModelEntity getByItemid(String itemid) { |