|
|
@@ -497,117 +497,103 @@ public class PurcInquiryServiceImpl implements PurcInquiryService {
|
|
|
@Override
|
|
|
public ModelMap saveWithoutVendor(PurcInquiryInfo inquiryInfo, FileUpload uploadItem) {
|
|
|
PurcInquiry inquiry = new PurcInquiry();
|
|
|
+ PurcInquiry old = inquiryDao.findByCode(inquiryInfo.getCode());
|
|
|
ModelMap map = new ModelMap();
|
|
|
- Set<Attach> attachs = new HashSet<Attach>();
|
|
|
- if (uploadItem.getFile() != null) {// 附件存在
|
|
|
- Attach attach = attachService.upload(uploadItem, "productAttach", "平台询价上传传物料照片或附件");
|
|
|
- if (attach == null) {
|
|
|
- map.put("error", "文件太大");
|
|
|
- } else {
|
|
|
- attachs.add(attach);
|
|
|
- inquiry.setAttachs(attachs);
|
|
|
+ if (old == null) {
|
|
|
+ Set<Attach> attachs = new HashSet<Attach>();
|
|
|
+ if (uploadItem.getFile() != null) {// 附件存在
|
|
|
+ Attach attach = attachService.upload(uploadItem, "productAttach", "平台询价上传传物料照片或附件");
|
|
|
+ if (attach == null) {
|
|
|
+ map.put("error", "文件太大");
|
|
|
+ } else {
|
|
|
+ attachs.add(attach);
|
|
|
+ inquiry.setAttachs(attachs);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
- Long useruu = SystemSession.getUser().getUserUU();
|
|
|
- if (inquiryInfo.getId() == null) {// 新增
|
|
|
- inquiry.setDate(new Date());
|
|
|
- inquiry.setCode(inquiryInfo.getCode());
|
|
|
- inquiry.setEnUU(enuu);
|
|
|
- inquiry.setCode(inquiryInfo.getCode());
|
|
|
- inquiry.setEndDate(inquiryInfo.getEndDate());
|
|
|
- inquiry.setRemark(inquiryInfo.getRemark());
|
|
|
- inquiry.setEnvironment(inquiryInfo.getEnvironment());
|
|
|
- inquiry.setEnterprise(enterpriseDao.findEnterpriseInfoByUu(enuu));
|
|
|
- inquiry.setRecorder(SystemSession.getUser().getUserName());
|
|
|
- inquiry.setRecorderUU(SystemSession.getUser().getUserUU());
|
|
|
- inquiry.setEnteryStatus(Status.UNAPPLY.value());
|
|
|
- inquiry.setPriceType(inquiryInfo.getPriceType());
|
|
|
- inquiry.setIsOpen((short) inquiryInfo.getIsOpen());
|
|
|
- inquiry.setInvoice(inquiryInfo.getInvoice());
|
|
|
- inquiry.setShip(inquiryInfo.getShip());
|
|
|
- inquiry.setCurrency(inquiryInfo.getCurrency());
|
|
|
- inquiry.setIfTax(inquiryInfo.getIfTax());
|
|
|
- inquiry.setInquirytype(inquiryInfo.getInquirytype());
|
|
|
- Set<PurcInquiryItem> items = new HashSet<PurcInquiryItem>();
|
|
|
- Short i = 1;
|
|
|
- if (!CollectionUtils.isEmpty(inquiryInfo.getInquiryItems())) {
|
|
|
- for (PurcInquiryItem purcitem : inquiryInfo.getInquiryItems()) {
|
|
|
- PurcInquiryItem item = new PurcInquiryItem();
|
|
|
- Product product = new Product();
|
|
|
- if (purcitem.getProductId() != null) {// 点击选择出来的,一般带有id
|
|
|
- product = productDao.findOne(purcitem.getProductId());
|
|
|
- item.setProduct(product);
|
|
|
- item.setProductId(product.getId());
|
|
|
- } else {// 导入或手动输入的一般不带有id
|
|
|
- product = productDao.findByEnUUAndCodeAndBrand(SystemSession.getUser().getEnterprise().getUu(),
|
|
|
- purcitem.getProdCode(), purcitem.getInbrand());
|
|
|
- if (product != null) {// 存在直接选择
|
|
|
- item.setProduct(product);
|
|
|
- item.setProductId(product.getId());
|
|
|
- } else { // 不存在,插入物料
|
|
|
- product = new Product();
|
|
|
- product.setBrand(purcitem.getInbrand());
|
|
|
- product.setCmpCode(purcitem.getCmpCode());
|
|
|
- product.setSourceApp(SOURCERAPP);
|
|
|
- product.setCode(purcitem.getProdCode());
|
|
|
- product.setEnUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
- product.setTitle(purcitem.getProdTitle());
|
|
|
- product.setCmpUuId(purcitem.getProdCode());
|
|
|
- product.setUnit(purcitem.getUnit());
|
|
|
- product.setUserUU(SystemSession.getUser().getUserUU());
|
|
|
- product.setShipAddr(SystemSession.getUser().getEnterprise().getEnAddress());
|
|
|
- product.setSpec(purcitem.getProdTitle());
|
|
|
- product = productDao.save(product);
|
|
|
+ Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
+ Long useruu = SystemSession.getUser().getUserUU();
|
|
|
+ if (inquiryInfo.getId() == null) {// 新增
|
|
|
+ inquiry.setDate(new Date());
|
|
|
+ inquiry.setCode(inquiryInfo.getCode());
|
|
|
+ inquiry.setEnUU(enuu);
|
|
|
+ inquiry.setCode(inquiryInfo.getCode());
|
|
|
+ inquiry.setEndDate(inquiryInfo.getEndDate());
|
|
|
+ inquiry.setRemark(inquiryInfo.getRemark());
|
|
|
+ inquiry.setEnvironment(inquiryInfo.getEnvironment());
|
|
|
+ inquiry.setEnterprise(enterpriseDao.findEnterpriseInfoByUu(enuu));
|
|
|
+ inquiry.setRecorder(SystemSession.getUser().getUserName());
|
|
|
+ inquiry.setRecorderUU(SystemSession.getUser().getUserUU());
|
|
|
+ inquiry.setEnteryStatus(Status.UNAPPLY.value());
|
|
|
+ inquiry.setPriceType(inquiryInfo.getPriceType());
|
|
|
+ inquiry.setIsOpen((short) inquiryInfo.getIsOpen());
|
|
|
+ inquiry.setInvoice(inquiryInfo.getInvoice());
|
|
|
+ inquiry.setShip(inquiryInfo.getShip());
|
|
|
+ inquiry.setCurrency(inquiryInfo.getCurrency());
|
|
|
+ inquiry.setIfTax(inquiryInfo.getIfTax());
|
|
|
+ inquiry.setInquirytype(inquiryInfo.getInquirytype());
|
|
|
+ Set<PurcInquiryItem> items = new HashSet<PurcInquiryItem>();
|
|
|
+ Short i = 1;
|
|
|
+ if (!CollectionUtils.isEmpty(inquiryInfo.getInquiryItems())) {
|
|
|
+ for (PurcInquiryItem purcitem : inquiryInfo.getInquiryItems()) {
|
|
|
+ PurcInquiryItem item = new PurcInquiryItem();
|
|
|
+ Product product = new Product();
|
|
|
+ if (purcitem.getProductId() != null) {// 点击选择出来的,一般带有id
|
|
|
+ product = productDao.findOne(purcitem.getProductId());
|
|
|
item.setProduct(product);
|
|
|
item.setProductId(product.getId());
|
|
|
+ } else {// 导入或手动输入的一般不带有id
|
|
|
+ product = productDao.findByEnUUAndCodeAndBrand(
|
|
|
+ SystemSession.getUser().getEnterprise().getUu(), purcitem.getProdCode(),
|
|
|
+ purcitem.getInbrand());
|
|
|
+ if (product != null) {// 存在直接选择
|
|
|
+ item.setProduct(product);
|
|
|
+ item.setProductId(product.getId());
|
|
|
+ } else { // 不存在,插入物料
|
|
|
+ product = new Product();
|
|
|
+ product.setBrand(purcitem.getInbrand());
|
|
|
+ product.setCmpCode(purcitem.getCmpCode());
|
|
|
+ product.setSourceApp(SOURCERAPP);
|
|
|
+ product.setCode(purcitem.getProdCode());
|
|
|
+ product.setEnUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ product.setTitle(purcitem.getProdTitle());
|
|
|
+ product.setCmpUuId(purcitem.getProdCode());
|
|
|
+ product.setUnit(purcitem.getUnit());
|
|
|
+ product.setUserUU(SystemSession.getUser().getUserUU());
|
|
|
+ product.setShipAddr(SystemSession.getUser().getEnterprise().getEnAddress());
|
|
|
+ product.setSpec(purcitem.getProdTitle());
|
|
|
+ product = productDao.save(product);
|
|
|
+ item.setProduct(product);
|
|
|
+ item.setProductId(product.getId());
|
|
|
+ }
|
|
|
}
|
|
|
+ item.setInquiry(inquiry);
|
|
|
+ item.setNumber(i);
|
|
|
+ item.setCurrency(inquiry.getCurrency());
|
|
|
+ item.setFromDate(new Date());
|
|
|
+ item.setToDate(purcitem.getToDate());
|
|
|
+ if (item.getCurrency().equals(RMB)) {
|
|
|
+ item.setTaxrate((float) 17);
|
|
|
+ } else {
|
|
|
+ item.setTaxrate((float) 0);
|
|
|
+ }
|
|
|
+ item.setRemark(purcitem.getRemark());
|
|
|
+ item.setStatus((short) Status.NOT_REPLY.value());
|
|
|
+ item.setIsOpen(inquiryInfo.getIsOpen());
|
|
|
+ item.setNeedquantity(purcitem.getNeedquantity());
|
|
|
+ items.add(item);
|
|
|
+ i++;
|
|
|
}
|
|
|
- item.setInquiry(inquiry);
|
|
|
- item.setNumber(i);
|
|
|
- item.setCurrency(inquiry.getCurrency());
|
|
|
- item.setFromDate(new Date());
|
|
|
- item.setToDate(purcitem.getToDate());
|
|
|
- if (item.getCurrency().equals(RMB)) {
|
|
|
- item.setTaxrate((float) 17);
|
|
|
- } else {
|
|
|
- item.setTaxrate((float) 0);
|
|
|
- }
|
|
|
- item.setRemark(purcitem.getRemark());
|
|
|
- item.setStatus((short) Status.NOT_REPLY.value());
|
|
|
- item.setIsOpen(inquiryInfo.getIsOpen());
|
|
|
- item.setNeedquantity(purcitem.getNeedquantity());
|
|
|
- items.add(item);
|
|
|
- i++;
|
|
|
}
|
|
|
- }
|
|
|
- List<PurcInquiryItem> purcitems = purcInquiryItemDao.save(items);
|
|
|
- if (purcitems.get(0).getId() != null) {
|
|
|
- map.put("success", "询价单保存成功");
|
|
|
- map.put("id", purcitems.get(0).getInquiry().getId());
|
|
|
- logger.log("询价单", "平台新增询价单", useruu, SystemSession.getUser().getIp());
|
|
|
- } else {
|
|
|
- map.put("error", "询价单保存失败");
|
|
|
+ List<PurcInquiryItem> purcitems = purcInquiryItemDao.save(items);
|
|
|
+ if (purcitems.get(0).getId() != null) {
|
|
|
+ map.put("success", "询价单保存成功");
|
|
|
+ map.put("id", purcitems.get(0).getInquiry().getId());
|
|
|
+ logger.log("询价单", "平台新增询价单", useruu, SystemSession.getUser().getIp());
|
|
|
+ } else {
|
|
|
+ map.put("error", "询价单保存失败");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- // else {
|
|
|
- // inquiry = inquiryDao.findOne(inquiryInfo.getId());
|
|
|
- // inquiry.setDate(new Date());
|
|
|
- // inquiry.setCode(inquiryInfo.getCode());
|
|
|
- // inquiry.setEnUU(enuu);
|
|
|
- // inquiry.setCode(inquiryInfo.getCode());
|
|
|
- // inquiry.setEndDate(inquiryInfo.getEndDate());
|
|
|
- // inquiry.setRemark(inquiryInfo.getRemark());
|
|
|
- // inquiry.setEnvironment(inquiryInfo.getEnvironment());
|
|
|
- // inquiry.setEnterprise(enterpriseDao.findEnterpriseInfoByUu(enuu));
|
|
|
- // inquiry.setRecorder(SystemSession.getUser().getUserName());
|
|
|
- // inquiry.setRecorderUU(SystemSession.getUser().getUserUU());
|
|
|
- // inquiry.setEnteryStatus(Status.UNAPPLY.value());
|
|
|
- // inquiry.setPriceType(inquiryInfo.getPriceType());
|
|
|
- // inquiry.setIsOpen(inquiryInfo.getIsOpen());
|
|
|
- // inquiry = inquiryDao.save(inquiry);
|
|
|
- // map.put("success", "询价单更新成功");
|
|
|
- // }
|
|
|
return map;
|
|
|
}
|
|
|
|