old mode 100644
new mode 100755
| | |
| | | package org.jeecg.modules.dry.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.config.TenantContext; |
| | | import org.jeecg.common.constant.CommonCacheConstant; |
| | | import org.jeecg.common.util.RedisUtil; |
| | | import org.jeecg.modules.dry.common.CacheConstants; |
| | | import org.jeecg.modules.dry.entity.DryEquipment; |
| | | import org.jeecg.modules.dry.mapper.DryEquipmentMapper; |
| | | import org.jeecg.modules.dry.service.IDryEquipmentService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: 干燥机 |
| | |
| | | @Service |
| | | public class DryEquipmentServiceImpl extends ServiceImpl<DryEquipmentMapper, DryEquipment> implements IDryEquipmentService { |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | @Override |
| | | public DryEquipment selectByTenantIdEquipmentId(String tenantId, String equipmentId) { |
| | | DryEquipment dryEquipment = (DryEquipment) redisUtil.hget(CacheConstants.RedisKeyEnum.EQP_MAP.getCode(), tenantId + equipmentId); |
| | | if (dryEquipment == null) { |
| | | List<DryEquipment> list = this.list(); |
| | | for (DryEquipment equipment : list) { |
| | | redisUtil.hset(CacheConstants.RedisKeyEnum.EQP_MAP.getCode(),equipment.getTenantId()+equipment.getCode(),equipment); |
| | | // 设置过期时间 |
| | | if ((equipment.getTenantId()+equipment.getCode()).equals(tenantId + equipmentId)) { |
| | | dryEquipment = equipment; |
| | | } |
| | | } |
| | | } |
| | | return dryEquipment; |
| | | } |
| | | |
| | | @Override |
| | | @Cacheable(cacheNames = CommonCacheConstant.DRY_CACHE_TENANT_EQUS, key = "#tenantId" , unless = "#result == null " ) |
| | | public Map<String,DryEquipment> queryEquByTenantId(Integer tenantId) { |
| | | TenantContext.setTenant(tenantId +""); |
| | | QueryWrapper<DryEquipment> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.lambda().eq(DryEquipment::getTenantId,tenantId); |
| | | List<DryEquipment> equipmentList = this.list(queryWrapper); |
| | | Map<String, DryEquipment> userMap = equipmentList.stream() |
| | | .collect(Collectors.toMap( |
| | | DryEquipment::getCode, |
| | | Function.identity(), |
| | | (existingValue, newValue) -> existingValue // 如果键冲突,保留旧值 |
| | | )); |
| | | return userMap; |
| | | } |
| | | |
| | | @Override |
| | | @Cacheable(cacheNames = CommonCacheConstant.DRY_CACHE_TENANT_EQUS_LIST, key = "#dryEquipment.tenantId+':'+#dryEquipment.enable" , unless = "#result == null " ) |
| | | public List<DryEquipment> queryEqusByTenantId(DryEquipment dryEquipment) { |
| | | TenantContext.setTenant(dryEquipment.getTenantId() +""); |
| | | QueryWrapper<DryEquipment> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.lambda().eq(DryEquipment::getTenantId,dryEquipment.getTenantId()); |
| | | if (dryEquipment.getEnable()!=null){ |
| | | queryWrapper.lambda().eq(DryEquipment::getEnable,dryEquipment.getEnable()); |
| | | } |
| | | List<DryEquipment> equipmentList = this.list(queryWrapper); |
| | | return equipmentList; |
| | | } |
| | | } |