|
|
@@ -718,6 +718,92 @@ public class InquiryForSaleServiceImpl implements InquiryForSaleService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ModelMap saveQuote(PublicInquiryItem publicInquiryItem) {
|
|
|
+ ModelMap result = new ModelMap();
|
|
|
+ result.put("success", false);
|
|
|
+ // 判断报价人信息
|
|
|
+ if (StringUtils.isEmpty(publicInquiryItem) || StringUtils.isEmpty(publicInquiryItem.getVendUU()) || StringUtils.isEmpty(publicInquiryItem.getVendUserUU())) {
|
|
|
+ result.put("message", "报价人信息不能为空");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ // 是否为自己的询价 并查询公共询价的信息
|
|
|
+ PurcInquiryItemInfo item = inquiryItemInfoDao.findOne(publicInquiryItem.getSourceId());
|
|
|
+ if (StringUtils.isEmpty(item)) {
|
|
|
+ result.put("message", "找不到当前公共询价");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if (item.getInquiry() != null && item.getInquiry().getEnUU().equals(publicInquiryItem.getVendUU())) {
|
|
|
+ result.put("message", "不能对自己单据进行报价");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ PublicInquiryItem existInquiry = infoDao.findByVendUUAndSourceId(publicInquiryItem.getVendUU(), publicInquiryItem.getSourceId());
|
|
|
+ // 是否重复报价
|
|
|
+ if (null != existInquiry) {
|
|
|
+ result.put("message", "该单据已报价,不能重复报价");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ // 是否已经已经转报价
|
|
|
+ List<PublicInquiry> saleInquiries = inquiryDao.findByEnUUAndCode(item.getInquiry().getEnUU(), item.getInquiry().getCode());
|
|
|
+ PublicInquiry inquiry = new PublicInquiry();
|
|
|
+ // 报价明细
|
|
|
+ PublicInquiryItem inquiryItem = new PublicInquiryItem( item);
|
|
|
+ inquiryItem.setMinOrderQty(publicInquiryItem.getMinOrderQty());
|
|
|
+ inquiryItem.setMinPackQty(publicInquiryItem.getMinPackQty());
|
|
|
+ inquiryItem.setLeadtime(publicInquiryItem.getLeadtime());
|
|
|
+ inquiryItem.setQutoApp(InquirySource.UU.name());
|
|
|
+ inquiryItem.setReplies(publicInquiryItem.getReplies());
|
|
|
+ inquiryItem.setCurrency(publicInquiryItem.getCurrency());
|
|
|
+ inquiryItem.setTaxrate(publicInquiryItem.getTaxrate());
|
|
|
+ inquiryItem.setVendUU(publicInquiryItem.getVendUU());
|
|
|
+ inquiryItem.setVendUserUU(publicInquiryItem.getVendUserUU());
|
|
|
+ inquiryItem.setReplaceCmpCode(publicInquiryItem.getReplaceCmpCode());
|
|
|
+ inquiryItem.setReplaceBrand(publicInquiryItem.getReplaceCmpCode());
|
|
|
+ inquiryItem.setReplaceSpec(publicInquiryItem.getReplaceCmpCode());
|
|
|
+ inquiryItem.setIsReplace(publicInquiryItem.getIsReplace());
|
|
|
+ if (CollectionUtils.isEmpty(saleInquiries)) {
|
|
|
+ // 附件
|
|
|
+ if (!CollectionUtils.isEmpty(inquiry.getAttachs())) {
|
|
|
+ Set<Attach> attachs = new HashSet<Attach>();
|
|
|
+ for (com.uas.ps.inquiry.model.Attach attach : inquiry.getAttachs()) {
|
|
|
+ com.uas.ps.inquiry.model.Attach newAttach = new com.uas.ps.inquiry.model.Attach();
|
|
|
+ newAttach.setDate(new Date());
|
|
|
+ newAttach.setDescription(attach.getDescription());
|
|
|
+ newAttach.setName(attach.getName());
|
|
|
+ newAttach.setPath(attach.getPath());
|
|
|
+ newAttach.setRelatedKey(attach.getRelatedKey());
|
|
|
+ newAttach.setSize(attach.getSize());
|
|
|
+ attachs.add(newAttach);
|
|
|
+ }
|
|
|
+ inquiry.setAttachs(attachs);
|
|
|
+
|
|
|
+ }
|
|
|
+ // 转报价后 主表信息保存
|
|
|
+ inquiry = new PublicInquiry(item.getInquiry());
|
|
|
+ if (null == inquiry.getEnName()) {
|
|
|
+ Enterprise e = enterpriseDao.findOne(inquiry.getEnUU());
|
|
|
+ inquiry.setEnName(e.getEnName());
|
|
|
+ }
|
|
|
+ inquiry = inquiryDao.save(inquiry);
|
|
|
+ } else { // 已经存在
|
|
|
+ inquiry = saleInquiries.get(0);
|
|
|
+ inquiryItem.setInquiry(inquiry);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ inquiryItem = SaveInquiryItems(inquiry, inquiryItem);
|
|
|
+ // 报价成功后保存到个人物料库中
|
|
|
+ if (null != inquiryItem && !StringUtils.isEmpty(inquiryItem.getInbrand()) && !StringUtils.isEmpty(inquiryItem.getCmpCode())) {
|
|
|
+ saveInquiryItemProduct(inquiryItem);
|
|
|
+ }
|
|
|
+ result.put("success", true);
|
|
|
+ result.put("content", inquiryItem);
|
|
|
+ return result;
|
|
|
+ } catch (Exception e) {
|
|
|
+ result.put("message", e.getMessage());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private InquiryEnRemind itemConvertEnRemind(PurcInquiryItem item) {
|
|
|
InquiryEnRemind remind = new InquiryEnRemind();
|
|
|
//remind.setEnName(enterprise.getEnName());
|