package com.doumee.service.business.impl; import com.doumee.biz.system.SystemDictDataBiz; import com.doumee.core.annotation.excel.ExcelImporter; 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.PinYinUtil; import com.doumee.core.utils.Utils; import com.doumee.dao.business.*; import com.doumee.dao.business.join.BaseGoodsJoinMapper; import com.doumee.dao.business.model.*; import com.doumee.dao.business.model.dto.*; import com.doumee.service.business.BaseDataService; import com.doumee.service.business.BaseGoodsService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.github.yulichang.wrapper.MPJLambdaWrapper; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; import java.io.File; import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; /** * 素材库-商品信息表Service实现 * @author 江蹄蹄 * @date 2023/09/07 11:41 */ @Slf4j @Service public class BaseGoodsServiceImpl implements BaseGoodsService { @Autowired private BaseGoodsMapper baseGoodsMapper; @Autowired private BaseGoodsJoinMapper baseGoodsJoinMapper; @Autowired private BaseGoodsParamMapper baseGoodsParamMapper; @Autowired private MultifileMapper multifileMapper; @Autowired @Lazy private SystemDictDataBiz systemDictDataBiz; @Autowired private BrandMapper brandMapper; @Autowired private GoodsMapper goodsMapper; @Autowired private BaseCategoryMapper baseCategoryMapper; @Autowired @Lazy private BaseDataService baseDataService; @Override public Integer create(BaseGoodsCreateOrUpdateRequest baseGoods) { LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); // if(baseGoodsMapper.selectCount(new QueryWrapper().eq("ISDELETED", Constants.ZERO).eq("name",baseGoods.getName()))>0){ // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+baseGoods.getName()+"】已存在"); // } Long integer = baseGoodsMapper.selectCount(new QueryWrapper().eq("ISDELETED", Constants.ZERO)); BaseGoods insert = new BaseGoods(); insert.setCreator(user.getId()); insert.setCreateDate(new Date()); insert.setEditor(user.getId()); insert.setEditDate(new Date()); insert.setIsdeleted(Constants.ZERO); insert.setRemark(baseGoods.getRemark()); insert.setName(baseGoods.getName()); //默认下架 insert.setStatus(Constants.ONE); insert.setSortnum(integer+Constants.ONE); insert.setImgurl(baseGoods.getImgurl()); insert.setCategoryId(baseGoods.getCategoryId()); insert.setBrandId(baseGoods.getBrandId()); insert.setZdPrice(baseGoods.getZdPrice()); insert.setPrice(baseGoods.getPrice()); insert.setContent(baseGoods.getContent()); insert.setPinyin(PinYinUtil.getFullSpell(insert.getName())); insert.setShortPinyin(PinYinUtil.getFirstSpell(insert.getName())); baseGoodsMapper.insert(insert); List multifileList = baseGoods.getMultifileList(); if(!Objects.isNull(multifileList)&&multifileList.size()>Constants.ZERO){ for (int i = 0; i < multifileList.size(); i++) { Multifile multifile = multifileList.get(i); multifile.setCreator(user.getId()); multifile.setCreateDate(new Date()); multifile.setIsdeleted(Constants.ZERO); multifile.setSortnum(i+Constants.ONE); multifile.setObjId(insert.getId()); multifile.setType(Constants.ZERO); multifile.setObjType(Constants.ONE); multifileMapper.insert(multifile); } } List goodsParamList = baseGoods.getBaseGoodsParamList(); if(!Objects.isNull(goodsParamList)&&goodsParamList.size()>0){ for (int i = 0; i < goodsParamList.size(); i++) { BaseGoodsParamCreatRequest param = goodsParamList.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(param.getName()); baseGoodsParam.setRemark(param.getRemark()); baseGoodsParam.setStatus(Constants.ZERO); baseGoodsParam.setSortnum(i+Constants.ONE); baseGoodsParam.setPramaId(param.getPramaId()); baseGoodsParam.setVal(param.getVal()); baseGoodsParam.setGoodsId(insert.getId()); baseGoodsParamMapper.insert(baseGoodsParam); } } return insert.getId(); } @Override public void deleteById(Integer id) { BaseGoods model = new BaseGoods(); model.setId(id); model.setEditDate(new Date()); model.setIsdeleted(Constants.ONE); updateById(model); // baseGoodsMapper.deleteById(id); } @Override public void delete(BaseGoods baseGoods) { UpdateWrapper deleteWrapper = new UpdateWrapper<>(baseGoods); baseGoodsMapper.delete(deleteWrapper); } @Override public void deleteByIdInBatch(List ids) { if (CollectionUtils.isEmpty(ids)) { return; } for(Integer id : ids){ deleteById(id); } // baseGoodsMapper.deleteBatchIds(ids); } @Transactional(rollbackFor = {Exception.class,BusinessException.class}) @Override public void update(BaseGoodsCreateOrUpdateRequest baseGoods) { LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); // if(baseGoodsMapper.selectCount(new QueryWrapper() // .eq("ISDELETED",Constants.ZERO).ne("id",baseGoods.getId()) // .eq("name",baseGoods.getName()))>0){ // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+baseGoods.getName()+"】已存在"); // } UpdateWrapper wrapper = new UpdateWrapper<>(); wrapper.lambda() .eq(BaseGoods::getId,baseGoods.getId()) .set(BaseGoods::getName,baseGoods.getName()) .set(BaseGoods::getBrandId,baseGoods.getBrandId()) .set(BaseGoods::getCategoryId,baseGoods.getCategoryId()) .set(BaseGoods::getImgurl,baseGoods.getImgurl()) .set(BaseGoods::getPrice,baseGoods.getPrice()) .set(BaseGoods::getZdPrice,baseGoods.getZdPrice()); baseGoodsMapper.update(null,wrapper); multifileMapper.delete(new QueryWrapper().eq("OBJ_ID",baseGoods.getId()) .eq("OBJ_TYPE",Constants.ONE)); List multifileList = baseGoods.getMultifileList(); if(!Objects.isNull(multifileList)&&multifileList.size()>Constants.ZERO){ for (int i = 0; i < multifileList.size(); i++) { Multifile multifile = multifileList.get(i); multifile.setCreator(user.getId()); multifile.setCreateDate(new Date()); multifile.setIsdeleted(Constants.ZERO); multifile.setSortnum(i+Constants.ONE); multifile.setObjId(baseGoods.getId()); multifile.setType(Constants.ZERO); multifile.setObjType(Constants.ONE); multifileMapper.insert(multifile); } } baseGoodsParamMapper.delete(new QueryWrapper().eq("GOODS_ID",baseGoods.getId())); List goodsParamList = baseGoods.getBaseGoodsParamList(); if(!Objects.isNull(goodsParamList)&&goodsParamList.size()>0){ for (int i = 0; i < goodsParamList.size(); i++) { BaseGoodsParamCreatRequest param = goodsParamList.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(param.getName()); baseGoodsParam.setRemark(param.getRemark()); baseGoodsParam.setStatus(Constants.ZERO); baseGoodsParam.setSortnum(i+Constants.ONE); baseGoodsParam.setPramaId(param.getPramaId()); baseGoodsParam.setVal(param.getVal()); baseGoodsParam.setGoodsId(baseGoods.getId()); baseGoodsParamMapper.insert(baseGoodsParam); } } } @Transactional(rollbackFor = {Exception.class,BusinessException.class}) @Override public void updateStatusByIds(BaseGoods param) { if (CollectionUtils.isEmpty(param.getIdList()) || param.getStatus() == null || !(Constants.equalsInteger(param.getStatus(), Constants.ONE)||Constants.equalsInteger(param.getStatus() ,Constants.ZERO))){ throw new BusinessException(ResponseStatus.BAD_REQUEST); } param.getIdList().forEach(s->updateStatusById(s,param.getStatus())); } @Transactional(rollbackFor = {Exception.class,BusinessException.class}) @Override public void updateStatusById(Integer id, Integer status) { LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); if (Objects.isNull(status)){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"商品状态不能为空"); } if (Constants.equalsInteger(status,Constants.ZERO)){ //如果启用 BaseGoods baseGoods = new BaseGoods(); baseGoods.setId(id); baseGoods.setEditDate(new Date()); baseGoods.setEditor(user.getId()); baseGoods.setStatus(status); baseGoodsMapper.updateById(baseGoods); }else if (Constants.equalsInteger(status,Constants.ONE)){ //如果禁用 BaseGoods baseGoods = new BaseGoods(); baseGoods.setId(id); baseGoods.setEditDate(new Date()); baseGoods.setEditor(user.getId()); baseGoods.setStatus(status); baseGoodsMapper.updateById(baseGoods); UpdateWrapper goodsUpdate = new UpdateWrapper<>(); goodsUpdate.lambda() .eq(Goods::getType,Constants.ONE) .eq(Goods::getGoodsId,id) .set(Goods::getStatus,Constants.ONE) .set(Goods::getEditor,user.getId()) .set(Goods::getEditDate,new Date()); goodsMapper.update(null,goodsUpdate); } } @Override public void updateById(BaseGoods baseGoods) { baseGoodsMapper.updateById(baseGoods); } @Override public void updateByIdInBatch(List baseGoodss) { if (CollectionUtils.isEmpty(baseGoodss)) { return; } for (BaseGoods baseGoods: baseGoodss) { this.updateById(baseGoods); } } @Override public BaseGoods findById(Integer id) { return baseGoodsMapper.selectById(id); } @Override public BaseGoodsDTO findByIdBaseGoods(Integer id) { MPJLambdaWrapper queryWrapper = new MPJLambdaWrapper<>(); queryWrapper.leftJoin(Brand.class,Brand::getId,BaseGoods::getBrandId) .leftJoin(BaseCategory.class,BaseCategory::getId,BaseGoods::getCategoryId) .selectAll(BaseGoods.class) .selectAs(Brand::getName,BaseGoodsDTO::getBrandName) .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(StringUtils.isNotBlank(baseGoodsDTO.getImgurl()) ? prefixUrl+baseGoodsDTO.getImgurl() : null); List multifiles = multifileMapper.selectList(new QueryWrapper() .eq("OBJ_ID", id) .eq("OBJ_TYPE", Constants.ONE)); if (!CollectionUtils.isEmpty(multifiles)){ multifiles.forEach(s->s.setFilefullurl(prefixUrl+s.getFileurl())); } baseGoodsDTO.setMultifileList(multifiles); QueryWrapper baseGoodsParamQuery = new QueryWrapper<>(); baseGoodsParamQuery.select("base_goods_param.*,(select name from base_cate_param bcp where (bcp.id = base_goods_param.PRAMA_ID)) as paramName") .lambda() .eq(BaseGoodsParam::getGoodsId,id) .orderByAsc(BaseGoodsParam::getSortnum); List baseGoodsParams = baseGoodsParamMapper.selectList(baseGoodsParamQuery); baseGoodsDTO.setBaseGoodsParamList(baseGoodsParams); return baseGoodsDTO; } @Override public BaseGoods findOne(BaseGoods baseGoods) { QueryWrapper wrapper = new QueryWrapper<>(baseGoods); return baseGoodsMapper.selectOne(wrapper); } @Override public List findList(BaseGoods baseGoods) { QueryWrapper wrapper = new QueryWrapper<>(baseGoods); return baseGoodsMapper.selectList(wrapper); } @Override public PageData findPage(PageWrap pageWrap) { pageWrap.getModel().setIsdeleted(Constants.ZERO); IPage page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); MPJLambdaWrapper queryWrapper = new MPJLambdaWrapper<>(); 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()) .like(pageWrap.getModel().getId()!=null,BaseGoods::getId, pageWrap.getModel().getId()) .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()); queryWrapper.orderByDesc(Goods::getId); PageData 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->{ 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; } @Override public PageData findCompanyPage(PageWrap pageWrap) { LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); pageWrap.getModel().setIsdeleted(Constants.ZERO); IPage page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); MPJLambdaWrapper queryWrapper = new MPJLambdaWrapper<>(); Utils.MP.blankToNull(pageWrap.getModel()); queryWrapper.leftJoin(Brand.class,Brand::getId,BaseGoods::getBrandId) .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) .like(StringUtils.isNotBlank(pageWrap.getModel().getName()), BaseGoods::getName,pageWrap.getModel().getName()) .like(pageWrap.getModel().getId()!=null,BaseGoods::getId, pageWrap.getModel().getId()) .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.ISDELETED = 0 and g.company_id = "+user.getCompanyId()+" "); queryWrapper.orderByDesc(Goods::getId); PageData 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; } @Override public long count(BaseGoods baseGoods) { QueryWrapper wrapper = new QueryWrapper<>(baseGoods); return baseGoodsMapper.selectCount(wrapper); } @Transactional(rollbackFor = {Exception.class,BusinessException.class}) @Override public Integer importBaseGoodsBatch(MultipartFile file) { LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); try { ExcelImporter ie = new ExcelImporter(file,0,0); List dataList = ie.getDataList(BaseGoodsImportDTO.class,null); if(dataList == null || dataList.size() ==0){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,录入数据为空!"); } //处理批量上传 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().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.setIsdeleted(Constants.ZERO); baseGoods.setName(s.getName()); baseGoods.setStatus(Constants.ZERO); baseGoods.setZdPrice(new BigDecimal(s.getZdPrice())); baseGoods.setPrice(new BigDecimal(s.getPrice())); if (StringUtils.isBlank(s.getCategoryName())){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"第【"+(1+index)+"行】商品类别不可为空"); } QueryWrapper categoryQuery = new QueryWrapper<>(); categoryQuery.lambda() .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(),"第【"+(1+index)+"行】商品类别【"+s.getCategoryName()+"】不存在"); } QueryWrapper brandQuery = new QueryWrapper<>(); brandQuery.lambda() .eq(Brand::getType,Constants.ONE) .eq(Brand::getName,s.getBrandName()); 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(),"第【"+(1+index)+"行】商品品牌【"+s.getBrandName()+"】不存在"); } String path =basePath+ s.getId(); List mulFiles = new ArrayList<>(); if(StringUtils.isNotBlank(path)){ File dir =new File(path+File.separator); if(dir!=null && dir.isDirectory()){ File[] files = dir.listFiles(); if(files!=null && files.length>0){ for(File f:files){ if(isImgFile(f)){ //取第一张图片作为列表图 baseGoods.setImgurl(baseDataService.getOssImgurl(ossModel,ossModel.getGoodsFolder(),f)); } if(f.isDirectory()){ //如果是文件夹 File[] fs = f.listFiles(); if(fs != null && fs.length > 0){ for(File mf : fs){ if(isImgFile(mf)){ if(mulFiles==null){ mulFiles = new ArrayList<>(); } mulFiles.add(baseDataService.getOssImgurl(ossModel,ossModel.getGoodsFolder(),mf)); } } } } } } } } // 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> collect = Arrays.asList(baseGoodsParamString.split("\n")) .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 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()); }finally { } return null; } private boolean existedIdInList(String id,int index, List dataList) { for (int j = 0; j