jiangping
2023-09-19 0b9c144b5110a7e2a85b2e5581ef304bb81a3ebc
server/service/src/main/java/com/doumee/service/impl/CateParamSelectServiceImpl.java
@@ -4,16 +4,20 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.doumee.core.model.LoginUserInfo;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.CateParamSelectMapper;
import com.doumee.dao.business.model.CateParamSelect;
import com.doumee.service.CateParamSelectService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.List;
@@ -28,6 +32,7 @@
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private CateParamSelectMapper cateParamSelectMapper;
@@ -149,22 +154,23 @@
    @Override
    @Async
    public   void dealGroupVals(Integer companyId) {
        Boolean  isGrouping = (Boolean)redisTemplate.opsForValue().get(companyId+"_isGrouping");
    @Transactional
    public  void dealCateParamSelect() {
        LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        Boolean  isGrouping = (Boolean)redisTemplate.opsForValue().get(loginUserInfo.getCompanyId()+Constants.CATE_PARAM_OPEN);
        if(isGrouping!=null && isGrouping ){
            return;
        }
        redisTemplate.opsForValue().set(companyId+"_isGrouping",true);
        redisTemplate.opsForValue().set(loginUserInfo.getCompanyId()+Constants.CATE_PARAM_OPEN,true);
        try {
            //---------TODO-------任康
            //删除企业下历史数据
            cateParamSelectMapper.delete(new QueryWrapper<CateParamSelect>().exists(" select 1 from category c where c.id = cate_param_select.category_id and  c.company_id = "+loginUserInfo.getCompanyId()+"   "));
            //新增当前企业可以使用的数据
            cateParamSelectMapper.insertBatch(loginUserInfo.getCompanyId(),loginUserInfo.getId());
        }catch (Exception e){
        }finally {
            redisTemplate.opsForValue().set(companyId+"_isGrouping",false);
            redisTemplate.opsForValue().set(loginUserInfo.getCompanyId()+Constants.CATE_PARAM_OPEN,false);
        }
    }
}