From a440ec3bfaa1363f5841100b8948d852971a2eb1 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期二, 10 十二月 2024 13:19:58 +0800
Subject: [PATCH] MmPredictAlarmConfigService

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemTypeImpl.java |   66 ++++++++++++++++++---------------
 1 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemTypeImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemTypeImpl.java
index 17344d5..02b2f0f 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemTypeImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemTypeImpl.java
@@ -1,84 +1,90 @@
 package com.iailab.module.model.mcs.pre.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.iailab.framework.common.pojo.PageResult;
 import com.iailab.framework.common.service.impl.BaseServiceImpl;
 import com.iailab.framework.common.util.collection.CollectionUtils;
 import com.iailab.module.model.mcs.pre.dao.MmItemTypeDao;
+import com.iailab.module.model.mcs.pre.entity.DmModuleItemEntity;
 import com.iailab.module.model.mcs.pre.entity.MmItemTypeEntity;
 import com.iailab.module.model.mcs.pre.service.MmItemTypeService;
 import com.iailab.module.model.mcs.pre.vo.MmItemTypePageReqVO;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * @author PanZhibao
  * @date 2021年04月23日 15:29
  */
-@Service("mmItemTypeService")
-public class MmItemTypeImpl extends BaseServiceImpl<MmItemTypeDao, MmItemTypeEntity> implements MmItemTypeService {
+@Service
+public class MmItemTypeImpl extends ServiceImpl<MmItemTypeDao, MmItemTypeEntity> implements MmItemTypeService {
 
+    @Autowired
+    private MmItemTypeDao mmItemTypeDao;
+
+    private Map<String, MmItemTypeEntity> typeIdMap = new ConcurrentHashMap<>();
+    
     @Override
     public PageResult<MmItemTypeEntity> page(MmItemTypePageReqVO reqVO) {
-        return baseDao.selectPage(reqVO);
-    }
-
-    private QueryWrapper<MmItemTypeEntity> getWrapper(Map<String, Object> params) {
-        String itemtypename = (String)params.get("itemtypename");
-
-        QueryWrapper<MmItemTypeEntity> wrapper = new QueryWrapper<>();
-        wrapper.like(StringUtils.isNotBlank(itemtypename),"itemtypename", itemtypename);
-
-        return wrapper;
+        return mmItemTypeDao.selectPage(reqVO);
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
     public void saveItemType(MmItemTypeEntity itemType) {
         itemType.setId(UUID.randomUUID().toString());
-        baseDao.insert(itemType);
+        mmItemTypeDao.insert(itemType);
+        typeIdMap.clear();
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
     public void update(MmItemTypeEntity itemType) {
-        baseDao.updateById(itemType);
+        mmItemTypeDao.updateById(itemType);
+        typeIdMap.clear();
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
     public void deleteBatch(String[] moduleIds) {
-        baseDao.deleteBatchIds(Arrays.asList(moduleIds));
+        mmItemTypeDao.deleteBatchIds(Arrays.asList(moduleIds));
+        typeIdMap.clear();
     }
 
     @Override
     public int check(MmItemTypeEntity itemType) {
         String id = itemType.getId();
         String itemtypename = itemType.getItemtypename();
-        QueryWrapper<MmItemTypeEntity> moduleWrapper = new QueryWrapper<>();
+        QueryWrapper<MmItemTypeEntity> moduleWrapper = new QueryWrapper();
         moduleWrapper.ne(StringUtils.isNotBlank(id), "id", id);
         moduleWrapper.and(wrapper -> wrapper.eq("itemtypename",itemtypename));
-        List<MmItemTypeEntity> list = baseDao.selectList(moduleWrapper);
+        List<MmItemTypeEntity> list = mmItemTypeDao.selectList(moduleWrapper);
         return list.size();
-    }
-
-    public MmItemTypeEntity getById(String itemtypeid) {
-        MmItemTypeEntity entity = baseDao.selectById(itemtypeid);
-        return entity;
     }
 
     @Override
     public MmItemTypeEntity getItemTypeByItemId(String itemId) {
-        List<MmItemTypeEntity> list = baseDao.getItemTypeByItemId(itemId);
+        if (typeIdMap.containsKey(itemId)) {
+            return typeIdMap.get(itemId);
+        }
+        List<MmItemTypeEntity> list = mmItemTypeDao.getItemTypeByItemId(itemId);
         if (CollectionUtils.isAnyEmpty(list)) {
             return null;
         }
+        typeIdMap.put(itemId, list.get(0));
         return list.get(0);
     }
+
+    @Override
+    public MmItemTypeEntity info(String id) {
+        return mmItemTypeDao.selectById(id);
+    }
+
+    @Override
+    public List<MmItemTypeEntity> list(Map<String, Object> params) {
+        return mmItemTypeDao.selectList(new QueryWrapper<>());
+    }
 }

--
Gitblit v1.9.3