瀏覽代碼

fix bug:处理ThreadLocal造成的内存泄漏问题

lijie 3 年之前
父節點
當前提交
b9dc0ecbe7
共有 1 個文件被更改,包括 28 次插入20 次删除
  1. 28 20
      src/main/java/com/persagy/proxy/dictionary/service/impl/AdmModelRelServiceImpl.java

+ 28 - 20
src/main/java/com/persagy/proxy/dictionary/service/impl/AdmModelRelServiceImpl.java

@@ -99,20 +99,24 @@ public class AdmModelRelServiceImpl extends AbstractAdmBaseServiceImpl<AdmModelR
     @Override
     public void processFloorCalState(InstanceUrlParam context, String modelId) {
         resetContext(context);
-        List<AdmFloor> floorList = queryFloorEntity(context, modelId, null);
-        if(CollUtil.isEmpty(floorList)) {
-            return;
-        }
-        Set<String> floorQueryTypes = getFloorQueryTypes(floorList);
-        List<ObjectRelationProjectCal> needCals = relationCalService.queryCalRelByRelationType(context, floorQueryTypes);
-        if(CollUtil.isEmpty(needCals)) {
-            return;
+        try {
+            List<AdmFloor> floorList = queryFloorEntity(context, modelId, null);
+            if(CollUtil.isEmpty(floorList)) {
+                return;
+            }
+            Set<String> floorQueryTypes = getFloorQueryTypes(floorList);
+            List<ObjectRelationProjectCal> needCals = relationCalService.queryCalRelByRelationType(context, floorQueryTypes);
+            if(CollUtil.isEmpty(needCals)) {
+                return;
+            }
+            //更新边类型计算状态:computationalState为2
+            needCals.forEach(item->{
+                item.setComputationalState(2);
+            });
+            relationCalService.updateObjectCalRel(context, needCals);
+        }finally {
+            AppContext.unload();
         }
-        //更新边类型计算状态:computationalState为2
-        needCals.forEach(item->{
-            item.setComputationalState(2);
-        });
-        relationCalService.updateObjectCalRel(context, needCals);
     }
 
     /**
@@ -126,14 +130,18 @@ public class AdmModelRelServiceImpl extends AbstractAdmBaseServiceImpl<AdmModelR
     @Override
     public void processRelObjects(InstanceUrlParam context, String oldBimId, String bimId, AdmFloor floor) {
         resetContext(context);
-        // 如果bimId不一致,则清空原来的楼层信息
-        if(StrUtil.isNotBlank(oldBimId) && !StrUtil.equals(oldBimId, bimId)) {
-            updateRelEquipments(context, oldBimId, floor, true);
-            updateRelISpace(context, oldBimId, floor, true);
+        try {
+            // 如果bimId不一致,则清空原来的楼层信息
+            if(StrUtil.isNotBlank(oldBimId) && !StrUtil.equals(oldBimId, bimId)) {
+                updateRelEquipments(context, oldBimId, floor, true);
+                updateRelISpace(context, oldBimId, floor, true);
+            }
+            // 更新新关联的
+            updateRelEquipments(context, bimId, floor, false);
+            updateRelISpace(context, bimId, floor, false);
+        }finally {
+            AppContext.unload();
         }
-        // 更新新关联的
-        updateRelEquipments(context, bimId, floor, false);
-        updateRelISpace(context, bimId, floor, false);
     }
     /***
      * Description: 重新设置一下上下文