From 0cbbe2c1cbfbf73e02e1796d921c2911c96d370b Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期一, 23 十二月 2024 11:46:31 +0800
Subject: [PATCH] Merge branch 'master' of http://dlindusit.com:53929/r/iailab-plat

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmModelArithSettingsServiceImpl.java |   48 +++++++++++++++++++++++++++++++-----------------
 1 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmModelArithSettingsServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmModelArithSettingsServiceImpl.java
index fff6acd..dc13a83 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmModelArithSettingsServiceImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmModelArithSettingsServiceImpl.java
@@ -1,49 +1,63 @@
 package com.iailab.module.model.mcs.pre.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.iailab.framework.common.service.impl.BaseServiceImpl;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.iailab.module.model.mcs.pre.dao.MmModelArithSettingsDao;
 import com.iailab.module.model.mcs.pre.entity.MmModelArithSettingsEntity;
 import com.iailab.module.model.mcs.pre.service.MmModelArithSettingsService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * @author PanZhibao
  * @date 2021年04月27日 9:24
  */
 @Service
-public class MmModelArithSettingsServiceImpl extends BaseServiceImpl<MmModelArithSettingsDao, MmModelArithSettingsEntity>
+public class MmModelArithSettingsServiceImpl extends ServiceImpl<MmModelArithSettingsDao, MmModelArithSettingsEntity>
         implements MmModelArithSettingsService {
+
+    @Autowired
+    private MmModelArithSettingsDao mmModelArithSettingsDao;
+
+    private static Map<String, List<MmModelArithSettingsEntity>> modelIdMap = new ConcurrentHashMap<>();
 
     @Override
     public void saveList(List<MmModelArithSettingsEntity> list) {
         QueryWrapper<MmModelArithSettingsEntity> queryWrapper = new QueryWrapper();
         queryWrapper.eq("modelid", list.get(0).getModelid());
-        baseDao.delete(queryWrapper);
+        mmModelArithSettingsDao.delete(queryWrapper);
         list.forEach(item -> {
             item.setId(UUID.randomUUID().toString());
         });
-        baseDao.insertList(list);
-    }
+        mmModelArithSettingsDao.insertList(list);
 
-    public List<MmModelArithSettingsEntity> getByModelid(String modelid) {
-        Map<String, Object> params = new HashMap<>(1);
-        params.put("modelid", modelid);
-        List<MmModelArithSettingsEntity> list = baseDao.getMmModelArithSettings(params);
-
-        if (CollectionUtils.isEmpty(list)) {
-            return new ArrayList<>();
-        }
-        return list;
+        // 清空缓存
+        modelIdMap.clear();
     }
 
     @Override
     public List<MmModelArithSettingsEntity> getByModelId(String modelId) {
-        QueryWrapper<MmModelArithSettingsEntity> queryWrapper = new QueryWrapper();
-        queryWrapper.eq("modelid", modelId);
-        return baseDao.selectList(queryWrapper);
+        if (modelIdMap.containsKey(modelId)) {
+            return modelIdMap.get(modelId);
+        }
+        Map<String, Object> params = new HashMap<>(1);
+        params.put("modelid", modelId);
+        List<MmModelArithSettingsEntity> list =  mmModelArithSettingsDao.getMmModelArithSettings(params);
+        if (CollectionUtils.isEmpty(list)) {
+            list = new ArrayList<>();
+        }
+        modelIdMap.put(modelId, list);
+        return list;
+    }
+
+    @Override
+    public void updatePyFile(String pyModule, String fileName) {
+        baseMapper.updatePyFile(pyModule + "." + fileName.substring(0,fileName.lastIndexOf("_")+1),pyModule + "." + fileName);
+        // 清空缓存
+        modelIdMap.clear();
     }
 }

--
Gitblit v1.9.3