From 04d88ef5d6e9f4814ad16f51f1550bd5be7c6fe6 Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期五, 15 九月 2023 09:12:31 +0800 Subject: [PATCH] 优化素材库处理源数据 --- server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java | 121 +++++++++++++++++++++++----------------- 1 files changed, 70 insertions(+), 51 deletions(-) diff --git a/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java index c9eca84..4312e70 100644 --- a/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java +++ b/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java @@ -130,7 +130,7 @@ @Override public Integer createPlat(GoodCreatePlatRequest param){ LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); - if(Constants.equalsInteger(user.getType(), Constants.UserType.COMPANY.getKey())){ + if(!Constants.equalsInteger(user.getType(), Constants.UserType.COMPANY.getKey())){ //闈炰紒涓氱敤鎴蜂笉鑳芥搷浣� throw new BusinessException(ResponseStatus.NOT_ALLOWED); } @@ -143,7 +143,7 @@ throw new BusinessException(ResponseStatus.BAD_REQUEST); } Category category = categoryMapper.selectById(param.getCategoryId()); - if(category ==null ||Constants.equalsInteger(category.getIsdeleted(), Constants.ONE) ||Constants.equalsInteger(category.getCompanyId(), user.getCompanyId())){ + if(category ==null ||Constants.equalsInteger(category.getIsdeleted(), Constants.ONE) ||!Constants.equalsInteger(category.getCompanyId(), user.getCompanyId())){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绫诲埆淇℃伅涓嶆纭紝璇峰埛鏂伴噸璇曪紒"); } if(category.getPlatCateId() == null){ @@ -160,11 +160,14 @@ if(p.getGoodsId() == null || p.getPrice() == null){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璇锋纭�夋嫨骞冲彴鍟嗗搧骞堕厤缃叆鎵嬩环锛�"); } + if(ids == null){ + ids = new ArrayList<>(); + } ids.add(p.getGoodsId()); } } goodsList = baseGoodsMapper.selectList(new QueryWrapper<>(bp).lambda().in((ids!=null && ids.size()>0),BaseGoods::getId,ids)); - if(Constants.equalsInteger(Constants.ONE, param.getType()) || goodsList==null || ids.size()!=goodsList.size()){ + if(Constants.equalsInteger(Constants.ONE, param.getType()) &&( goodsList==null || ids.size()!=goodsList.size())){ // 濡傛灉閫夋嫨骞冲彴鍟嗗搧鍜屾煡璇㈢粨鏋滃涓嶄笂锛屾彁绀洪敊璇� throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璇锋纭�夋嫨骞冲彴鍟嗗搧锛�"); } @@ -219,6 +222,7 @@ goods.setStatus(Constants.ZERO); goods.setCreateDate(new Date()); goods.setCreator(user.getId()); + goods.setCompanyId(user.getCompanyId()); goods.setIsdeleted(Constants.ZERO); //澶勭悊鎷奸煶闂 goods.setPinyin(PinYinUtil.getFullSpell(goods.getName())); @@ -227,7 +231,7 @@ goods.setCategoryId(param.getCategoryId()); //鑾峰彇鍏ユ墜浠锋牸 goods.setPrice(getPriceFromParam(model,param)); - goods.setZdPrice(model.getZdPrice());g + goods.setZdPrice(model.getZdPrice()); goods.setRemark(model.getRemark()); goods.setImgurl(model.getImgurl()); goods.setBrandId(model.getBrandId()); @@ -644,9 +648,10 @@ if (pageWrap.getModel().getBrandId() != null) { queryWrapper.eq(Goods::getBrandId, pageWrap.getModel().getBrandId()); } - + if (pageWrap.getModel().getCompanyId() != null) { + queryWrapper.eq(Goods::getCompanyId, pageWrap.getModel().getCompanyId()); + } queryWrapper.orderByDesc(Goods::getId); - IPage<Goods> goodsIPage = goodsJoinMapper.selectJoinPage(page, Goods.class, queryWrapper); String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode() + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode(); @@ -761,54 +766,54 @@ //鏌ヨ鍏ㄩ儴灞炴��1鍜屽睘鎬�2瑙勬牸鍊� List<CateAttr> allAttr = cateAttrMapper.selectList(new QueryWrapper<>(ca)); //灞炴��1闆嗗悎 - String[] attrs = StringUtils.defaultString(m.getAttrFirstNames(),"").split("\n"); +// String[] attrs = StringUtils.defaultString(m.getAttrFirstNames(),"").split("\n"); //灞炴��2闆嗗悎 - String[] attrs2 = StringUtils.defaultString(m.getAttrSecodNames(),"").split("\n"); +// String[] attrs2 = StringUtils.defaultString(m.getAttrSecodNames(),"").split("\n"); //浜у搧鍙傛暟闆嗗悎 String[] params = StringUtils.defaultString(m.getParamStr(),"").split("\n"); - if(attrs.length > 0){ - String attrids="" ,attrNames=""; - for(String s : attrs){ - if(StringUtils.isBlank(s)){ - continue; - } - //鏌ヨ灞炴�ц鏍煎璞� - CateAttr ta = getCateAttrByName(s,Constants.ZERO,allAttr); - if(ta == null){ - throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗��"+(num)+"銆戣灞炴��1涓��"+s+"銆戞棤鏁堬紝璇锋鏌ヨ緭鍏ワ紒"); - } - if(StringUtils.isNotBlank(attrids)){ - attrids += ","; - attrNames += ","; - } - attrids+= ta.getId(); - attrNames+= ta.getName(); - } - newModel.setAttrFirstIds(attrids); - newModel.setAttrFirstNames(attrNames); - } - if(attrs2.length > 0){ - String attrids="" ,attrNames=""; - for(String s : attrs2){ - if(StringUtils.isBlank(s)){ - continue; - } - //鏌ヨ灞炴�ц鏍煎璞� - CateAttr ta = getCateAttrByName(s,Constants.ONE,allAttr); - if(ta == null){ - throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗��"+(num)+"銆戣灞炴��1涓��"+s+"銆戞棤鏁堬紝璇锋鏌ヨ緭鍏ワ紒"); - } - if(StringUtils.isNotBlank(attrids)){ - attrids += ","; - attrNames += ","; - } - attrids+= ta.getId(); - attrNames+= ta.getName(); - } - newModel.setAttrSecodIds(attrids); - newModel.setAttrSecodNames(attrNames); - - } +// if(attrs.length > 0){ +// String attrids="" ,attrNames=""; +// for(String s : attrs){ +// if(StringUtils.isBlank(s)){ +// continue; +// } +// //鏌ヨ灞炴�ц鏍煎璞� +// CateAttr ta = getCateAttrByName(s,Constants.ZERO,allAttr); +// if(ta == null){ +// throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗��"+(num)+"銆戣灞炴��1涓��"+s+"銆戞棤鏁堬紝璇锋鏌ヨ緭鍏ワ紒"); +// } +// if(StringUtils.isNotBlank(attrids)){ +// attrids += ","; +// attrNames += ","; +// } +// attrids+= ta.getId(); +// attrNames+= ta.getName(); +// } +// newModel.setAttrFirstIds(attrids); +// newModel.setAttrFirstNames(attrNames); +// } +// if(attrs2.length > 0){ +// String attrids="" ,attrNames=""; +// for(String s : attrs2){ +// if(StringUtils.isBlank(s)){ +// continue; +// } +// //鏌ヨ灞炴�ц鏍煎璞� +// CateAttr ta = getCateAttrByName(s,Constants.ONE,allAttr); +// if(ta == null){ +// throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗��"+(num)+"銆戣灞炴��1涓��"+s+"銆戞棤鏁堬紝璇锋鏌ヨ緭鍏ワ紒"); +// } +// if(StringUtils.isNotBlank(attrids)){ +// attrids += ","; +// attrNames += ","; +// } +// attrids+= ta.getId(); +// attrNames+= ta.getName(); +// } +// newModel.setAttrSecodIds(attrids); +// newModel.setAttrSecodNames(attrNames); +// +// } List<String> mulFiles = null; String proDir =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PROJECTS).getCode(); @@ -890,6 +895,20 @@ gp.setSortnum(ta.getSortnum()); //鎻掑叆浜у搧鍙傛暟鍏宠仈琛� goodsParamMapper.insert(gp); + //瀛樺偍 cate_param_select 鏌ヨ鏄惁宸插瓨鍦� + if(cateParamSelectMapper.selectCount(new QueryWrapper<CateParamSelect>() + .eq("PARAM_ID",gp.getPramaId()).eq("NAME",gp.getName()))<=Constants.ZERO){ + CateParamSelect cateParamSelect = new CateParamSelect(); + cateParamSelect.setCreator(user.getId()); + cateParamSelect.setCreateDate(new Date()); + cateParamSelect.setName(gp.getVal()); + cateParamSelect.setIsdeleted(Constants.ZERO); + cateParamSelect.setStatus(Constants.ZERO); + cateParamSelect.setParamId(gp.getPramaId()); + cateParamSelect.setCategoryId(newModel.getCategoryId()); + cateParamSelect.setStatus(Constants.ZERO); + cateParamSelectMapper.insert(cateParamSelect); + }; } } if(mulFiles !=null && mulFiles.size()>0){ -- Gitblit v1.9.3