From 36d1f24952e857c971aed06042f6c7ebba6b147e Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期三, 30 四月 2025 11:25:20 +0800
Subject: [PATCH] sf
---
server/service/src/main/java/com/doumee/service/impl/CateParamSelectServiceImpl.java | 109 ++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 92 insertions(+), 17 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 25c9e80..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,18 +4,33 @@
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;
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.ArrayList;
+import java.util.Date;
import java.util.List;
/**
@@ -28,8 +43,11 @@
@Autowired
private RedisTemplate redisTemplate;
+
@Autowired
private CateParamSelectMapper cateParamSelectMapper;
+ @Autowired
+ private GoodsParamMapper goodsParamMapper;
@Override
public Integer create(CateParamSelect cateParamSelect) {
@@ -149,22 +167,79 @@
@Override
@Async
- public void dealGroupVals(Integer companyId) {
- Boolean isGrouping = (Boolean)redisTemplate.opsForValue().get(companyId+"_isGrouping");
- if(isGrouping!=null && isGrouping ){
- return;
- }
- redisTemplate.opsForValue().set(companyId+"_isGrouping",true);
- try {
- //---------TODO-------浠诲悍
-
- }catch (Exception e){
-
- }finally {
- redisTemplate.opsForValue().set(companyId+"_isGrouping",false);
- }
-
-
-
+ 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 ){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"浼佷笟鍙傛暟閫夐」鍒濆鍖栨鍦ㄦ墽琛岋紝璇风◢鍚庨噸璇曪紒");
+ }
+ redisTemplate.opsForValue().set(loginUserInfo.getCompanyId()+Constants.CATE_PARAM_OPEN,true);
+ try {
+ //鍒犻櫎浼佷笟涓嬪巻鍙叉暟鎹�
+ 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 {
+ redisTemplate.opsForValue().set(loginUserInfo.getCompanyId()+Constants.CATE_PARAM_OPEN,false);
+ }
+ }
+
+ 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