From 1f04768f05d4a68f0f16456b7934f729dea9fb83 Mon Sep 17 00:00:00 2001
From: zhuguifei <zhuguifei@zhuguifeideiMac.local>
Date: 星期一, 01 九月 2025 08:36:27 +0800
Subject: [PATCH] 去除MQTT log,优化设备列表接口

---
 jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryEquipmentController.java |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryEquipmentController.java b/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryEquipmentController.java
index 0bf2aac..cb7eda1 100755
--- a/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryEquipmentController.java
+++ b/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryEquipmentController.java
@@ -12,10 +12,15 @@
 import javax.servlet.http.HttpServletResponse;
 
 import cn.hutool.core.bean.BeanUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.config.TenantContext;
+import org.jeecg.common.constant.CommonCacheConstant;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.RedisUtil;
+import org.jeecg.common.util.TokenUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
 import org.jeecg.modules.dry.common.CacheConstants;
@@ -38,6 +43,7 @@
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jetbrains.annotations.NotNull;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
@@ -103,6 +109,11 @@
 		//鏄惁寮�鍚郴缁熺鐞嗘ā鍧楃殑澶氱鎴锋暟鎹殧绂汇�怱AAS澶氱鎴锋ā寮忋��
 		if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
 			dryEquipment.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(),0));
+			//fix: shiro鎺掗櫎鐨勬帴鍙f棤娉曚粠jwt鑾峰彇tenantId
+			String tenantId = TokenUtils.getTenantIdByRequest(req);
+			if(StringUtils.isNotEmpty(tenantId)){
+				dryEquipment.setTenantId(Integer.parseInt(tenantId));
+			}
 		}
 		//------------------------------------------------------------------------------------------------
 		QueryWrapper<DryEquipment> queryWrapper = QueryGenerator.initQueryWrapper(dryEquipment, req.getParameterMap());
@@ -116,9 +127,17 @@
 		 queryWrapper.orderByAsc("code");
 		 List<DryEquipment> eqps = dryEquipmentService.list(queryWrapper);
 		 List<DryEquipmentVo> equipmentVos = new ArrayList<>();
+		 if(eqps == null){
+			 return equipmentVos;
+		 }
+
 		 eqps.stream().forEach(item -> {
 			 DryEquipmentVo dryEquipmentVo = BeanUtil.toBean(item, DryEquipmentVo.class);
 			 DryEqpType dryEqpType = dryEqpTypeService.getById(item.getType());
+			 if(dryEqpType == null){
+				 equipmentVos.add(dryEquipmentVo);
+				 return;
+			 }
 			 dryEquipmentVo.setType(dryEqpType.getName());
 			 dryEquipmentVo.setDryEfficiency(dryEqpType.getDryEfficiency());
 			 dryEquipmentVo.setSteamConsumption(dryEqpType.getSteamConsumption());
@@ -154,8 +173,10 @@
 	@ApiOperation(value="骞茬嚗鏈�-娣诲姞", notes="骞茬嚗鏈�-娣诲姞")
 	@RequiresPermissions("dry:dry_equipment:add")
 	@PostMapping(value = "/add")
+	@CacheEvict(value = {CommonCacheConstant.DRY_CACHE_TENANT_EQUS_LIST,CommonCacheConstant.DRY_CACHE_TENANT_EQUS},allEntries=true)
 	public Result<String> add(@RequestBody DryEquipment dryEquipment) {
 		dryEquipmentService.save(dryEquipment);
+		redisUtil.del(CacheConstants.RedisKeyEnum.EQP_MAP.getCode());
 		return Result.OK("娣诲姞鎴愬姛锛�");
 	}
 
@@ -169,11 +190,11 @@
 	@ApiOperation(value="骞茬嚗鏈�-缂栬緫", notes="骞茬嚗鏈�-缂栬緫")
 	@RequiresPermissions("dry:dry_equipment:edit")
 	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
+	@CacheEvict(value = {CommonCacheConstant.DRY_CACHE_TENANT_EQUS_LIST,CommonCacheConstant.DRY_CACHE_TENANT_EQUS},allEntries=true)
 	public Result<String> edit(@RequestBody DryEquipment dryEquipment) {
 		// 鍒犻櫎redis缂撳瓨
 		redisUtil.del(CacheConstants.RedisKeyEnum.EQP_MAP.getCode());
 		dryEquipmentService.updateById(dryEquipment);
-
 		return Result.OK("缂栬緫鎴愬姛!");
 	}
 
@@ -187,6 +208,7 @@
 	@ApiOperation(value="骞茬嚗鏈�-閫氳繃id鍒犻櫎", notes="骞茬嚗鏈�-閫氳繃id鍒犻櫎")
 	@RequiresPermissions("dry:dry_equipment:delete")
 	@DeleteMapping(value = "/delete")
+	@CacheEvict(value = {CommonCacheConstant.DRY_CACHE_TENANT_EQUS_LIST,CommonCacheConstant.DRY_CACHE_TENANT_EQUS},allEntries=true)
 	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
 		redisUtil.del(CacheConstants.RedisKeyEnum.EQP_MAP.getCode());
 		dryEquipmentService.removeById(id);
@@ -203,6 +225,7 @@
 	@ApiOperation(value="骞茬嚗鏈�-鎵归噺鍒犻櫎", notes="骞茬嚗鏈�-鎵归噺鍒犻櫎")
 	@RequiresPermissions("dry:dry_equipment:deleteBatch")
 	@DeleteMapping(value = "/deleteBatch")
+	@CacheEvict(value = {CommonCacheConstant.DRY_CACHE_TENANT_EQUS_LIST,CommonCacheConstant.DRY_CACHE_TENANT_EQUS},allEntries=true)
 	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
 		redisUtil.del(CacheConstants.RedisKeyEnum.EQP_MAP.getCode());
 		this.dryEquipmentService.removeByIds(Arrays.asList(ids.split(",")));

--
Gitblit v1.9.3