|
|
@@ -4,6 +4,7 @@ import com.uas.platform.b2b.core.util.ThreadUtils;
|
|
|
import com.uas.platform.b2b.dao.*;
|
|
|
import com.uas.platform.b2b.erp.model.Inquiry;
|
|
|
import com.uas.platform.b2b.model.*;
|
|
|
+import com.uas.platform.b2b.ps.InquiryUtils;
|
|
|
import com.uas.platform.b2b.search.SearchService;
|
|
|
import com.uas.platform.b2b.service.AttachService;
|
|
|
import com.uas.platform.b2b.service.ProductUsersService;
|
|
|
@@ -128,7 +129,7 @@ public class PubInquiryServiceImpl implements PubInquiryService {
|
|
|
// 这里先要判断是否有询价单的操作权限,涉及到后面单据查看的问题
|
|
|
Integer count = roleService.findRoleByEnUUAndUserUU(enuu, useruu);
|
|
|
Double manCount = roleDao.findByEnuuAndUserUU(SystemSession.getUser().getEnterprise().getUu(),SystemSession.getUser().getUserUU());
|
|
|
- if(count == 0 && manCount == 0) {
|
|
|
+ if (count == 0 && manCount == 0) {
|
|
|
map.put("info", "您没有询价单的操作权限,请通知管理员设置权限");
|
|
|
return map;
|
|
|
}
|
|
|
@@ -139,11 +140,11 @@ public class PubInquiryServiceImpl implements PubInquiryService {
|
|
|
if (null == inquiry) {// 新增
|
|
|
// 这里设置自动添加为客户关系,并且如果当前用户非管理员要进行自动分配客户处理
|
|
|
Long custuseruu = purcInquiry.getRecorderUU();
|
|
|
- if(null == custuseruu) {
|
|
|
+ if (null == custuseruu) {
|
|
|
Enterprise enterprise = enterpriseDao.findOne(purcInquiry.getEnUU());
|
|
|
custuseruu = enterprise.getEnAdminuu();
|
|
|
}
|
|
|
- if(null != custuseruu) {
|
|
|
+ if (null != custuseruu) {
|
|
|
vendorDao.initVendorAndDistribute(purcInquiry.getEnUU(), custuseruu, enuu, useruu);
|
|
|
logger.log("客户关系", "添加客户", "通过公共询价(" + purcInquiry.getId() + ")转询价自动添加客户关系");
|
|
|
}
|
|
|
@@ -212,6 +213,17 @@ public class PubInquiryServiceImpl implements PubInquiryService {
|
|
|
items.add(item);
|
|
|
i++;
|
|
|
}
|
|
|
+// try {
|
|
|
+// inquiry = InquiryUtils.saveList(new ArrayList<PublicInquiryItem>(items));
|
|
|
+// if (inquiry.getId() != null) {
|
|
|
+// map.put("success", "转客户询价单成功");
|
|
|
+// map.put("id", inquiry.getId());
|
|
|
+// } else {
|
|
|
+// map.put("success", "转客户询价单失败");
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
List<PublicInquiryItem> purcitems = publicInquiryItemDao.save(items);
|
|
|
if (purcitems.get(0).getId() != null) {
|
|
|
map.put("success", "转客户询价单成功");
|
|
|
@@ -257,24 +269,31 @@ public class PubInquiryServiceImpl implements PubInquiryService {
|
|
|
replies.addAll(purcReplies);
|
|
|
item.setReplies(replies);
|
|
|
Long idid = commonDao.queryForObject("select public$inquiryitems_seq.nextval from dual", Long.class);
|
|
|
+ item.setInquiry(inquiry);
|
|
|
+ item.setId(idid);
|
|
|
try {
|
|
|
- commonDao.getJdbcTemplate().update(
|
|
|
- "insert into public$inquiryitems(id_id,id_number,id_currency,id_fromdate,id_todate,id_taxrate,id_prid,id_venduu,"
|
|
|
- + "id_venduseruu,id_sourceapp,id_status,id_custlap,id_sendstatus,id_sourceid,id_inid,id_kind) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
|
|
- idid, item.getNumber(), item.getCurrency(), item.getFromDate(), item.getToDate(),
|
|
|
- item.getTaxrate(), item.getProductId(), item.getVendUU(), item.getVendUserUU(),
|
|
|
- item.getSourceApp(), item.getStatus(), item.getCustLap(), item.getSendStatus(),
|
|
|
- item.getSourceId(), inquiry.getId(), inquiry.getKind());
|
|
|
- } catch (DataAccessException e) {
|
|
|
+ item = InquiryUtils.save(item);
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- item = publicInquiryItemDao.findOne(idid);
|
|
|
- //回复清单更新
|
|
|
- if(replies.size() > 0) {
|
|
|
- for (PublicInquiryReply reply1 : replies) {
|
|
|
- commonDao.getJdbcTemplate().update("update public$inquiryreply set ir_idid = " + idid + "where ir_id = " + reply1.getId());
|
|
|
- }
|
|
|
- }
|
|
|
+// try {
|
|
|
+// commonDao.getJdbcTemplate().update(
|
|
|
+// "insert into public$inquiryitems(id_id,id_number,id_currency,id_fromdate,id_todate,id_taxrate,id_prid,id_venduu,"
|
|
|
+// + "id_venduseruu,id_sourceapp,id_status,id_custlap,id_sendstatus,id_sourceid,id_inid,id_kind) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
|
|
+// idid, item.getNumber(), item.getCurrency(), item.getFromDate(), item.getToDate(),
|
|
|
+// item.getTaxrate(), item.getProductId(), item.getVendUU(), item.getVendUserUU(),
|
|
|
+// item.getSourceApp(), item.getStatus(), item.getCustLap(), item.getSendStatus(),
|
|
|
+// item.getSourceId(), inquiry.getId(), inquiry.getKind());
|
|
|
+// } catch (DataAccessException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// item = publicInquiryItemDao.findOne(idid);
|
|
|
+// //回复清单更新
|
|
|
+// if(replies.size() > 0) {
|
|
|
+// for (PublicInquiryReply reply1 : replies) {
|
|
|
+// commonDao.getJdbcTemplate().update("update public$inquiryreply set ir_idid = " + idid + "where ir_id = " + reply1.getId());
|
|
|
+// }
|
|
|
+// }
|
|
|
if (item != null) {
|
|
|
map.put("success", "转客户询价单成功");
|
|
|
map.put("id", item.getInquiry().getId());
|
|
|
@@ -471,12 +490,12 @@ public class PubInquiryServiceImpl implements PubInquiryService {
|
|
|
inquiryInfo.setInvoice(inquiry.getInvoice());
|
|
|
inquiryInfo.setInquirytype(inquiry.getInquirytype());
|
|
|
Set<Long> ids = new HashSet<Long>();
|
|
|
- List<Long> idStrings = new ArrayList<>();
|
|
|
+ List<Long> idList = new ArrayList<>();
|
|
|
Set<InquiryProductInfo> products = new HashSet<InquiryProductInfo>();
|
|
|
if (!CollectionUtils.isEmpty(inquiry.getInquiryItems())) {
|
|
|
for (PublicInquiryItemInfo item : inquiry.getInquiryItems()) {
|
|
|
- idStrings.add(item.getProductId());
|
|
|
- ids.addAll(idStrings);
|
|
|
+ idList.add(item.getProductId());
|
|
|
+ ids.addAll(idList);
|
|
|
}
|
|
|
}
|
|
|
if (!CollectionUtils.isEmpty(ids)) {
|
|
|
@@ -511,12 +530,13 @@ public class PubInquiryServiceImpl implements PubInquiryService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public ModelMap acceptInquiry(Long id) {
|
|
|
+ public ModelMap acceptInquiry(Long id) throws Exception {
|
|
|
ModelMap map = new ModelMap();
|
|
|
PublicInquiryItem item = publicInquiryItemDao.findOne(id);
|
|
|
item.setAgreed(Constant.YES);
|
|
|
item.setStatus((short) Status.REPLIED.value());
|
|
|
- item = publicInquiryItemDao.save(item);
|
|
|
+// item = publicInquiryItemDao.save(item);
|
|
|
+ item = InquiryUtils.saveItem(item);
|
|
|
if (item.getAgreed().equals(Constant.YES) && item.getStatus().equals((short) Status.REPLIED.value())) {
|
|
|
map.put("success", "采纳成功");
|
|
|
} else {
|
|
|
@@ -532,12 +552,13 @@ public class PubInquiryServiceImpl implements PubInquiryService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public ModelMap refuseInquiry(Long id) {
|
|
|
+ public ModelMap refuseInquiry(Long id) throws Exception {
|
|
|
ModelMap map = new ModelMap();
|
|
|
PublicInquiryItem item = publicInquiryItemDao.findOne(id);
|
|
|
item.setAgreed(Constant.NO);
|
|
|
item.setStatus((short) Status.REPLIED.value());
|
|
|
- item = publicInquiryItemDao.save(item);
|
|
|
+// item = publicInquiryItemDao.save(item);
|
|
|
+ item = InquiryUtils.saveItem(item);
|
|
|
if (item.getAgreed().equals(Constant.NO) && item.getStatus().equals((short) Status.REPLIED.value())) {
|
|
|
map.put("success", "拒绝操作成功");
|
|
|
} else {
|
|
|
@@ -565,7 +586,8 @@ public class PubInquiryServiceImpl implements PubInquiryService {
|
|
|
if (attach == null) {
|
|
|
throw new Exception("文件太大");
|
|
|
}
|
|
|
- attach = attachDao.save(attach);
|
|
|
+// attach = attachDao.save(attach);
|
|
|
+ attach = InquiryUtils.addAttachs(attach);
|
|
|
// 避免出现无附件的情况
|
|
|
Set<Attach> attachSet = item.getAttaches() != null ? item.getAttaches() : new HashSet<Attach>();
|
|
|
attachSet.add(attach);
|
|
|
@@ -573,7 +595,8 @@ public class PubInquiryServiceImpl implements PubInquiryService {
|
|
|
item = reply(item);
|
|
|
}
|
|
|
item.setAttaches(attachSet);
|
|
|
- item = publicInquiryItemDao.save(item);
|
|
|
+// item = publicInquiryItemDao.save(item);
|
|
|
+ item = InquiryUtils.saveItem(item);
|
|
|
map.put("success", true);
|
|
|
map.put("item", item);
|
|
|
return map;
|