|
|
|
@ -14,6 +14,8 @@ import com.xujie.sys.modules.inquiry.service.InquiryApplicationService; |
|
|
|
import com.xujie.sys.modules.inquiry.mapper.InquiryApplicationMapper; |
|
|
|
import com.xujie.sys.modules.pms.data.EamProjectPartInfoData; |
|
|
|
import com.xujie.sys.modules.quote.entity.Quote; |
|
|
|
import com.xujie.sys.modules.quote.entity.QuoteDetailBom; |
|
|
|
import com.xujie.sys.modules.quote.mapper.QuoteDetailBomMapper; |
|
|
|
import com.xujie.sys.modules.quote.mapper.QuoteMapper; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
@ -21,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.mail.MessagingException; |
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@ -46,6 +49,12 @@ public class InquiryApplicationServiceImpl extends ServiceImpl<InquiryApplicatio |
|
|
|
@Autowired |
|
|
|
private QuoteMapper quoteMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private QuoteDetailBomMapper quoteDetailBomMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private InquiryDetailServiceImpl inquiryDetailServiceImpl; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageUtils searchInquiryApplicationInfo(InquiryApplicationData data) { |
|
|
|
if (data.getBu() != "" && data.getBu() != null) { |
|
|
|
@ -58,35 +67,75 @@ public class InquiryApplicationServiceImpl extends ServiceImpl<InquiryApplicatio |
|
|
|
InquiryDetailData inquiryDetailData = new InquiryDetailData(); |
|
|
|
inquiryDetailData.setRfqId(inquiryApplicationData.getId()); |
|
|
|
List<InquiryDetailData> inquiryDetailDataList = inquiryDetailMapper.searchInquiryDetailInfo(inquiryDetailData); |
|
|
|
for (InquiryDetailData detailData : inquiryDetailDataList) { |
|
|
|
List<EamProjectPartInfoData> detailDataList = inquiryApplicationMapper.rfqGetFullBOM(detailData); |
|
|
|
Quote quoteData = new Quote(); |
|
|
|
quoteData.setInsideInquiryNo(inquiryApplicationData.getRfqNo()); |
|
|
|
// List<Quote> salesQuotationList = quoteMapper.queryQuoteList(quoteData); |
|
|
|
// 如果detailDataList只有一条数据 |
|
|
|
if (detailDataList.size() > 1) { |
|
|
|
inquiryApplicationData.setBomStatus("BOM制作完成"); |
|
|
|
break; |
|
|
|
} |
|
|
|
// 如果是循环的最后一条数据 |
|
|
|
if (detailData.equals(inquiryDetailDataList.get(inquiryDetailDataList.size() - 1))) { |
|
|
|
inquiryApplicationData.setBomStatus("BOM制作中"); |
|
|
|
if (!inquiryDetailDataList.isEmpty()) { |
|
|
|
int hasBom = 0; |
|
|
|
for (InquiryDetailData detailData : inquiryDetailDataList) { |
|
|
|
List<Quote> quoteList = inquiryDetailMapper.searchQuotationRecordInfo(detailData); |
|
|
|
for (Quote quote : quoteList) { |
|
|
|
QuoteDetailBom quoteDetailBom = new QuoteDetailBom(); |
|
|
|
quoteDetailBom.setQuoteId(quote.getId()); |
|
|
|
List<QuoteDetailBom> detailDataList = quoteDetailBomMapper.queryQuoteDetailBom2(quoteDetailBom); |
|
|
|
if (!detailDataList.isEmpty()) { |
|
|
|
hasBom++; |
|
|
|
} |
|
|
|
} |
|
|
|
Quote quoteData = new Quote(); |
|
|
|
quoteData.setInsideInquiryNo(inquiryApplicationData.getRfqNo()); |
|
|
|
quoteData.setCreateBy("admin"); |
|
|
|
List<Quote> salesQuotationList = quoteMapper.queryQuoteList(quoteData); |
|
|
|
// 如果Bom有数据 |
|
|
|
if (hasBom > 0) { |
|
|
|
if (inquiryApplicationData.getStatus().equals("C")){ |
|
|
|
inquiryApplicationData.setBomStatus("BOM制作完成"); |
|
|
|
} else { |
|
|
|
List<String> statusQuoteList = new ArrayList<>(); |
|
|
|
for (Quote quote : salesQuotationList) { |
|
|
|
statusQuoteList.add(quote.getStatus()); |
|
|
|
} |
|
|
|
if (!statusQuoteList.contains("下达")) { |
|
|
|
inquiryApplicationData.setBomStatus("TP计算中"); |
|
|
|
} else { |
|
|
|
for (int i = 0; i < statusQuoteList.size(); i++) { |
|
|
|
String s = statusQuoteList.get(i); |
|
|
|
if (s.equals("下达")) { |
|
|
|
// 当前循环是否是最后一个 |
|
|
|
if (i == statusQuoteList.size() - 1) { |
|
|
|
inquiryApplicationData.setBomStatus("报价单审批中"); |
|
|
|
|
|
|
|
for (int j = 0; j < salesQuotationList.size(); j++) { |
|
|
|
Quote quote = salesQuotationList.get(j); |
|
|
|
InquiryDetailData inquiryDetailData1 = new InquiryDetailData(); |
|
|
|
inquiryDetailData1.setApplicationNo(quote.getQuoteVersionNo()); |
|
|
|
inquiryDetailData1.setPage(1); |
|
|
|
inquiryDetailData1.setLimit(1); |
|
|
|
List<InquiryDetailData> quoteAuthData = (List<InquiryDetailData>) inquiryDetailServiceImpl.searchAllInquiryQuoteInfo(inquiryDetailData1).getList(); |
|
|
|
|
|
|
|
if (quoteAuthData.isEmpty() || !quoteAuthData.get(0).getAllAuthFlag().equals("全部审批")) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
// 如果是最后一个循环 |
|
|
|
if (j == salesQuotationList.size() - 1) { |
|
|
|
inquiryApplicationData.setBomStatus("报价单审批成功"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
inquiryApplicationData.setBomStatus("报价单部分审批中"); |
|
|
|
break; // 结束外层循环 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
// 如果是循环的最后一条数据 |
|
|
|
if (detailData.equals(inquiryDetailDataList.get(inquiryDetailDataList.size() - 1))) { |
|
|
|
inquiryApplicationData.setBomStatus("BOM制作中"); |
|
|
|
} |
|
|
|
} |
|
|
|
// else { |
|
|
|
// if (!salesQuotationList.isEmpty()){ |
|
|
|
// for (Quote quote : salesQuotationList) { |
|
|
|
// if (quote.getStatus().equals("下达")){ |
|
|
|
// inquiryApplicationData.setBomStatus("报价单审核中"); |
|
|
|
// // 结束循环 |
|
|
|
// break; |
|
|
|
// } |
|
|
|
// // 如果是最后一个循环 |
|
|
|
// if (quote.equals(salesQuotationList.get(salesQuotationList.size() - 1))){ |
|
|
|
// inquiryApplicationData.setBomStatus("TP计算中"); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
} else { |
|
|
|
inquiryApplicationData.setBomStatus("BOM制作中"); |
|
|
|
} |
|
|
|
} |
|
|
|
page.setRecords(list); |
|
|
|
|