|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer create(BaseGoodsCreateOrUpdateRequest baseGoods) { | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | if(baseGoodsMapper.selectCount(new QueryWrapper<BaseGoods>().eq("ISDELETED", Constants.ZERO).eq("name",baseGoods.getName()))>0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+baseGoods.getName()+"】已存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        if(baseGoodsMapper.selectCount(new QueryWrapper<BaseGoods>().eq("ISDELETED", Constants.ZERO).eq("name",baseGoods.getName()))>0){ | 
|---|
|  |  |  | //            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+baseGoods.getName()+"】已存在"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Integer integer = baseGoodsMapper.selectCount(new QueryWrapper<BaseGoods>().eq("ISDELETED", Constants.ZERO)); | 
|---|
|  |  |  | BaseGoods insert = new BaseGoods(); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void deleteById(Integer id) { | 
|---|
|  |  |  | baseGoodsMapper.deleteById(id); | 
|---|
|  |  |  | BaseGoods model = new BaseGoods(); | 
|---|
|  |  |  | model.setId(id); | 
|---|
|  |  |  | model.setEditDate(new Date()); | 
|---|
|  |  |  | model.setIsdeleted(Constants.ONE); | 
|---|
|  |  |  | updateById(model); | 
|---|
|  |  |  | //        baseGoodsMapper.deleteById(id); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | if (CollectionUtils.isEmpty(ids)) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | baseGoodsMapper.deleteBatchIds(ids); | 
|---|
|  |  |  | for(Integer id : ids){ | 
|---|
|  |  |  | deleteById(id); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        baseGoodsMapper.deleteBatchIds(ids); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | public void update(BaseGoodsCreateOrUpdateRequest baseGoods) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | if(baseGoodsMapper.selectCount(new QueryWrapper<BaseGoods>() | 
|---|
|  |  |  | .eq("ISDELETED",Constants.ZERO).ne("id",baseGoods.getId()) | 
|---|
|  |  |  | .eq("name",baseGoods.getName()))>0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+baseGoods.getName()+"】已存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        if(baseGoodsMapper.selectCount(new QueryWrapper<BaseGoods>() | 
|---|
|  |  |  | //                .eq("ISDELETED",Constants.ZERO).ne("id",baseGoods.getId()) | 
|---|
|  |  |  | //                .eq("name",baseGoods.getName()))>0){ | 
|---|
|  |  |  | //            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+baseGoods.getName()+"】已存在"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | UpdateWrapper<BaseGoods> wrapper = new UpdateWrapper<>(); | 
|---|
|  |  |  | wrapper.lambda() | 
|---|
|  |  |  | 
|---|
|  |  |  | MPJLambdaWrapper<BaseGoods> queryWrapper = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | queryWrapper.leftJoin(Brand.class,Brand::getId,BaseGoods::getBrandId) | 
|---|
|  |  |  | .leftJoin(BaseCategory.class,BaseCategory::getId,BaseGoods::getBaseDataId) | 
|---|
|  |  |  | .leftJoin(BaseCategory.class,BaseCategory::getId,BaseGoods::getCategoryId) | 
|---|
|  |  |  | .selectAll(BaseGoods.class) | 
|---|
|  |  |  | .selectAs(Brand::getName,BaseGoodsDTO::getBrandName) | 
|---|
|  |  |  | .selectAs(BaseCategory::getSortnum,BaseGoodsDTO::getCategoryName) | 
|---|
|  |  |  | .selectAs(BaseCategory::getName,BaseGoodsDTO::getCategoryName) | 
|---|
|  |  |  | .eq(BaseGoods::getId,id); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BaseGoodsDTO baseGoodsDTO = baseGoodsJoinMapper.selectJoinOne(BaseGoodsDTO.class, queryWrapper); | 
|---|
|  |  |  | String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() | 
|---|
|  |  |  | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode(); | 
|---|
|  |  |  | baseGoodsDTO.setImgfullurl(prefixUrl+baseGoodsDTO.getImgurl()); | 
|---|
|  |  |  | baseGoodsDTO.setImgfullurl(StringUtils.isNotBlank(baseGoodsDTO.getImgurl()) ? prefixUrl+baseGoodsDTO.getImgurl() : null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Multifile> multifiles = multifileMapper.selectList(new QueryWrapper<Multifile>() | 
|---|
|  |  |  | .eq("OBJ_ID", id) | 
|---|
|  |  |  | 
|---|
|  |  |  | Utils.MP.blankToNull(pageWrap.getModel()); | 
|---|
|  |  |  | queryWrapper.leftJoin(Brand.class,Brand::getId,BaseGoods::getBrandId) | 
|---|
|  |  |  | .leftJoin(BaseCategory.class,BaseCategory::getId,BaseGoods::getCategoryId) | 
|---|
|  |  |  | //                    .leftJoin(BaseData.class,BaseData::getId,BaseGoods::getBaseDataId) | 
|---|
|  |  |  | .selectAll(BaseGoods.class) | 
|---|
|  |  |  | .selectAs(BaseCategory::getPriceRate,BaseGoods::getCateRatePrice) | 
|---|
|  |  |  | .selectAs(Brand::getName,BaseGoods::getBrandName) | 
|---|
|  |  |  | //                    .selectAs(BaseData::getPrice,BaseGoods::getJdPrice) | 
|---|
|  |  |  | .selectAs(BaseCategory::getName,BaseGoods::getCategoryName) | 
|---|
|  |  |  | .eq(BaseGoods::getIsdeleted, Constants.ZERO) | 
|---|
|  |  |  | .like(StringUtils.isNotBlank(pageWrap.getModel().getName()), BaseGoods::getName,pageWrap.getModel().getName()) | 
|---|
|  |  |  | 
|---|
|  |  |  | String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() | 
|---|
|  |  |  | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode(); | 
|---|
|  |  |  | pageData.getRecords().forEach(i->{ | 
|---|
|  |  |  | i.setFullImgUrl(prefixUrl + i.getImgurl()); | 
|---|
|  |  |  | if(StringUtils.isNotBlank(i.getImgurl())){ | 
|---|
|  |  |  | i.setFullImgUrl(prefixUrl + i.getImgurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | i.setJdPrice(i.getPrice()); | 
|---|
|  |  |  | i.setPrice(Constants.formatBigdecimal(i.getPrice()).multiply(Constants.formatBigdecimal(i.getCateRatePrice()))); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | return pageData; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | .leftJoin(BaseCategory.class,BaseCategory::getId,BaseGoods::getCategoryId) | 
|---|
|  |  |  | .selectAll(BaseGoods.class) | 
|---|
|  |  |  | .selectAs(Brand::getName,BaseGoods::getBrandName) | 
|---|
|  |  |  | .selectAs(BaseCategory::getPriceRate,BaseGoods::getCateRatePrice) | 
|---|
|  |  |  | .selectAs(BaseCategory::getName,BaseGoods::getCategoryName) | 
|---|
|  |  |  | .eq(BaseGoods::getStatus, Constants.ZERO) | 
|---|
|  |  |  | .eq(BaseGoods::getIsdeleted, Constants.ZERO) | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(pageWrap.getModel().getCategoryId()!=null,BaseGoods::getCategoryId, pageWrap.getModel().getCategoryId()) | 
|---|
|  |  |  | .eq(pageWrap.getModel().getBrandId()!=null,BaseGoods::getBrandId, pageWrap.getModel().getBrandId()) | 
|---|
|  |  |  | .eq(pageWrap.getModel().getStatus()!=null,BaseGoods::getStatus, pageWrap.getModel().getStatus()) | 
|---|
|  |  |  | .notExists(user.getType().equals(Constants.UserType.COMPANY.getKey())," select 1 from goods g where g.GOODS_ID = t.id and g.TYPE = 1  and  g.company_id = "+user.getCompanyId()+"  "); | 
|---|
|  |  |  | .notExists(user.getType().equals(Constants.UserType.COMPANY.getKey())," select 1 from goods g where g.GOODS_ID = t.id and g.TYPE = 1 and g.ISDELETED = 0  and  g.company_id = "+user.getCompanyId()+"  "); | 
|---|
|  |  |  | queryWrapper.orderByDesc(Goods::getId); | 
|---|
|  |  |  | PageData<BaseGoods> pageData =PageData.from(baseGoodsJoinMapper.selectJoinPage(page,BaseGoods.class,queryWrapper)); | 
|---|
|  |  |  | String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() | 
|---|
|  |  |  | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode(); | 
|---|
|  |  |  | pageData.getRecords().forEach(i->{ | 
|---|
|  |  |  | i.setFullImgUrl(prefixUrl + i.getImgurl()); | 
|---|
|  |  |  | //加价系数 | 
|---|
|  |  |  | i.setPrice(Constants.formatBigdecimal(i.getPrice()).multiply(Constants.formatBigdecimal(i.getCateRatePrice()))); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | return pageData; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if(dataList == null || dataList.size() ==0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,录入数据为空!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<String> comNameList = dataList.stream().map(s -> s.getName().trim()).distinct().collect(Collectors.toList()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!(dataList.size() == comNameList.size())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"商品名称有已存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //            List<String> collect1 = dataList.stream().filter(s->{ | 
|---|
|  |  |  | //                if (StringUtils.isBlank(s.getBrandName())){ | 
|---|
|  |  |  | //                    throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | //                }else { | 
|---|
|  |  |  | //                    return true; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //            }).map(s -> s.getCategoryName()).collect(Collectors.toList()); | 
|---|
|  |  |  | //            QueryWrapper<BaseCategory> wrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | //            wrapper.lambda() | 
|---|
|  |  |  | //                    .in(BaseCategory::getName,collect1); | 
|---|
|  |  |  | //            List<BaseCategory> baseCategories = baseCategoryMapper.selectList(wrapper); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | dataList.forEach(s->{ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(baseGoodsMapper.selectCount(new QueryWrapper<BaseGoods>().eq("ISDELETED", Constants.ZERO).eq("name",s.getName()))>0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+s.getName()+"】已存在"); | 
|---|
|  |  |  | //处理批量上传 | 
|---|
|  |  |  | String proDir =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PROJECTS).getCode(); | 
|---|
|  |  |  | String platformDir =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PLATFORM).getCode(); | 
|---|
|  |  |  | String basePath = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.GOODS_IMG_DIR).getCode() | 
|---|
|  |  |  | + proDir + platformDir ; | 
|---|
|  |  |  | OssModel ossModel = baseDataService.initOssModel(); | 
|---|
|  |  |  | for (int index = 0; index < dataList.size(); index++) { | 
|---|
|  |  |  | BaseGoodsImportDTO  s = dataList.get(index); | 
|---|
|  |  |  | if(existedIdInList(s.getId(),index,dataList)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"第【"+(1+index)+"行】商品编号【"+s.getId()+"】在表格中重复"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(baseGoodsMapper.selectCount(new QueryWrapper<BaseGoods>().lambda().eq(BaseGoods::getIsdeleted, Constants.ZERO) | 
|---|
|  |  |  | .eq(BaseGoods::getBaseDataId,s.getId()) | 
|---|
|  |  |  | .eq(BaseGoods::getOrigin,Constants.BasegoodsOrigin.imported))>0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"第【"+(1+index)+"行】商品编号【"+s.getId()+"】已导入!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BaseGoods baseGoods = new BaseGoods(); | 
|---|
|  |  |  | baseGoods.setCreator(user.getId()); | 
|---|
|  |  |  | baseGoods.setOrigin(Constants.BasegoodsOrigin.imported); | 
|---|
|  |  |  | baseGoods.setBaseDataId(s.getId()); | 
|---|
|  |  |  | baseGoods.setCreateDate(new Date()); | 
|---|
|  |  |  | baseGoods.setEditor(user.getId()); | 
|---|
|  |  |  | baseGoods.setEditDate(new Date()); | 
|---|
|  |  |  | 
|---|
|  |  |  | baseGoods.setZdPrice(new BigDecimal(s.getZdPrice())); | 
|---|
|  |  |  | baseGoods.setPrice(new BigDecimal(s.getPrice())); | 
|---|
|  |  |  | if (StringUtils.isBlank(s.getCategoryName())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"商品类别不可为空"); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"第【"+(1+index)+"行】商品类别不可为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | QueryWrapper<BaseCategory> categoryQuery = new QueryWrapper<>(); | 
|---|
|  |  |  | categoryQuery.lambda() | 
|---|
|  |  |  | .eq(BaseCategory::getName,s.getCategoryName()); | 
|---|
|  |  |  | BaseCategory baseCategory = baseCategoryMapper.selectOne(categoryQuery); | 
|---|
|  |  |  | .eq(BaseCategory::getName,s.getCategoryName()); | 
|---|
|  |  |  | categoryQuery.lambda() | 
|---|
|  |  |  | .eq(BaseCategory::getIsdeleted,Constants.ZERO); | 
|---|
|  |  |  | BaseCategory baseCategory = baseCategoryMapper.selectOne(categoryQuery.last(" limit 1")); | 
|---|
|  |  |  | if (Objects.isNull(baseCategory)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"商品类别不存在"); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"第【"+(1+index)+"行】商品类别【"+s.getCategoryName()+"】不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | QueryWrapper<Brand> brandQuery = new QueryWrapper<>(); | 
|---|
|  |  |  | brandQuery.lambda() | 
|---|
|  |  |  | .eq(Brand::getType,Constants.ONE) | 
|---|
|  |  |  | .eq(Brand::getName,s.getBrandName()); | 
|---|
|  |  |  | Brand brand = brandMapper.selectOne(brandQuery); | 
|---|
|  |  |  | brandQuery.lambda() | 
|---|
|  |  |  | .eq(Brand::getIsdeleted,Constants.ZERO); | 
|---|
|  |  |  | brandQuery.lambda() | 
|---|
|  |  |  | .eq(Brand::getType,Constants.ONE); | 
|---|
|  |  |  | Brand brand = brandMapper.selectOne(brandQuery.last("limit 1")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (Objects.isNull(brand)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"商品品牌不存在"); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"第【"+(1+index)+"行】商品品牌【"+s.getBrandName()+"】不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //处理批量上传 | 
|---|
|  |  |  | String proDir =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PLATFORM).getCode(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.GOODS_IMG_DIR).getCode() | 
|---|
|  |  |  | + proDir + File.separator + s.getId(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String path =basePath+ s.getId(); | 
|---|
|  |  |  | List<String> mulFiles = new ArrayList<>(); | 
|---|
|  |  |  | if(StringUtils.isNotBlank(path)){ | 
|---|
|  |  |  | OssModel ossModel = baseDataService.initOssModel(); | 
|---|
|  |  |  | File dir =new File(path+File.separator); | 
|---|
|  |  |  | if(dir!=null && dir.isDirectory()){ | 
|---|
|  |  |  | File[]  files = dir.listFiles(); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                baseGoods.setImgurl(); | 
|---|
|  |  |  | baseGoods.setCategoryId(baseCategory.getId()); | 
|---|
|  |  |  | baseGoods.setBrandId(brand.getId()); | 
|---|
|  |  |  | baseGoods.setPinyin(PinYinUtil.getFullSpell(s.getName())); | 
|---|
|  |  |  | baseGoods.setShortPinyin(PinYinUtil.getFirstSpell(s.getName())); | 
|---|
|  |  |  | baseGoodsMapper.insert(baseGoods); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(mulFiles !=null && mulFiles.size()>0){ | 
|---|
|  |  |  | for(int i=0;i<mulFiles.size();i++){ | 
|---|
|  |  |  | String str = mulFiles.get(i); | 
|---|
|  |  |  | Multifile f = new Multifile(); | 
|---|
|  |  |  | f.setObjType(Constants.ZERO); | 
|---|
|  |  |  | f.setObjType(Constants.ONE); | 
|---|
|  |  |  | f.setName(str); | 
|---|
|  |  |  | f.setType(Constants.ZERO); | 
|---|
|  |  |  | f.setObjId(baseGoods.getId()); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String baseGoodsParamString = s.getBaseGoodsParamString(); | 
|---|
|  |  |  | List<List<String>> collect = Arrays.asList(baseGoodsParamString.split("\n")) | 
|---|
|  |  |  | .stream().map(s1 -> Arrays.asList(s1.split("[:,:]")) ).collect(Collectors.toList()); | 
|---|
|  |  |  | if (!CollectionUtils.isEmpty(collect)){ | 
|---|
|  |  |  | //                    Integer i = 0; | 
|---|
|  |  |  | for (int i = 0; i < collect.size(); i++){ | 
|---|
|  |  |  | if (!CollectionUtils.isEmpty(baseCategory.getBaseCateParamList())){ | 
|---|
|  |  |  | List<String> s2 = collect.get(i); | 
|---|
|  |  |  | BaseCateParam baseCateParam = baseCategory.getBaseCateParamList() | 
|---|
|  |  |  | .stream().filter(s3 -> s3.getName().equals(s2.get(0))).findFirst() | 
|---|
|  |  |  | .orElseThrow(()->new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"配置参数不存在")); | 
|---|
|  |  |  | BaseGoodsParam baseGoodsParam = new BaseGoodsParam(); | 
|---|
|  |  |  | baseGoodsParam.setCreator(user.getId()); | 
|---|
|  |  |  | baseGoodsParam.setCreateDate(new Date()); | 
|---|
|  |  |  | baseGoodsParam.setEditor(user.getId()); | 
|---|
|  |  |  | baseGoodsParam.setEditDate(new Date()); | 
|---|
|  |  |  | baseGoodsParam.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | baseGoodsParam.setName(baseCateParam.getName()); | 
|---|
|  |  |  | baseGoodsParam.setRemark(baseCateParam.getRemark()); | 
|---|
|  |  |  | baseGoodsParam.setStatus(Constants.ZERO); | 
|---|
|  |  |  | baseGoodsParam.setSortnum(i+Constants.ONE); | 
|---|
|  |  |  | baseGoodsParam.setPramaId(baseCateParam.getId()); | 
|---|
|  |  |  | baseGoodsParam.setVal(s2.size() > 1 ? s2.get(1) : null ); | 
|---|
|  |  |  | baseGoodsParam.setGoodsId(baseGoods.getId()); | 
|---|
|  |  |  | baseGoodsParamMapper.insert(baseGoodsParam); | 
|---|
|  |  |  | .stream() | 
|---|
|  |  |  | .map(s1 -> Arrays.asList(s1.split("[:,:]")) ) | 
|---|
|  |  |  | .filter(s1->!CollectionUtils.isEmpty(s1)) | 
|---|
|  |  |  | .collect(Collectors.toList()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!CollectionUtils.isEmpty(baseCategory.getBaseCateParamList())) { | 
|---|
|  |  |  | for (int i = 0; i < baseCategory.getBaseCateParamList().size(); i++) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BaseCateParam baseCateParam = baseCategory.getBaseCateParamList().get(i); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BaseGoodsParam baseGoodsParam = new BaseGoodsParam(); | 
|---|
|  |  |  | baseGoodsParam.setCreator(user.getId()); | 
|---|
|  |  |  | baseGoodsParam.setCreateDate(new Date()); | 
|---|
|  |  |  | baseGoodsParam.setEditor(user.getId()); | 
|---|
|  |  |  | baseGoodsParam.setEditDate(new Date()); | 
|---|
|  |  |  | baseGoodsParam.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | baseGoodsParam.setName(baseCateParam.getName()); | 
|---|
|  |  |  | baseGoodsParam.setRemark(baseCateParam.getRemark()); | 
|---|
|  |  |  | baseGoodsParam.setStatus(Constants.ZERO); | 
|---|
|  |  |  | baseGoodsParam.setSortnum(i + Constants.ONE); | 
|---|
|  |  |  | baseGoodsParam.setPramaId(baseCateParam.getId()); | 
|---|
|  |  |  | baseGoodsParam.setGoodsId(baseGoods.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!CollectionUtils.isEmpty(collect)) { | 
|---|
|  |  |  | List<String> list = collect.stream() | 
|---|
|  |  |  | .filter(s3 -> s3.get(0).equals(baseCateParam.getName())) | 
|---|
|  |  |  | .findFirst() | 
|---|
|  |  |  | .orElse(new ArrayList<>()); | 
|---|
|  |  |  | baseGoodsParam.setVal(list.size() > 1 ? list.get(1) : null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | baseGoodsParamMapper.insert(baseGoodsParam); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (Exception e) { | 
|---|
|  |  |  | log.error(String.format("批量插入异常%s ",e.getMessage())); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),e.getMessage()); | 
|---|
|  |  |  | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private boolean existedIdInList(String id,int index, List<BaseGoodsImportDTO> dataList) { | 
|---|
|  |  |  | for (int j = 0; j <dataList.size(); j++) { | 
|---|
|  |  |  | if(index!=j && StringUtils.equals(id,dataList.get(j).getId())){ | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private boolean isImgFile(File f) { | 
|---|
|  |  |  | if(f!=null && f.isFile() ){ | 
|---|
|  |  |  | String name = f.getName(); | 
|---|