常熟吴彦祖 5 months ago
parent
commit
dba11c58b5
  1. 3
      src/main/java/com/xujie/modules/supplier/data/PurQuotationReplyHistData.java
  2. 21
      src/main/java/com/xujie/modules/supplier/service/impl/PurQuotationReplyHistServiceImpl.java
  3. 37
      src/main/java/com/xujie/modules/supplier/service/impl/PurQuotationServiceImpl.java
  4. 3
      src/main/resources/mapper/supplier/PurQuotationDetailMapper.xml
  5. 2
      src/main/resources/mapper/supplier/PurQuotationReplyHistMapper.xml

3
src/main/java/com/xujie/modules/supplier/data/PurQuotationReplyHistData.java

@ -147,6 +147,9 @@ public class PurQuotationReplyHistData extends QueryPage {
@ApiModelProperty(value = "排除状态") @ApiModelProperty(value = "排除状态")
private String notExistsStatus; private String notExistsStatus;
@ApiModelProperty(value = "审批筛选:need-需要审批 none-不需要审批 all-全部")
private String approvalFilter;
public Object getKey() { public Object getKey() {
return this.id; return this.id;
} }

21
src/main/java/com/xujie/modules/supplier/service/impl/PurQuotationReplyHistServiceImpl.java

@ -48,6 +48,10 @@ public class PurQuotationReplyHistServiceImpl extends ServiceImpl<PurQuotationRe
return; return;
} }
if (model.getPrice() == null || model.getPrice() <= 0) {
throw new RuntimeException("未税单价必须大于0");
}
int count = baseMapper.getPurHistCount(model); int count = baseMapper.getPurHistCount(model);
model.setSeqNo(++count); model.setSeqNo(++count);
//更新物料状态 //更新物料状态
@ -109,8 +113,8 @@ public class PurQuotationReplyHistServiceImpl extends ServiceImpl<PurQuotationRe
purQuotationDetailMapper.updatePurDetailStatus(purQuoDetailData); purQuotationDetailMapper.updatePurDetailStatus(purQuoDetailData);
//更新报价状态 //更新报价状态
baseMapper.updateById(model); baseMapper.updateById(model);
if (Objects.equals("已接受", model.getStatus())) {
closeHeaderIfAllDetailsAccepted(model.getOrderNo(), model.getSite());
if (Objects.equals("已接受", model.getStatus()) || Objects.equals("已拒绝", model.getStatus())) {
closeHeaderIfAllDetailsFinished(model.getOrderNo(), model.getSite());
} }
} }
@ -136,9 +140,9 @@ public class PurQuotationReplyHistServiceImpl extends ServiceImpl<PurQuotationRe
} }
/** /**
* 全部明细已接受时,主表自动关闭(仅更新主表状态)
* 全部明细已接受或已拒绝时,主表自动关闭(仅更新主表状态)
*/ */
private void closeHeaderIfAllDetailsAccepted(String orderNo, String site) {
private void closeHeaderIfAllDetailsFinished(String orderNo, String site) {
PurQuotationDetail detailQuery = new PurQuotationDetail(); PurQuotationDetail detailQuery = new PurQuotationDetail();
detailQuery.setOrderNo(orderNo); detailQuery.setOrderNo(orderNo);
detailQuery.setSite(site); detailQuery.setSite(site);
@ -146,8 +150,8 @@ public class PurQuotationReplyHistServiceImpl extends ServiceImpl<PurQuotationRe
if (CollectionUtils.isEmpty(details)) { if (CollectionUtils.isEmpty(details)) {
return; return;
} }
boolean allAccepted = details.stream().allMatch(d -> Objects.equals("已接受", d.getStatus()));
if (!allAccepted) {
boolean allFinished = details.stream().allMatch(this::isDetailFinishedStatus);
if (!allFinished) {
return; return;
} }
PurQuotationHeaderData headerQuery = new PurQuotationHeaderData(); PurQuotationHeaderData headerQuery = new PurQuotationHeaderData();
@ -163,4 +167,9 @@ public class PurQuotationReplyHistServiceImpl extends ServiceImpl<PurQuotationRe
purQuotationHeaderMapper.updateById(update); purQuotationHeaderMapper.updateById(update);
} }
private boolean isDetailFinishedStatus(PurQuotationDetailData detail) {
String status = detail.getStatus();
return Objects.equals("已接受", status) || Objects.equals("已拒绝", status);
}
} }

