|
|
@ -133,30 +133,51 @@ public class PurQuotationServiceImpl implements PurQuotationService { |
|
|
if(CollectionUtils.isEmpty(purHeaderList)){ |
|
|
if(CollectionUtils.isEmpty(purHeaderList)){ |
|
|
throw new RuntimeException("询价单不存在"); |
|
|
throw new RuntimeException("询价单不存在"); |
|
|
} |
|
|
} |
|
|
//状态是否有待提交 |
|
|
|
|
|
|
|
|
//只有待提交或待报价状态才可以维护物料明细 |
|
|
PurQuotationHeaderData purHeader = purHeaderList.get(0); |
|
|
PurQuotationHeaderData purHeader = purHeaderList.get(0); |
|
|
if(!Objects.equals("待提交", purHeader.getStatus())){ |
|
|
|
|
|
throw new RuntimeException("询价单只有在待提交状态才可以提交"); |
|
|
|
|
|
|
|
|
if (!isDetailMaintainableHeaderStatus(purHeader.getStatus())) { |
|
|
|
|
|
throw new RuntimeException("询价单只有在待提交或待报价状态才可以维护物料明细"); |
|
|
} |
|
|
} |
|
|
if(model.getId() != null){ |
|
|
|
|
|
|
|
|
if (model.getId() != null) { |
|
|
|
|
|
PurQuotationDetail existing = purQuotationDetailMapper.selectById(model.getId()); |
|
|
|
|
|
if (existing == null) { |
|
|
|
|
|
throw new RuntimeException("物料明细不存在"); |
|
|
|
|
|
} |
|
|
|
|
|
if (!isDetailEditableStatus(existing.getStatus())) { |
|
|
|
|
|
throw new RuntimeException("物料明细只有在待提交或待报价状态才可以编辑"); |
|
|
|
|
|
} |
|
|
purQuotationDetailMapper.updateById(model); |
|
|
purQuotationDetailMapper.updateById(model); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
int itemNo = purQuotationDetailMapper.getMaxItemNo(model.getOrderNo(),model.getSite()); |
|
|
|
|
|
|
|
|
if (model.getStatus() == null || model.getStatus().isEmpty()) { |
|
|
|
|
|
model.setStatus(Objects.equals("待报价", purHeader.getStatus()) ? "待报价" : "待提交"); |
|
|
|
|
|
} |
|
|
|
|
|
int itemNo = purQuotationDetailMapper.getMaxItemNo(model.getOrderNo(), model.getSite()); |
|
|
model.setItemNo(++itemNo); |
|
|
model.setItemNo(++itemNo); |
|
|
purQuotationDetailMapper.insert(model); |
|
|
purQuotationDetailMapper.insert(model); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean isDetailMaintainableHeaderStatus(String headerStatus) { |
|
|
|
|
|
return Objects.equals("待提交", headerStatus) || Objects.equals("待报价", headerStatus); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean isDetailEditableStatus(String detailStatus) { |
|
|
|
|
|
return Objects.equals("待提交", detailStatus) || Objects.equals("待报价", detailStatus); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Transactional |
|
|
@Transactional |
|
|
public void delPurDetail(PurQuotationDetail model){ |
|
|
public void delPurDetail(PurQuotationDetail model){ |
|
|
if(model.getId() == null){ |
|
|
if(model.getId() == null){ |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
//只有待提交状态才可以删除 |
|
|
|
|
|
|
|
|
//只有待提交或待报价状态才可以删除 |
|
|
PurQuotationDetail purDetailData = purQuotationDetailMapper.selectById(model.getId()); |
|
|
PurQuotationDetail purDetailData = purQuotationDetailMapper.selectById(model.getId()); |
|
|
if(!Objects.equals("待提交", purDetailData.getStatus())){ |
|
|
|
|
|
throw new RuntimeException("物料明细只有在待提交状态才可以删除"); |
|
|
|
|
|
|
|
|
if (purDetailData == null) { |
|
|
|
|
|
throw new RuntimeException("物料明细不存在"); |
|
|
|
|
|
} |
|
|
|
|
|
if (!isDetailEditableStatus(purDetailData.getStatus())) { |
|
|
|
|
|
throw new RuntimeException("物料明细只有在待提交或待报价状态才可以删除"); |
|
|
} |
|
|
} |
|
|
purQuotationDetailMapper.deleteById(model.getId()); |
|
|
purQuotationDetailMapper.deleteById(model.getId()); |
|
|
} |
|
|
} |
|
|
|