new
Agoni 1 year ago
parent 0a662b9613
commit 9946d271c3

@ -1,6 +1,7 @@
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.expenseapplytrip.ExpenseApplyTripDO;
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;
@ -41,13 +42,14 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
public Long createQuotationSheet(QuotationSheetCreateReqVO createReqVO) {
// 插入
QuotationSheetDO quotationSheet = QuotationSheetConvert.INSTANCE.convert(createReqVO);
quotationSheetMapper.insert(quotationSheet);
//
saveOrUpdate(quotationSheet);
if (createReqVO.getQuotationDetails().size() > 0){
//中间表插入数据
createReqVO.getQuotationDetails().forEach(quotationSheetDetail -> {
quotationSheetDetail.setCompanyId(quotationSheet.getId());
});
for (QuotationSheetDetailDO quotationSheetDetailDO : createReqVO.getQuotationDetails()) {
quotationSheetDetailDO.setCompanyId(quotationSheet.getId());
}
quotationSheetDetailService.saveBatch(createReqVO.getQuotationDetails());
}
return quotationSheet.getId();
}
@ -57,20 +59,17 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
// 校验存在
validateQuotationSheetExists(updateReqVO.getId());
//删除原先
List<QuotationSheetDetailDO > quotationSheetDetailDOList =
quotationSheetDetailService.list(Wrappers.<QuotationSheetDetailDO> lambdaQuery()
quotationSheetDetailService.remove(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);
saveOrUpdate(updateObj);
if (updateReqVO.getQuotationDetails().size() > 0){
//中间表插入数据
updateReqVO.getQuotationDetails().forEach(quotationSheetDetail -> {
quotationSheetDetail.setCompanyId(updateObj.getId());
});
quotationSheetDetailService.saveBatch(updateReqVO.getQuotationDetails());
}
}

Loading…
Cancel
Save