37
src/main/java/com/xujie/modules/supplier/service/impl/PurQuotationServiceImpl.java

@ -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) {
PurQuotationDetail existing = purQuotationDetailMapper.selectById(model.getId());
if (existing == null) {
throw new RuntimeException("物料明细不存在");
}
if (!isDetailEditableStatus(existing.getStatus())) {
throw new RuntimeException("物料明细只有在待提交或待报价状态才可以编辑");
} }
if(model.getId() != null){
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());
} }

3
src/main/resources/mapper/supplier/PurQuotationDetailMapper.xml

@ -326,7 +326,7 @@
, G.payment_term as paymentTerm , G.payment_term as paymentTerm
, P.part_spec as spec , P.part_spec as spec
,B.qty,H.umid,H.convert_factor,H.price
,B.qty,U.UMName as umid,H.convert_factor,H.price
,H.tax,H.material_cost ,H.produce_fee,H.profit,H.additional_cost,H.freight,H.duty ,H.tax,H.material_cost ,H.produce_fee,H.profit,H.additional_cost,H.freight,H.duty
,H.surface_fee ,H.purchase_cycle ,H.mould_fee ,H.reason, H.remark ,H.surface_fee ,H.purchase_cycle ,H.mould_fee ,H.reason, H.remark
, (SELECT dbo.Get_Tax_TaxRate(A.site, A.tax_code)) as taxRate , (SELECT dbo.Get_Tax_TaxRate(A.site, A.tax_code)) as taxRate
@ -339,6 +339,7 @@
left join sys_user E on A.buyer = E.username left join sys_user E on A.buyer = E.username
left join DeliveryTerm F on A.site = F.site and A.delivery_term = F.delivery_term_id left join DeliveryTerm F on A.site = F.site and A.delivery_term = F.delivery_term_id
left join PaymentTerm G on A.site = G.site and A.payment_term = G.payment_term_id left join PaymentTerm G on A.site = G.site and A.payment_term = G.payment_term_id
left join um U on U.site=P.site and P.unit=u.UMID
where B.site = '${query.site}' and A.status not in ('待提交','已关闭') where B.site = '${query.site}' and A.status not in ('待提交','已关闭')
<if test="query.supplierId != null and query.supplierId != '' "> and A.supplier_id = '%${query.supplierId}%'</if> <if test="query.supplierId != null and query.supplierId != '' "> and A.supplier_id = '%${query.supplierId}%'</if>
<if test="query.supplierName != null and query.supplierName != '' "> and A.supplier_name like '%${query.supplierName}%'</if> <if test="query.supplierName != null and query.supplierName != '' "> and A.supplier_name like '%${query.supplierName}%'</if>

2
src/main/resources/mapper/supplier/PurQuotationReplyHistMapper.xml

@ -119,6 +119,8 @@
<if test="query.reason != null and query.reason != '' "> and A.reason like '%${query.reason}%'</if> <if test="query.reason != null and query.reason != '' "> and A.reason like '%${query.reason}%'</if>
<if test="query.remark2 != null and query.remark2 != '' "> and A.remark2 like '%${query.remark2}%'</if> <if test="query.remark2 != null and query.remark2 != '' "> and A.remark2 like '%${query.remark2}%'</if>
<if test="query.status != null and query.status != '' "> and A.status like '%${query.status}%'</if> <if test="query.status != null and query.status != '' "> and A.status like '%${query.status}%'</if>
<if test="query.approvalFilter == 'need'"> and A.status = '已报价'</if>
<if test="query.approvalFilter == 'none'"> and A.status != '已报价'</if>
<if test="query.seqNo != null "> and A.seq_no = '${query.seqNo}'</if> <if test="query.seqNo != null "> and A.seq_no = '${query.seqNo}'</if>
<if test="query.notExistsStatus != null and query.notExistsStatus !=''">and B.status not in ('${query.notExistsStatus}')</if> <if test="query.notExistsStatus != null and query.notExistsStatus !=''">and B.status not in ('${query.notExistsStatus}')</if>

Loading…
Cancel
Save