new
Agoni 1 year ago
parent 0a662b9613
commit 9946d271c3

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.bs.service.quotationsheet; package cn.iocoder.yudao.module.bs.service.quotationsheet;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO;
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetdetail.QuotationSheetDetailDO; 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.QuotationSheetDetailService;
import cn.iocoder.yudao.module.bs.service.quotationsheetdetail.QuotationSheetDetailServiceImpl; import cn.iocoder.yudao.module.bs.service.quotationsheetdetail.QuotationSheetDetailServiceImpl;
@ -41,13 +42,14 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
public Long createQuotationSheet(QuotationSheetCreateReqVO createReqVO) { public Long createQuotationSheet(QuotationSheetCreateReqVO createReqVO) {
// 插入 // 插入
QuotationSheetDO quotationSheet = QuotationSheetConvert.INSTANCE.convert(createReqVO); QuotationSheetDO quotationSheet = QuotationSheetConvert.INSTANCE.convert(createReqVO);
quotationSheetMapper.insert(quotationSheet); saveOrUpdate(quotationSheet);
//
if (createReqVO.getQuotationDetails().size() > 0){ if (createReqVO.getQuotationDetails().size() > 0){
//中间表插入数据 //中间表插入数据
createReqVO.getQuotationDetails().forEach(quotationSheetDetail -> { for (QuotationSheetDetailDO quotationSheetDetailDO : createReqVO.getQuotationDetails()) {
quotationSheetDetail.setCompanyId(quotationSheet.getId()); quotationSheetDetailDO.setCompanyId(quotationSheet.getId());
}); }
quotationSheetDetailService.saveBatch(createReqVO.getQuotationDetails());
} }
return quotationSheet.getId(); return quotationSheet.getId();
} }
@ -57,20 +59,17 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
// 校验存在 // 校验存在
validateQuotationSheetExists(updateReqVO.getId()); validateQuotationSheetExists(updateReqVO.getId());
//删除原先 //删除原先
List<QuotationSheetDetailDO > quotationSheetDetailDOList = quotationSheetDetailService.remove(Wrappers.<QuotationSheetDetailDO> lambdaQuery()
quotationSheetDetailService.list(Wrappers.<QuotationSheetDetailDO> lambdaQuery()
.eq(QuotationSheetDetailDO::getCompanyId,updateReqVO.getId()).eq(BaseDO::getDeleted,0)); .eq(QuotationSheetDetailDO::getCompanyId,updateReqVO.getId()).eq(BaseDO::getDeleted,0));
if (quotationSheetDetailDOList.size() > 0){
quotationSheetDetailService.saveBatch(quotationSheetDetailDOList);
}
// 更新 // 更新
QuotationSheetDO updateObj = QuotationSheetConvert.INSTANCE.convert(updateReqVO); QuotationSheetDO updateObj = QuotationSheetConvert.INSTANCE.convert(updateReqVO);
quotationSheetMapper.updateById(updateObj); saveOrUpdate(updateObj);
if (updateReqVO.getQuotationDetails().size() > 0){ if (updateReqVO.getQuotationDetails().size() > 0){
//中间表插入数据 //中间表插入数据
updateReqVO.getQuotationDetails().forEach(quotationSheetDetail -> { updateReqVO.getQuotationDetails().forEach(quotationSheetDetail -> {
quotationSheetDetail.setCompanyId(updateObj.getId()); quotationSheetDetail.setCompanyId(updateObj.getId());
}); });
quotationSheetDetailService.saveBatch(updateReqVO.getQuotationDetails());
} }
} }

Loading…
Cancel
Save