From 3c4d486d9d41d9aee4da312b68db19ac9332420e Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期六, 08 二月 2025 18:15:20 +0800 Subject: [PATCH] aaa --- server/service/src/main/java/com/doumee/service/impl/CateParamSelectServiceImpl.java | 71 ++++++++++++++++++++++++++++++++++- 1 files changed, 69 insertions(+), 2 deletions(-) diff --git a/server/service/src/main/java/com/doumee/service/impl/CateParamSelectServiceImpl.java b/server/service/src/main/java/com/doumee/service/impl/CateParamSelectServiceImpl.java index 62bd13a..bc5ea07 100644 --- a/server/service/src/main/java/com/doumee/service/impl/CateParamSelectServiceImpl.java +++ b/server/service/src/main/java/com/doumee/service/impl/CateParamSelectServiceImpl.java @@ -4,14 +4,23 @@ 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.constants.ResponseStatus; +import com.doumee.core.exception.BusinessException; 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.CateParamMapper; import com.doumee.dao.business.CateParamSelectMapper; +import com.doumee.dao.business.GoodsParamMapper; +import com.doumee.dao.business.model.CateParam; import com.doumee.dao.business.model.CateParamSelect; +import com.doumee.dao.business.model.Goods; +import com.doumee.dao.business.model.GoodsParam; import com.doumee.service.CateParamSelectService; +import com.github.yulichang.wrapper.MPJLambdaWrapper; +import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; @@ -20,6 +29,8 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -35,6 +46,8 @@ @Autowired private CateParamSelectMapper cateParamSelectMapper; + @Autowired + private GoodsParamMapper goodsParamMapper; @Override public Integer create(CateParamSelect cateParamSelect) { @@ -154,12 +167,16 @@ @Override @Async - @Transactional public void dealCateParamSelect() { + dealCateParamSelectDo(); + } + @Override + @Transactional + public void dealCateParamSelectDo() { LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); Boolean isGrouping = (Boolean)redisTemplate.opsForValue().get(loginUserInfo.getCompanyId()+Constants.CATE_PARAM_OPEN); if(isGrouping!=null && isGrouping ){ - return; + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"浼佷笟鍙傛暟閫夐」鍒濆鍖栨鍦ㄦ墽琛岋紝璇风◢鍚庨噸璇曪紒"); } redisTemplate.opsForValue().set(loginUserInfo.getCompanyId()+Constants.CATE_PARAM_OPEN,true); try { @@ -167,6 +184,45 @@ 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()); + /*List<CateParamSelect> list = new ArrayList<>(); + List<GoodsParam> params = goodsParamMapper.selectJoinList(GoodsParam.class,new MPJLambdaWrapper<GoodsParam>() + .select( GoodsParam::getPramaId) + .select( "TRIM(REPLACE(t.val,'聽','')) as val,CONCAT(TRIM(REPLACE(t.val,'聽','')),t.PRAMA_ID,t1.CATEGORY_ID ) as uky") + .selectAs(Goods::getCategoryId,CateParamSelect::getCategoryId) + .innerJoin(Goods.class,Goods::getId,GoodsParam::getGoodsId) + .isNotNull(GoodsParam::getPramaId) + .isNotNull(GoodsParam::getVal) + .ne(GoodsParam::getVal,"") + .eq(Goods::getIsdeleted,Constants.ZERO ) + .eq(Goods::getStatus,Constants.ZERO ) + .eq(Goods::getCompanyId,loginUserInfo.getCompanyId()) + .groupBy("uky") + ); + if(params.size()>0){ + Date date = new Date(); + for(GoodsParam p : params){ + if(StringUtils.isBlank(p.getVal()) || StringUtils.equals(p.getVal().trim(),"")){ + continue; + } + if(repeatValParam(p,list)){ + continue; + } + p.setVal(p.getVal().trim()); + CateParamSelect cp = new CateParamSelect(); + cp.setCategoryId(p.getCategoryId()); + cp.setName(p.getVal()); + cp.setIsdeleted(Constants.ZERO); + cp.setCreateDate(date); + cp.setParamId(p.getPramaId()); + cp.setStatus(Constants.ZERO); + cp.setCreator(loginUserInfo.getId()); +// cateParamSelectMapper.insert(cp); + list.add(cp); + } + } + if(list.size()>0){ + cateParamSelectMapper.insert(list); + }*/ }catch (Exception e){ e.printStackTrace(); }finally { @@ -174,5 +230,16 @@ } } + private boolean repeatValParam(GoodsParam p, List<CateParamSelect> list) { + for(CateParamSelect cp :list){ + if(StringUtils.equals(cp.getName(),p.getVal()) + && Constants.equalsInteger(cp.getParamId(),p.getPramaId()) + && Constants.equalsInteger(cp.getCategoryId(),p.getCategoryId())){ + return true; + } + } + return false; + } + } -- Gitblit v1.9.3