-报价新增物料明细插入

new
Agoni 1 year ago
parent 282288bd82
commit 0a662b9613

@ -1,5 +1,8 @@
package cn.iocoder.yudao.module.bs.controller.admin.quotationsheet.vo;
import cn.iocoder.yudao.module.bs.controller.admin.quotationsheetdetail.vo.QuotationSheetDetailBaseVO;
import cn.iocoder.yudao.module.bs.controller.admin.quotationsheetdetail.vo.QuotationSheetDetailCreateReqVO;
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetdetail.QuotationSheetDetailDO;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
@ -10,7 +13,10 @@ import javax.validation.constraints.*;
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class QuotationSheetCreateReqVO extends QuotationSheetBaseVO {
@Schema(description = "物料id集合", requiredMode = Schema.RequiredMode.REQUIRED)
/* @Schema(description = "物料id集合", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "物料id集合不能为空")
private List<Long> suppliesIdList;
private List<Long> suppliesIdList;*/
@NotEmpty(message = "物料不能为空")
private List<QuotationSheetDetailDO> quotationDetails;
}

@ -1,8 +1,11 @@
package cn.iocoder.yudao.module.bs.controller.admin.quotationsheet.vo;
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheet.QuotationSheetDO;
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetdetail.QuotationSheetDetailDO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - 报价单 Response VO")
@Data
@ -16,4 +19,7 @@ public class QuotationSheetRespVO extends QuotationSheetBaseVO {
@Schema(description = "创建时间")
private LocalDateTime createTime;
private List<QuotationSheetDetailDO> quotationDetails;
}

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bs.controller.admin.quotationsheet.vo;
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetdetail.QuotationSheetDetailDO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@ -15,4 +16,8 @@ public class QuotationSheetUpdateReqVO extends QuotationSheetBaseVO {
@NotNull(message = "主键不能为空")
private Long id;
@NotEmpty(message = "物料不能为空")
private List<QuotationSheetDetailDO> quotationDetails;
}

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bs.dal.dataobject.materiel;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
@ -20,7 +21,7 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MaterielDO extends BaseDO {
public class MaterielDO extends TenantBaseDO {
/**
*

@ -1,5 +1,10 @@
package cn.iocoder.yudao.module.bs.service.quotationsheet;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetdetail.QuotationSheetDetailDO;
import cn.iocoder.yudao.module.bs.service.quotationsheetdetail.QuotationSheetDetailService;
import cn.iocoder.yudao.module.bs.service.quotationsheetdetail.QuotationSheetDetailServiceImpl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.yulichang.base.MPJBaseServiceImpl;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import org.springframework.stereotype.Service;
@ -29,16 +34,21 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
@Resource
private QuotationSheetMapper quotationSheetMapper;
@Resource
private QuotationSheetDetailService quotationSheetDetailService;
@Override
public Long createQuotationSheet(QuotationSheetCreateReqVO createReqVO) {
// 插入
QuotationSheetDO quotationSheet = QuotationSheetConvert.INSTANCE.convert(createReqVO);
if (null != createReqVO.getSuppliesIdList()){
quotationSheet.setMaterialIdList(createReqVO.getSuppliesIdList().toString());
}
// SecurityFrameworkUtils.getLoginUser().
quotationSheetMapper.insert(quotationSheet);
// 返回
//
if (createReqVO.getQuotationDetails().size() > 0){
//中间表插入数据
createReqVO.getQuotationDetails().forEach(quotationSheetDetail -> {
quotationSheetDetail.setCompanyId(quotationSheet.getId());
});
}
return quotationSheet.getId();
}
@ -46,9 +56,22 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
public void updateQuotationSheet(QuotationSheetUpdateReqVO updateReqVO) {
// 校验存在
validateQuotationSheetExists(updateReqVO.getId());
//删除原先
List<QuotationSheetDetailDO > quotationSheetDetailDOList =
quotationSheetDetailService.list(Wrappers.<QuotationSheetDetailDO> lambdaQuery()
.eq(QuotationSheetDetailDO::getCompanyId,updateReqVO.getId()).eq(BaseDO::getDeleted,0));
if (quotationSheetDetailDOList.size() > 0){
quotationSheetDetailService.saveBatch(quotationSheetDetailDOList);
}
// 更新
QuotationSheetDO updateObj = QuotationSheetConvert.INSTANCE.convert(updateReqVO);
quotationSheetMapper.updateById(updateObj);
if (updateReqVO.getQuotationDetails().size() > 0){
//中间表插入数据
updateReqVO.getQuotationDetails().forEach(quotationSheetDetail -> {
quotationSheetDetail.setCompanyId(updateObj.getId());
});
}
}
@Override

@ -3,15 +3,17 @@ package cn.iocoder.yudao.module.bs.service.quotationsheetdetail;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.bs.controller.admin.quotationsheetdetail.vo.*;
import cn.iocoder.yudao.module.bs.dal.dataobject.materiel.MaterielDO;
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetdetail.QuotationSheetDetailDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import com.github.yulichang.base.MPJBaseService;
/**
* Service
*
* @author
*/
public interface QuotationSheetDetailService {
public interface QuotationSheetDetailService extends MPJBaseService<QuotationSheetDetailDO> {
/**
*

@ -1,5 +1,8 @@
package cn.iocoder.yudao.module.bs.service.quotationsheetdetail;
import cn.iocoder.yudao.module.bs.dal.dataobject.materiel.MaterielDO;
import cn.iocoder.yudao.module.bs.dal.mysql.materiel.MaterielMapper;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
@ -22,7 +25,7 @@ import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.*;
*/
@Service
@Validated
public class QuotationSheetDetailServiceImpl implements QuotationSheetDetailService {
public class QuotationSheetDetailServiceImpl extends MPJBaseServiceImpl<QuotationSheetDetailMapper, QuotationSheetDetailDO> implements QuotationSheetDetailService {
@Resource
private QuotationSheetDetailMapper quotationSheetDetailMapper;

Loading…
Cancel
Save