绑定至规格
This commit is contained in:
parent
8e27e25936
commit
82c72c9e0c
|
|
@ -68,7 +68,7 @@ public class TbProskuConController {
|
||||||
throw new Exception(be.getMessage());
|
throw new Exception(be.getMessage());
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new Exception("相同商品耗材信息不允许添加");
|
throw new Exception("参数错误");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,8 @@
|
||||||
*/
|
*/
|
||||||
package cn.ysk.cashier.cons.service.dto;
|
package cn.ysk.cashier.cons.service.dto;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package cn.ysk.cashier.cons.service.dto;
|
package cn.ysk.cashier.cons.service.dto;
|
||||||
|
|
||||||
import cn.ysk.cashier.cons.domain.TbProskuCon;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
@ -11,5 +10,5 @@ public class TbProskuConDtoV2 {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Integer productId;
|
private Integer productId;
|
||||||
List<TbProskuCon> cons;
|
List<TbProskuConDto> cons;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package cn.ysk.cashier.cons.service.impl;
|
package cn.ysk.cashier.cons.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.ysk.cashier.cons.domain.TbConsInfo;
|
import cn.ysk.cashier.cons.domain.TbConsInfo;
|
||||||
import cn.ysk.cashier.cons.domain.TbConsSuppFlow;
|
import cn.ysk.cashier.cons.domain.TbConsSuppFlow;
|
||||||
|
|
@ -172,7 +174,7 @@ public class TbProskuConServiceImpl implements TbProskuConService {
|
||||||
throw new BadRequestException("对应的商品信息不存在");
|
throw new BadRequestException("对应的商品信息不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Integer> collect = resources.getCons().stream().map(TbProskuCon::getId).collect(Collectors.toList());
|
List<Integer> collect = resources.getCons().stream().map(TbProskuConDto::getId).collect(Collectors.toList());
|
||||||
//现有的
|
//现有的
|
||||||
List<TbProskuCon> tbProskuCons = tbProskuConRepository.searchAllByProductId(resources.getProductId());
|
List<TbProskuCon> tbProskuCons = tbProskuConRepository.searchAllByProductId(resources.getProductId());
|
||||||
List<Integer> delIds = new ArrayList<>();
|
List<Integer> delIds = new ArrayList<>();
|
||||||
|
|
@ -186,7 +188,7 @@ public class TbProskuConServiceImpl implements TbProskuConService {
|
||||||
}
|
}
|
||||||
|
|
||||||
//判断
|
//判断
|
||||||
for (TbProskuCon resource : resources.getCons()) {
|
for (TbProskuConDto resource : resources.getCons()) {
|
||||||
TbConsInfo tbConsInfo = tbConsInfoRepository.findById(resource.getConInfoId()).orElseGet(TbConsInfo::new);
|
TbConsInfo tbConsInfo = tbConsInfoRepository.findById(resource.getConInfoId()).orElseGet(TbConsInfo::new);
|
||||||
if (ObjectUtil.isNull(tbConsInfo) || ObjectUtil.isNull(tbConsInfo.getId())) {
|
if (ObjectUtil.isNull(tbConsInfo) || ObjectUtil.isNull(tbConsInfo.getId())) {
|
||||||
throw new BadRequestException("对应的耗材信息不存在");
|
throw new BadRequestException("对应的耗材信息不存在");
|
||||||
|
|
@ -197,7 +199,9 @@ public class TbProskuConServiceImpl implements TbProskuConService {
|
||||||
throw new BadRequestException("规格信息不存在");
|
throw new BadRequestException("规格信息不存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newCons.add(resource);
|
TbProskuCon tbConsInfo1 = new TbProskuCon();
|
||||||
|
BeanUtil.copyProperties(tbConsInfo1,resource, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
|
newCons.add(tbConsInfo1);
|
||||||
}
|
}
|
||||||
if (!CollectionUtils.isEmpty(newCons)) {
|
if (!CollectionUtils.isEmpty(newCons)) {
|
||||||
tbProskuConRepository.saveAll(newCons);
|
tbProskuConRepository.saveAll(newCons);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue