Эх сурвалжийг харах

Merge branch 'dev' of ssh://10.10.101.21/source/platform-b2b into login-excel

wangmh 8 жил өмнө
parent
commit
85afdb6503
55 өөрчлөгдсөн 1023 нэмэгдсэн , 204 устгасан
  1. 5 6
      src/main/java/com/uas/platform/b2b/controller/BaseInfoController.java
  2. 0 1
      src/main/java/com/uas/platform/b2b/controller/PublicQueryController.java
  3. 1 1
      src/main/java/com/uas/platform/b2b/controller/PurcProductController.java
  4. 21 0
      src/main/java/com/uas/platform/b2b/controller/SaleOrderChangeController.java
  5. 5 4
      src/main/java/com/uas/platform/b2b/controller/SaleOrderController.java
  6. 15 3
      src/main/java/com/uas/platform/b2b/dao/NoticeDao.java
  7. 10 0
      src/main/java/com/uas/platform/b2b/dao/PurchaseInquiryItemDao.java
  8. 7 4
      src/main/java/com/uas/platform/b2b/dao/PurchaseOrderItemDao.java
  9. 36 10
      src/main/java/com/uas/platform/b2b/erp/controller/InquiryController.java
  10. 2 2
      src/main/java/com/uas/platform/b2b/erp/controller/VendorRateController.java
  11. 17 7
      src/main/java/com/uas/platform/b2b/erp/model/AcceptNotify.java
  12. 6 0
      src/main/java/com/uas/platform/b2b/erp/service/InquiryService.java
  13. 62 4
      src/main/java/com/uas/platform/b2b/erp/service/impl/InquiryServiceImpl.java
  14. 77 29
      src/main/java/com/uas/platform/b2b/erp/service/impl/PublicInquiryServiceImpl.java
  15. 30 6
      src/main/java/com/uas/platform/b2b/erp/service/impl/VendorServiceImpl.java
  16. 2 1
      src/main/java/com/uas/platform/b2b/event/MakeOrderSaveReleaseEvent.java
  17. 4 1
      src/main/java/com/uas/platform/b2b/event/PurchaseInquiryMouldInvalidReleaseEvent.java
  18. 2 1
      src/main/java/com/uas/platform/b2b/event/PurchaseInquiryMouldReplyReleaseEvent.java
  19. 2 0
      src/main/java/com/uas/platform/b2b/event/PurchaseInquiryMouldSaveReleaseEvent.java
  20. 4 1
      src/main/java/com/uas/platform/b2b/event/PurchaseNoticeEndReleaseEvent.java
  21. 4 1
      src/main/java/com/uas/platform/b2b/event/PurchaseOrderEndReleaseEvent.java
  22. 4 1
      src/main/java/com/uas/platform/b2b/event/PurchaseOrderSaveReleaseEvent.java
  23. 2 0
      src/main/java/com/uas/platform/b2b/event/PurchaseProofingItemSaveReleaseEvent.java
  24. 4 1
      src/main/java/com/uas/platform/b2b/event/SaleSendAcceptReleaseEvent.java
  25. 4 1
      src/main/java/com/uas/platform/b2b/event/SaleSendRefuseReleaseEvent.java
  26. 1 1
      src/main/java/com/uas/platform/b2b/filter/SSOInterceptor.java
  27. 8 11
      src/main/java/com/uas/platform/b2b/listener/MessageListener.java
  28. 22 2
      src/main/java/com/uas/platform/b2b/model/PurchaseInquiryItem.java
  29. 1 0
      src/main/java/com/uas/platform/b2b/service/PurchaseInquiryService.java
  30. 1 0
      src/main/java/com/uas/platform/b2b/service/PurchaseOrderService.java
  31. 18 14
      src/main/java/com/uas/platform/b2b/service/impl/AttachServiceImpl.java
  32. 0 1
      src/main/java/com/uas/platform/b2b/service/impl/BrandServiceImpl.java
  33. 4 1
      src/main/java/com/uas/platform/b2b/service/impl/ComponentServiceImpl.java
  34. 12 4
      src/main/java/com/uas/platform/b2b/service/impl/DeputyOrderServiceImpl.java
  35. 3 0
      src/main/java/com/uas/platform/b2b/service/impl/PurchaseAcceptServiceImpl.java
  36. 1 1
      src/main/java/com/uas/platform/b2b/service/impl/PurchaseApBillServiceImpl.java
  37. 100 33
      src/main/java/com/uas/platform/b2b/service/impl/PurchaseInquiryServiceImpl.java
  38. 5 0
      src/main/java/com/uas/platform/b2b/service/impl/PurchaseOrderServiceImpl.java
  39. 0 1
      src/main/java/com/uas/platform/b2b/service/impl/RoleServiceImpl.java
  40. 0 1
      src/main/java/com/uas/platform/b2b/service/impl/VendorsServiceImpl.java
  41. 360 0
      src/main/java/com/uas/platform/b2b/support/HttpUtils.java
  42. 32 2
      src/main/java/com/uas/platform/b2b/support/MessageConf.java
  43. 35 0
      src/main/java/com/uas/platform/b2b/temporary/model/FileUrl.java
  44. 14 1
      src/main/java/com/uas/platform/b2b/temporary/model/UserInfo.java
  45. 19 20
      src/main/java/com/uas/platform/b2b/v2/controller/EnterpriseController.java
  46. 3 1
      src/main/resources/dev/message.properties
  47. 3 1
      src/main/resources/prod/message.properties
  48. 3 1
      src/main/resources/test/message.properties
  49. 11 4
      src/main/webapp/resources/js/common/services.js
  50. 27 12
      src/main/webapp/resources/js/index/app.js
  51. 2 2
      src/main/webapp/resources/tpl/index/fa/apcheck_customer.html
  52. 9 0
      src/main/webapp/resources/tpl/index/make/order.html
  53. 2 1
      src/main/webapp/resources/tpl/index/purc/deputyOrder.html
  54. 0 3
      src/main/webapp/resources/tpl/index/sale/inquiry_mould.html
  55. 1 1
      src/main/webapp/resources/tpl/index/sale/order.html

+ 5 - 6
src/main/java/com/uas/platform/b2b/controller/BaseInfoController.java

@@ -9,10 +9,7 @@ import com.uas.platform.b2b.model.Vendor;
 import com.uas.platform.b2b.search.SearchService;
 import com.uas.platform.b2b.service.BaseInfoService;
 import com.uas.platform.b2b.service.ProductService;
-import com.uas.platform.b2b.support.JxlsExcelView;
-import com.uas.platform.b2b.support.SystemSession;
-import com.uas.platform.b2b.support.TokenService;
-import com.uas.platform.b2b.support.UsageBufferedLogger;
+import com.uas.platform.b2b.support.*;
 import com.uas.platform.b2b.temporary.model.BasePartnersInfo;
 import com.uas.platform.b2b.temporary.model.NewPurcOrder;
 import com.uas.platform.b2b.temporary.model.ProdInfo;
@@ -45,8 +42,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
-import static org.springframework.data.jpa.domain.AbstractPersistable_.id;
-
 /**
  * 基础资料设置<br>
  * 物料查看、物料资料上传
@@ -71,6 +66,9 @@ public class BaseInfoController {
 	@Autowired
 	private TokenService tokenService;
 
+	@Autowired
+	private SysConf sysConf;
+
 	/**
 	 * 查看自己的物料资料
 	 */
@@ -289,6 +287,7 @@ public class BaseInfoController {
 	 */
 	@RequestMapping(value = "/xls/permission", method = RequestMethod.GET)
 	public ModelMap exportPermission() {
+		sysConf.getB2b();
 		return new ModelMap("success", true);
 	}
 

+ 0 - 1
src/main/java/com/uas/platform/b2b/controller/PublicQueryController.java

@@ -84,7 +84,6 @@ public class PublicQueryController {
 			if (enterprise != null)
 				returnMap.put("uu", new QueriableMember(enterprise));
 		}
-		System.out.println(JSON.toJSON(returnMap));
 		return returnMap;
 	}
 

+ 1 - 1
src/main/java/com/uas/platform/b2b/controller/PurcProductController.java

@@ -370,7 +370,7 @@ public class PurcProductController {
 	 */
 	@RequestMapping(value = "/edit/delete", method = RequestMethod.POST)
 	@ResponseBody
-	public ModelMap deleteById(Long id) throws Exception {
+	public ModelMap deleteById(@RequestBody Long id) throws Exception {
 		ModelMap map = new ModelMap();
 		try {
 			baseInfoService.deleteById(id);

+ 21 - 0
src/main/java/com/uas/platform/b2b/controller/SaleOrderChangeController.java

@@ -419,6 +419,27 @@ public class SaleOrderChangeController {
 		return modelAndView;
 	}
 
+
+	/**
+	 * 导出 - 无需确认
+	 *
+	 * @param searchFilter
+	 * @return
+	 */
+	@RequestMapping(value = "/xls", params = RequestState.UNREAD, method = RequestMethod.GET)
+	public ModelAndView exportUnreadChanges(PageParams params, String searchFilter) {
+		params.setPage(1);
+		params.setCount(SearchConstants.TOP_NUM);
+		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日");
+		ModelAndView modelAndView = new ModelAndView();
+		modelAndView.addObject("dateFormat", dateFormat);
+		modelAndView.addObject("state", "无需确认");
+		modelAndView.addObject("data",getUnReadPurchaseOrderChanges(params, searchFilter).getContent());
+		modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/sale/saleChange", "客户采购变更单列表_无需确认"));
+		logger.log("客户采购变更单", "导出Excel列表", "导出无需确认Excel列表");
+		return modelAndView;
+	}
+
 	/**
 	 * 设置单据已读
 	 * @author wangmh

+ 5 - 4
src/main/java/com/uas/platform/b2b/controller/SaleOrderController.java

@@ -669,10 +669,11 @@ public class SaleOrderController {
 	 */
 	@RequestMapping(value = "/items/reply", method = RequestMethod.POST)
 	public ResponseEntity<String> replyOrderItems(@RequestBody String idString) {
-		List<PurchaseOrderReply> replies = purchaseOrderService.reply(idString.split(","));
-		for (PurchaseOrderReply reply : replies)
-			logger.log("客户采购单", "批量回复客户采购明细", reply.replyDescription(), reply.getOrderItem().getOrder().getCode(),
-					reply.getOrderItem().getId());
+//		List<PurchaseOrderReply> replies = purchaseOrderService.reply(idString.split(","));
+//		for (PurchaseOrderReply reply : replies)
+//			logger.log("客户采购单", "批量回复客户采购明细", reply.replyDescription(), reply.getOrderItem().getOrder().getCode(),
+//					reply.getOrderItem().getId());
+        purchaseOrderService.replyByBatch(idString, SystemSession.getUser().getUserName(), SystemSession.getUser().getIp(), SystemSession.getUser().getEnterprise().getUu(), SystemSession.getUser().getUserUU());
 		return new ResponseEntity<String>(HttpStatus.OK);
 	}
 

+ 15 - 3
src/main/java/com/uas/platform/b2b/dao/NoticeDao.java

@@ -1,21 +1,33 @@
 package com.uas.platform.b2b.dao;
 
-import javax.persistence.QueryHint;
-
+import com.uas.platform.b2b.model.Notice;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.QueryHints;
+import org.springframework.data.jpa.repository.query.Procedure;
 import org.springframework.stereotype.Repository;
 
-import com.uas.platform.b2b.model.Notice;
+import javax.persistence.QueryHint;
 
 @Repository
 public interface NoticeDao extends JpaSpecificationExecutor<Notice>, JpaRepository<Notice, Long> {
 
 	@QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value = "true") })
 	Page<Notice> findAll(Specification<Notice> spec, Pageable pageable);
+
+	/**
+	 * 在log$erp表中加入日志
+	 * @param username
+	 * @param userip
+	 * @param enuu
+	 * @param useruu
+	 * @param title
+	 * @param message
+	 */
+	@Procedure(procedureName = "PURC$ERP_SEND_EMAIL")
+	void saveErpLog(String username,String userip, Long enuu, Long useruu, String title, String message);
 	
 }

+ 10 - 0
src/main/java/com/uas/platform/b2b/dao/PurchaseInquiryItemDao.java

@@ -9,6 +9,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.jpa.repository.query.Procedure;
 import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
 
@@ -192,4 +193,13 @@ public interface PurchaseInquiryItemDao extends JpaSpecificationExecutor<Purchas
 	 */
 	@Query("select count(p) from PurchaseInquiryItem p where p.id in :ids and p.inquiry.overdue=0 and (p.inquiry.check is null or p.inquiry.check <> 1) and p.status=200")
 	Integer getNotOfferCount(@Param("ids") List<Long> ids);
+
+    /**
+     * 更新询价报价传输到erp的状态
+     *
+     * @param enuu
+     * @param status
+     */
+	@Procedure(procedureName = "inquiryitem_erpstatus_update")
+    void updateStatus(Long enuu, Short status);
 }

+ 7 - 4
src/main/java/com/uas/platform/b2b/dao/PurchaseOrderItemDao.java

@@ -1,17 +1,17 @@
 package com.uas.platform.b2b.dao;
 
-import java.util.Date;
-import java.util.List;
-
+import com.uas.platform.b2b.model.PurchaseOrderItem;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.jpa.repository.query.Procedure;
 import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
 import org.springframework.transaction.annotation.Transactional;
 
-import com.uas.platform.b2b.model.PurchaseOrderItem;
+import java.util.Date;
+import java.util.List;
 
 @Repository
 @Transactional
@@ -77,4 +77,7 @@ public interface PurchaseOrderItemDao extends JpaSpecificationExecutor<PurchaseO
 	@Modifying(clearAutomatically = true)
 	@Query("update PurchaseOrderItem p set p.replyQty=(select sum(r.qty) from PurchaseOrderReply r where r.orderItem=p),p.replyDelivery= :delivery,p.replyRemark= :remark where p.id= :id")
 	public void updateByReply(@Param("delivery") Date delivery, @Param("remark") String remark, @Param("id") long id);
+
+    @Procedure(procedureName = "purc$reply_batch")
+    public void replyByBatch(String idString, String username, String userip, Long enuu, Long useruu);
 }

+ 36 - 10
src/main/java/com/uas/platform/b2b/erp/controller/InquiryController.java

@@ -1,6 +1,7 @@
 
 package com.uas.platform.b2b.erp.controller;
 
+import com.alibaba.fastjson.JSON;
 import com.uas.platform.b2b.erp.model.Inquiry;
 import com.uas.platform.b2b.erp.model.InquiryDecide;
 import com.uas.platform.b2b.erp.model.InquiryDetail;
@@ -15,10 +16,7 @@ import com.uas.platform.core.util.ArrayUtils;
 import com.uas.platform.core.util.serializer.FlexJsonUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
@@ -47,22 +45,37 @@ public class InquiryController {
 
 	private final static ErpBufferedLogger logger = BufferedLoggerManager.getLogger(ErpBufferedLogger.class);
 
+    /**
+     * 将买家ERP的采购询价写到平台
+     *
+     * @param data
+     * @return
+     * @throws UnsupportedEncodingException
+     */
+    @RequestMapping(method = RequestMethod.POST)
+    @ResponseBody
+    public void saveInquiries(@RequestParam("data") String data) throws UnsupportedEncodingException {
+        String jsonStr = URLDecoder.decode(data, "UTF-8");
+        List<Inquiry> inquiries = FlexJsonUtils.fromJsonArray(jsonStr, Inquiry.class);
+        purchaseInquiryService.save(inquiryService.convertInquiry(inquiries));
+        logger.log("询价单", "上传询价单", inquiries.size());
+    }
+
 	/**
-	 * 将买家ERP的采购询价写到平台
+	 * 将买家ERP的采购询价写到平台(新方法)
 	 * 
 	 * @param data
 	 * @return
 	 * @throws UnsupportedEncodingException
 	 */
-	@RequestMapping(method = RequestMethod.POST)
+	@RequestMapping(value = "/v2", method = RequestMethod.POST)
 	@ResponseBody
-	public void saveInquiries(@RequestParam("data") String data) throws UnsupportedEncodingException {
-		String jsonStr = URLDecoder.decode(data, "UTF-8");
-		List<Inquiry> inquiries = FlexJsonUtils.fromJsonArray(jsonStr, Inquiry.class);
-		purchaseInquiryService.save(inquiryService.convertInquiry(inquiries));
+	public void saveInquiries(@RequestBody List<Inquiry> inquiries) {
+        purchaseInquiryService.save(inquiryService.convertInquiry(inquiries));
 		logger.log("询价单", "上传询价单", inquiries.size());
 	}
 
+
 	/**
 	 * 买家在收到报价信息后,点击提交按钮后,状态传至平台,至此平台的供应商不能再对这张询价单进行报价
 	 * 
@@ -157,4 +170,17 @@ public class InquiryController {
 		logger.log("询价单", "询价单附件上传", attachs.size());
 	}
 
+    /**
+     * 买家上传自动询价单明细,因为存在客户后来才注册平台的情况(重新上传)
+     *
+     * @param data
+     * @throws UnsupportedEncodingException
+     */
+	@RequestMapping(value = "/qutoInquiry", method = RequestMethod.POST)
+    @ResponseBody
+    public void uploadQutoInquiry(@RequestParam("data") String data) throws UnsupportedEncodingException {
+        String jsonStr = URLDecoder.decode(data, "UTF-8");
+        List<InquiryDetail> details = FlexJsonUtils.fromJsonArray(jsonStr, InquiryDetail.class);
+        inquiryService.save(details);
+    }
 }

+ 2 - 2
src/main/java/com/uas/platform/b2b/erp/controller/VendorRateController.java

@@ -124,7 +124,7 @@ public class VendorRateController {
 	 */
 	@RequestMapping(value = "/check", method = RequestMethod.POST)
 	@ResponseBody
-	public void checkSuccess(@RequestParam("data") String data) {
-		vendorService.updateStatus(data);
+	public void checkSuccess(@RequestParam("data") String data) throws UnsupportedEncodingException {
+		vendorService.updateStatus(URLDecoder.decode(data, "UTF-8"));
 	}
 }

+ 17 - 7
src/main/java/com/uas/platform/b2b/erp/model/AcceptNotify.java

@@ -1,16 +1,12 @@
 package com.uas.platform.b2b.erp.model;
 
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.collections.CollectionUtils;
-
 import com.uas.platform.b2b.model.SaleSend;
 import com.uas.platform.b2b.model.SaleSendItem;
 import com.uas.platform.b2b.support.SystemSession;
 import com.uas.platform.core.model.Status;
+import org.apache.commons.collections.CollectionUtils;
+
+import java.util.*;
 
 /**
  * 买家ERP的收料通知单
@@ -26,6 +22,7 @@ public class AcceptNotify {
 	private String an_remark;
 	private String an_sendcode;
 	private String an_recorder;
+	private Date an_date;
 	private List<AcceptNotifyDetail> details;
 
 	public Long getB2b_ss_id() {
@@ -60,6 +57,18 @@ public class AcceptNotify {
 		this.an_rate = an_rate;
 	}
 
+	public void setAn_venduu(long an_venduu) {
+		this.an_venduu = an_venduu;
+	}
+
+	public Date getAn_date() {
+		return an_date;
+	}
+
+	public void setAn_date(Date an_date) {
+		this.an_date = an_date;
+	}
+
 	public String getAn_payment() {
 		return an_payment;
 	}
@@ -127,6 +136,7 @@ public class AcceptNotify {
 		this.an_venduu = send.getEnUU();
 		this.an_sendcode = send.getCode();
 		this.an_recorder = send.getRecorder();
+		this.an_date = send.getDate();
 		this.details = new ArrayList<AcceptNotifyDetail>();
 		if (!CollectionUtils.isEmpty(send.getSendItems())) {
 			for (SaleSendItem item : send.getSendItems()) {

+ 6 - 0
src/main/java/com/uas/platform/b2b/erp/service/InquiryService.java

@@ -51,4 +51,10 @@ public interface InquiryService {
 	 */
 	List<SaleQuotationItem> convertQuotationDecide(List<InquiryDecide> decides);
 
+    /**
+     * 保存自动询价单明细
+     *
+     * @param details
+     */
+    void save(List<InquiryDetail> details);
 }

+ 62 - 4
src/main/java/com/uas/platform/b2b/erp/service/impl/InquiryServiceImpl.java

@@ -1,23 +1,27 @@
 package com.uas.platform.b2b.erp.service.impl;
 
 import com.uas.account.util.AccountUtils;
+import com.uas.platform.b2b.core.util.ContextUtils;
 import com.uas.platform.b2b.dao.*;
 import com.uas.platform.b2b.erp.model.Inquiry;
 import com.uas.platform.b2b.erp.model.InquiryDecide;
 import com.uas.platform.b2b.erp.model.InquiryDetail;
+import com.uas.platform.b2b.erp.model.InquiryDetailDet;
 import com.uas.platform.b2b.erp.service.InquiryService;
+import com.uas.platform.b2b.erp.support.ErpBufferedLogger;
+import com.uas.platform.b2b.event.PurchaseInquiryItemSaveReleaseEvent;
 import com.uas.platform.b2b.model.*;
 import com.uas.platform.b2b.support.SystemSession;
 import com.uas.platform.b2b.temporary.model.PartnershipRecord;
+import com.uas.platform.core.logging.BufferedLoggerManager;
 import com.uas.platform.core.model.Constant;
 import com.uas.platform.core.model.Status;
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 @Service
 public class InquiryServiceImpl implements InquiryService {
@@ -43,6 +47,11 @@ public class InquiryServiceImpl implements InquiryService {
 	@Autowired
 	private UserDao userDao;
 
+	@Autowired
+    private CommonDao commonDao;
+
+    private final static ErpBufferedLogger logger = BufferedLoggerManager.getLogger(ErpBufferedLogger.class);
+
 	@Override
 	public List<PurchaseInquiryItem> convertInquiry(List<Inquiry> inquiries) {
 		List<PurchaseInquiryItem> inquiryItems = new ArrayList<PurchaseInquiryItem>();
@@ -178,7 +187,8 @@ public class InquiryServiceImpl implements InquiryService {
 		return quotationItems;
 	}
 
-	/**
+
+    /**
 	 * 添加供应商资料
 	 * 
 	 * @param inquiryItem
@@ -216,4 +226,52 @@ public class InquiryServiceImpl implements InquiryService {
 		return null;
 	}
 
+    @Override
+    public void save(List<InquiryDetail> details) {
+        if(!CollectionUtils.isEmpty(details)) {
+        	Set<String> codes = new HashSet<>();
+        	List<PurchaseInquiryItem> items = new ArrayList<>();
+            for(InquiryDetail detail : details) {
+                //先查询已经上传的询价单主表信息
+                Inquiry inquiry = getInquiry(detail.getIn_code(), detail.getId_id());
+                if(null != inquiry) {
+                    List<InquiryDetail> inquiryDetails = commonDao.query("select * from purc$inquiryitems where id_inid = " + inquiry.getIn_id() + " and id_sourceid = " + detail.getId_id(), InquiryDetail.class);
+                    if(inquiryDetails.size() == 0) {
+                        //查询对应平台的物料信息
+                        List<Product> products = productDao.findByEnUUAndCode(SystemSession.getUser().getEnterprise().getUu(), detail.getId_prodcode());
+                        if(products.size() > 0) {
+                            Long prodId = products.get(0).getId();
+                            Long id = commonDao.getJdbcTemplate().queryForLong("select purc$inquiryitems_seq.nextval from dual");
+                            String sql = "insert into purc$inquiryitems(id_id,id_sourceid,id_number,id_inid,id_useruu,id_prid,id_currency,id_taxrate,id_remark,id_venduu,id_venduseruu,id_fromdate,id_todate,id_status,id_sendstatus,id_erpdate,id_date,id_sourceapp) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+                            commonDao.getJdbcTemplate().update(sql, id,detail.getId_id(), detail.getId_detno(), inquiry.getIn_id(), SystemSession.getUser().getUserUU(), prodId, detail.getId_currency(), detail.getId_rate(), detail.getId_remark(), detail.getVe_uu(), detail.getVe_contactuu(), detail.getId_fromdate(), detail.getId_todate(), Status.NOT_REPLY.value(), Status.NOT_UPLOAD.value(), new Date(), inquiry.getIn_date(), "erp");
+                            //插入分段信息
+                            if(detail.getDets().size() > 0) {
+                                for(InquiryDetailDet det : detail.getDets()) {
+                                    sql = "insert into purc$inquiryreply (ir_id,ir_lapqty,ir_idid) VALUES (purc$inquiryreply_seq.nextval, ?, ?)";
+                                    commonDao.getJdbcTemplate().update(sql, det.getIdd_lapqty() == null ? 0 :  det.getIdd_lapqty(), id);
+                                }
+                            }
+                            logger.log("自动询价明细上传", "新增了自动询价的明细(" + id + ")", 1);
+                        }
+						// 产生消息
+						PurchaseInquiryItem inquiryItem = purchaseInquiryItemDao.findByVendUUAndSourceId(detail.getVe_uu(), detail.getId_id());
+						if (null != inquiryItem && null != inquiryItem.getInquiry() && !codes.contains(inquiryItem.getInquiry().getCode() + inquiryItem.getVendUU())) {
+							// 可能存在一个单里两个企业都是注册了之后,同时传输明细的情况,所以需要enuu 和code 一起判断
+							codes.add(inquiryItem.getInquiry().getCode() + inquiryItem.getVendUU());
+							items.add(inquiryItem);
+						}
+                    }
+                }
+            }
+            if (!CollectionUtils.isEmpty(items)) {
+				ContextUtils.publishEvent(new PurchaseInquiryItemSaveReleaseEvent(items));
+			}
+        }
+    }
+
+    private Inquiry getInquiry(String in_code, Long id) {
+	    String sql = "select in_id, in_date from purc$inquiry left join purc$inquiryitems on id_inid = in_id where in_code = '" + in_code + "' and in_enuu = " + SystemSession.getUser().getEnterprise().getUu() + " and purc$inquiryitems.id_sourceid <> " + id;
+        List<Inquiry> inquiries = commonDao.getJdbcTemplate().query(sql, new BeanPropertyRowMapper<Inquiry>(Inquiry.class));
+        return inquiries.size() > 0 ? inquiries.get(0) : null;
+    }
 }

+ 77 - 29
src/main/java/com/uas/platform/b2b/erp/service/impl/PublicInquiryServiceImpl.java

@@ -1,5 +1,6 @@
 package com.uas.platform.b2b.erp.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.uas.message.mail.service.MailService;
 import com.uas.platform.b2b.core.util.ContextUtils;
 import com.uas.platform.b2b.core.util.DateFormatUtils;
@@ -10,12 +11,12 @@ import com.uas.platform.b2b.erp.model.BatchInquiry;
 import com.uas.platform.b2b.erp.service.PublicInquiryService;
 import com.uas.platform.b2b.erp.support.ErpBufferedLogger;
 import com.uas.platform.b2b.event.PurcInquirySaveReleaseEvent;
-import com.uas.platform.b2b.model.Product;
-import com.uas.platform.b2b.model.PurcInquiry;
-import com.uas.platform.b2b.model.PurcInquiryItem;
+import com.uas.platform.b2b.model.*;
 import com.uas.platform.b2b.support.MessageConf;
 import com.uas.platform.b2b.support.SystemSession;
+import com.uas.platform.b2b.support.UsageBufferedLogger;
 import com.uas.platform.b2b.temporary.model.SmsMessage;
+import com.uas.platform.b2b.temporary.model.UserInfo;
 import com.uas.platform.core.logging.BufferedLoggerManager;
 import com.uas.platform.core.model.Constant;
 import com.uas.platform.core.model.Status;
@@ -59,8 +60,18 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
     @Autowired
     private MessageConf messageConf;
 
+    @Autowired
+    private NoticeDao noticeDao;
+
+    @Autowired
+    private UserDao userDao;
+
     private final static ErpBufferedLogger logger = BufferedLoggerManager.getLogger(ErpBufferedLogger.class);
 
+    private final static UsageBufferedLogger usageLogger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
+
+    private static final String TEL_REGEXP = "^((\\(\\d{3}\\))|(\\d{3}\\-))?(13|15|18|17)\\d{9}$";
+
     @Override
     public List<PurcInquiry> convertInquiry(List<BatchInquiry> inquiries) {
         Long enuu = SystemSession.getUser().getEnterprise().getUu();
@@ -128,7 +139,11 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
             // 产生消息
             sendMessage(inquiryItems);
             // 发送通知
-            sendRemind(inquiries);
+            Long userUU = SystemSession.getUser().getUserUU();
+            Long enUU = SystemSession.getUser().getEnterprise().getUu();
+            String userIp = SystemSession.getUser().getIp();
+            String userName = SystemSession.getUser().getUserName();
+            sendRemind(inquiries, userUU, userName, userIp, enUU);
         }
     }
 
@@ -160,9 +175,12 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
      * 发送通知
      *
      * @param inquiries 采购询价单主表
-     * @return
+     * @param userUU
+     *@param userName
+     * @param userIp
+     * @param enUU @return
      */
-    private void sendRemind(final List<PurcInquiry> inquiries){
+    private void sendRemind(final List<PurcInquiry> inquiries, final Long userUU, final String userName, final String userIp, final Long enUU){
         ThreadTask.getInstance().execute(new Runnable() {
             @Override
             public void run() {
@@ -175,44 +193,74 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
                     obj.add(inquiry.getEnterprise().getEnName());
                     sms.setParams(obj);
                     for (PurcInquiryItem inquiryItem : inquiry.getInquiryItems()) {
-                        if (!enUUs.contains(inquiryItem.getVendUU())) {
+                        if (null != inquiryItem.getVendUU() && !enUUs.contains(inquiryItem.getVendUU())) {
                             // 查找业务员邮箱
-                            String userEmailSql = "select distinct us.user_email useremail from sec$users us " +
+                            String userEmailSql = "select distinct us.user_email ememail from sec$users us " +
                                     " left join sec$userrole ur on us.user_uu = ur.user_uu left join sec$roles sr " +
                                     " on ur.role_id = sr.role_id where sr.role_desc = '业务员' and us.user_email is not null " +
-                                    " and sr.role_enuu = " + inquiryItem.getVendUU();
-                            List<String> userEmails = commonDao.query(userEmailSql, String.class);
-                            String userTelSql = "select distinct us.user_email useremail from sec$users us " +
+                                    " and sr.role_enuu = " + inquiryItem.getVendUU() + " and us.user_uu in (" +
+                                    "select pd_useruu from purc$distribute where pd_vdid = (" +
+                                    "select ve_id from purc$vendors where ve_myenuu = " + inquiry.getEnUU() + " and ve_vendenuu = " + inquiryItem.getVendUU() + "))";
+                            List<UserInfo> userEmails = commonDao.query(userEmailSql, UserInfo.class);
+                            String userTelSql = "select distinct us.user_tel emphone from sec$users us " +
                                     " left join sec$userrole ur on us.user_uu = ur.user_uu left join sec$roles sr " +
-                                    " on ur.role_id = sr.role_id where sr.role_desc = '业务员' and us.user_email is not null " +
-                                    " and sr.role_enuu = " + inquiryItem.getVendUU();
-                            List<String> userTels = commonDao.query(userTelSql, String.class);
+                                    " on ur.role_id = sr.role_id where sr.role_desc = '业务员' and us.user_tel is not null " +
+                                    " and sr.role_enuu = " + inquiryItem.getVendUU() + " and us.user_uu in (" +
+                                    "select pd_useruu from purc$distribute where pd_vdid = (" +
+                                    "select ve_id from purc$vendors where ve_myenuu = " + inquiry.getEnUU() + " and ve_vendenuu = " + inquiryItem.getVendUU() + "))";
+                            List<UserInfo> userTels = commonDao.query(userTelSql, UserInfo.class);
                             // 发邮件
                             Map<String, Object> model = new HashMap<String, Object>();
-                            model.put("vendorname", inquiryItem.getEnterprise().getEnName());
+                            Enterprise vendor = enterpriseDao.findOne(inquiryItem.getVendUU());
+                            if (null != vendor) {
+                                model.put("vendorname", vendor.getEnName());
+                            } else {
+                                model.put("vendorname", "供应商");
+                            }
                             model.put("custname", inquiry.getEnterprise().getEnName());
                             model.put("date", DateFormatUtils.DATE_FORMAT.format(new Date()));
-                            for (String userEmail : userEmails) {
-                                String emailRegex = "[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?";
-                                if (Pattern.matches(emailRegex, userEmail)) {
+                            // 不存在被分配客户的业务员则添加系统管理员
+                            if (CollectionUtils.isEmpty(userEmails) && CollectionUtils.isEmpty(userTels)) {
+                                Enterprise enterprise = enterpriseDao.findOne(inquiryItem.getVendUU());
+                                if (null != enterprise) {
+                                    User admin = userDao.findOne(enterprise.getEnAdminuu());
+                                    if (null != admin) {
+                                        UserInfo adminInfo = new UserInfo(admin);
+                                        userEmails.add(adminInfo);
+                                        userTels.add(adminInfo);
+                                    }
+                                }
+                            }
+                            for (UserInfo userEmail : userEmails) {
+                                String emailRegex = "\\w[-\\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\\.)+[A-Za-z]{2,14}";
+                                if (Pattern.matches(emailRegex, userEmail.getEmemail())) {
                                     try {
-                                        mailService.send(messageConf.getTplInquiryForB2B(), userEmail, model);
+                                        mailService.send(messageConf.getTplInquiryForB2B(), userEmail.getEmemail(), model);
+                                        // 线程内无法访问Systemsession,会报nullPoint,采用存储过程
+//										usageLogger.log("询价发送邮件", "企业UU:" + inquiry.getEnUU() + ",单号:" +inquiry.getCode() +" 发送邮件成功", "询价发送邮件成功");
+                                        noticeDao.saveErpLog(userName, userIp, enUU, userUU, "发送询价单通知邮件", "发送成功,询价单号" + inquiry.getCode());
                                     } catch (Exception e) {
-                                        logger.log("公共询价发送邮件出错", inquiry.getEnUU() + "," +inquiry.getCode() +" 发送失败", 0);
+//										usageLogger.log("询价发送邮件", "企业UU:" + inquiry.getEnUU() + ",单号:" +inquiry.getCode() +" 发送邮件失败", "询价发送邮件出错");
+                                        noticeDao.saveErpLog(userName, userIp, enUU, userUU, "发送询价单通知邮件", "发送失败,询价单号" + inquiry.getCode());
                                         e.printStackTrace();
                                     }
                                 }
                             }
                             // 发短信
-                            for (String userTel : userTels) {
-                                try {
-                                    sms.setReceiver(userTel);
-                                    sms.setTemplateId(messageConf.getMsgInquiryForB2B());
-                                    HttpUtil.sendPost(messageConf.getMessageUrl(), FlexJsonUtils.toJsonDeep(sms));
-
-                                } catch (Exception e) {
-                                    logger.log("公共询价发送短信出错", inquiry.getEnUU() + "," +inquiry.getCode() +" 发送失败", 0);
-                                    e.printStackTrace();
+                            for (UserInfo userTel : userTels) {
+                                if(null != userTel.getEmphone() && userTel.getEmphone().matches(TEL_REGEXP)) {//手机号判断
+                                    try {
+                                        sms.setReceiver(userTel.getEmphone());
+                                        sms.setTemplateId(messageConf.getMsgInquiryForB2B());
+                                        HttpUtil.sendPost(messageConf.getMessageUrl(), FlexJsonUtils.toJsonDeep(sms));
+//										usageLogger.log("询价发送短信", "企业UU:" + inquiry.getEnUU() + ",单号:" +inquiry.getCode() +"短信发送成功", "询价发送短信成功");
+
+                                        noticeDao.saveErpLog(userName, userIp, enUU, userUU, "发送询价单通知短信", "发送成功,询价单号" + inquiry.getCode());
+                                    } catch (Exception e) {
+                                        noticeDao.saveErpLog(userName, userIp, enUU, userUU, "发送询价单通知短信", "发送失败,询价单号" + inquiry.getCode());
+//                                        usageLogger.log("询价发送短信", "企业UU:" + inquiry.getEnUU() + ",单号:" +inquiry.getCode() +"短信发送失败", "询价发送短信出错");
+                                        e.printStackTrace();
+                                    }
                                 }
                             }
                             enUUs.add(inquiryItem.getVendUU());

+ 30 - 6
src/main/java/com/uas/platform/b2b/erp/service/impl/VendorServiceImpl.java

@@ -9,12 +9,14 @@ import com.uas.platform.b2b.dao.VendorDao;
 import com.uas.platform.b2b.erp.model.ErpInviteRecord;
 import com.uas.platform.b2b.erp.model.InquiryVendorInfo;
 import com.uas.platform.b2b.erp.service.VendorService;
+import com.uas.platform.b2b.erp.support.ErpBufferedLogger;
 import com.uas.platform.b2b.model.InvitationRecord;
 import com.uas.platform.b2b.model.Vendor;
 import com.uas.platform.b2b.support.MessageConf;
 import com.uas.platform.b2b.support.SysConf;
 import com.uas.platform.b2b.support.SystemSession;
 import com.uas.platform.b2b.temporary.model.SmsMessage;
+import com.uas.platform.core.logging.BufferedLoggerManager;
 import com.uas.platform.core.model.Status;
 import com.uas.platform.core.util.HttpUtil;
 import com.uas.platform.core.util.serializer.FlexJsonUtils;
@@ -58,6 +60,23 @@ public class VendorServiceImpl implements VendorService{
      */
     final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
+    /**
+     * 电话号码匹配格式
+     */
+    static final String TEL_REGEXP = "^((\\(\\d{3}\\))|(\\d{3}\\-))?(13|15|18|17)\\d{9}$";
+
+    /**
+     * 匹配中文正则式
+     */
+    private static final String CHINESE_REGEXP = "^[\u4e00-\u9fa5]*$";
+
+    /**
+     * 匹配英文正则式
+     */
+    private static final String ENGLISH_REGEXP = "^[A-Za-z]+$";
+
+    private final static ErpBufferedLogger logger = BufferedLoggerManager.getLogger(ErpBufferedLogger.class);
+
     @Override
     public void saveInvitation(List<InquiryVendorInfo> infos) {
         if(!CollectionUtils.isEmpty(infos)) {
@@ -67,11 +86,11 @@ public class VendorServiceImpl implements VendorService{
                 InvitationRecord record = invitationRecordDao.findByEnuuAndVendname(SystemSession.getUser().getEnterprise().getUu(), info.getVe_name());
                 if(null == record || Status.NOT_UPLOAD.value() == record.getStatus()) {
                     record = info.covert();
-                    //发送邮件前先进行判断,每天每个供应商只发送一封邮件
-                    List<ErpInviteRecord> inviteRecords = getRecord(record.getVendname());
-                    if(inviteRecords.size() == 0) {
+                    //发送邮件前先进行判断,每天每个供应商只发送一封邮件(判断在erp已经做了,这边暂时不判断)
+                    List<ErpInviteRecord> inviteRecords = getRecord(record.getVendname().trim());
+                    if(CollectionUtils.isEmpty(inviteRecords)) {
                         // 发送邮件或短信成功才进行保存
-                        if(record.getVenduseremail() != null) {
+                        if(record.getVenduseremail() != null && record.getVenduseremail().contains("@") && !record.getVenduseremail().matches(CHINESE_REGEXP)) {
                             Map<String, Object> model = new HashMap<String, Object>();
                             // 邮件信息
                             if (null != record.getVendusername()) {
@@ -87,12 +106,13 @@ public class VendorServiceImpl implements VendorService{
                                 mailService.send(messageConf.getTplInvitationForERP(), record.getVenduseremail(), model);
                                 record.setStatus(Status.DOWNLOADED.value());
                                 tplstatus = true;
+                                logger.log("erp邀请供应商注册", "邮件邀请:" + record.getVenduseremail(), 1);
                             } catch (Exception e) {
                                 record.setStatus(Status.NOT_UPLOAD.value());
                                 e.printStackTrace();
                             }
                         }
-                        if(record.getVendusertel() != null) {
+                        if(record.getVendusertel() != null && record.getVendusertel().matches(TEL_REGEXP)) {
                             try {
                                 SmsMessage sms = new SmsMessage();
                                 List<Object> obj = new ArrayList<Object>();
@@ -105,6 +125,7 @@ public class VendorServiceImpl implements VendorService{
                                 HttpUtil.sendPost(messageUrl, FlexJsonUtils.toJsonDeep(sms));
                                 record.setStatus(Status.DOWNLOADED.value());
                                 msgstatus = true;
+                                logger.log("erp邀请供应商注册", "短信邀请:" + record.getVendusertel(), 1);
                             } catch (Exception e) {
                                 e.printStackTrace();
                             }
@@ -141,7 +162,10 @@ public class VendorServiceImpl implements VendorService{
      * @return
      */
     private List<ErpInviteRecord> getRecord(String name) {
-        String sql = "select * from invitation_tplrecord where ve_name = '" + name +"'";
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        // 判断是否是当天的单据
+        String sql = "select * from invitation_tplrecord where ve_name = '" + name + "' and substr(ve_date, 1, 10) = '"
+                + simpleDateFormat.format(new Date()) + "'";
         List<ErpInviteRecord> records = commonDao.query(sql, ErpInviteRecord.class);
         return records;
     }

+ 2 - 1
src/main/java/com/uas/platform/b2b/event/MakeOrderSaveReleaseEvent.java

@@ -36,7 +36,8 @@ public class MakeOrderSaveReleaseEvent extends SaveReleaseEvent<PagingReleaseDet
         String emName = "采购员";
         if (null == emUU) {
             emUU = 1L;
-        } else {
+        }
+        if (null != make.getUser()) {
             emName = make.getUser().getUserName();
         }
         Long enUU = make.getEnUU();

+ 4 - 1
src/main/java/com/uas/platform/b2b/event/PurchaseInquiryMouldInvalidReleaseEvent.java

@@ -56,10 +56,13 @@ public class PurchaseInquiryMouldInvalidReleaseEvent extends SaveReleaseEvent<Pa
         PagingRelease release = new PagingRelease(emUU, emName, enUU, date, codeValue, from, title, context, type, isReply, category, table, sourceId, orderStatus, toVendor, url);
         Long vendUU = mould.getVenduu();
         Long vendUserUU = mould.getVendUserUU();
+        String vendUserName = "操作员";
         if (null == vendUserUU) {
             vendUserUU = 1L;
         }
-        String vendUserName = mould.getVendUser().getUserName();
+        if (null != mould.getVendUser()) {
+            vendUserName = mould.getVendUser().getUserName();
+        }
         PagingReleaseDetail releaseDetail = new PagingReleaseDetail(vendUU, vendUserUU, vendUserName);
         releaseDetail.setPagingRelease(release);
         return releaseDetail;

+ 2 - 1
src/main/java/com/uas/platform/b2b/event/PurchaseInquiryMouldReplyReleaseEvent.java

@@ -37,7 +37,8 @@ public class PurchaseInquiryMouldReplyReleaseEvent extends SaveReleaseEvent<Pagi
         String emName = "操作员";
         if (null == emUU) {
             emUU = 1L;
-        } else {
+        }
+        if (null != mould.getVendUser()) {
             emName = mould.getVendUser().getUserName();
         }
         Long vendUU = mould.getVenduu();

+ 2 - 0
src/main/java/com/uas/platform/b2b/event/PurchaseInquiryMouldSaveReleaseEvent.java

@@ -59,6 +59,8 @@ public class PurchaseInquiryMouldSaveReleaseEvent extends SaveReleaseEvent<Pagin
         String vendUserName = "业务员";
         if (null == vendUserUU) {
             vendUserUU = 1L;
+        }
+        if (null != mould.getVendUser()) {
             vendUserName = mould.getVendUser().getUserName();
         }
         PagingReleaseDetail releaseDetail = new PagingReleaseDetail(vendUU, vendUserUU, vendUserName);

+ 4 - 1
src/main/java/com/uas/platform/b2b/event/PurchaseNoticeEndReleaseEvent.java

@@ -38,7 +38,10 @@ public class PurchaseNoticeEndReleaseEvent extends SaveReleaseEvent<PagingReleas
         if (null == emUU) {
             emUU = 1L;
         }
-        String emName = order.getUser().getUserName();
+        String emName = "操作员";
+        if (null != order.getUser()) {
+            emName = order.getUser().getUserName();
+        }
         Long enUU = order.getEnUU();
         Date date = new Date();
         String codeValue = order.getCode();

+ 4 - 1
src/main/java/com/uas/platform/b2b/event/PurchaseOrderEndReleaseEvent.java

@@ -37,7 +37,10 @@ public class PurchaseOrderEndReleaseEvent extends SaveReleaseEvent<PagingRelease
         if (null == emUU) {
             emUU = 1L;
         }
-        String emName = item.getOrder().getUser().getUserName();
+        String emName = "操作员";
+        if (null != item.getOrder().getUser()) {
+            emName = item.getOrder().getUser().getUserName();
+        }
         Long enUU = item.getOrder().getEnUU();
         Date date = new Date();
         String codeValue = item.getOrder().getCode();

+ 4 - 1
src/main/java/com/uas/platform/b2b/event/PurchaseOrderSaveReleaseEvent.java

@@ -37,7 +37,10 @@ public class PurchaseOrderSaveReleaseEvent extends SaveReleaseEvent<PagingReleas
         if (null == emUU) {
             emUU = 1L;
         }
-        String emName = orderAll.getUser().getUserName();
+        String emName = "操作员";
+        if (null != orderAll.getUser()) {
+            emName = orderAll.getUser().getUserName();
+        }
         Long enUU = orderAll.getEnUU();
         Date date = new Date();
         String codeValue = orderAll.getCode();

+ 2 - 0
src/main/java/com/uas/platform/b2b/event/PurchaseProofingItemSaveReleaseEvent.java

@@ -63,6 +63,8 @@ public class PurchaseProofingItemSaveReleaseEvent extends SaveReleaseEvent<Pagin
         String vendUserName = "业务员";
         if (null == vendUserUU) {
             vendUserUU = 1L;
+        }
+        if (null != proofingItem.getVendUser()) {
             vendUserName = proofingItem.getVendUser().getUserName();
         }
         PagingReleaseDetail releaseDetail = new PagingReleaseDetail(vendUU, vendUserUU, vendUserName);

+ 4 - 1
src/main/java/com/uas/platform/b2b/event/SaleSendAcceptReleaseEvent.java

@@ -36,7 +36,10 @@ public class SaleSendAcceptReleaseEvent extends SaveReleaseEvent<PagingReleaseDe
         if (null == emUU) {
             emUU = 1L;
         }
-        String emName = send.getCustUser().getUserName();
+        String emName = "操作员";
+        if (null == send.getCustUser()) {
+            emName = send.getCustUser().getUserName();
+        }
         Long enUU = send.getCustUU();
         Date date = new Date();
         String codeValue = send.getCode();

+ 4 - 1
src/main/java/com/uas/platform/b2b/event/SaleSendRefuseReleaseEvent.java

@@ -34,7 +34,10 @@ public class SaleSendRefuseReleaseEvent extends SaveReleaseEvent<PagingReleaseDe
         if (null == emUU) {
             emUU = 1L;
         }
-        String emName = send.getCustUser().getUserName();
+        String emName = "操作员";
+        if (null != send.getCustUser()) {
+            emName = send.getCustUser().getUserName();
+        }
         Long enUU = send.getCustUU();
         Date date = new Date();
         String codeValue = send.getCode();

+ 1 - 1
src/main/java/com/uas/platform/b2b/filter/SSOInterceptor.java

@@ -167,7 +167,7 @@ public class SSOInterceptor extends AbstractSSOInterceptor {
 	 */
 	private void accessDecision(HttpServletRequest request, User user, HttpServletResponse response) throws IOException {
 		Collection<ConfigAttribute> configAttributes = getAttributes(request);
-		if (null == configAttributes || configAttributes.size() == 0 || user.isSys()) {
+		if (null == configAttributes || configAttributes.size() == 0 || user.isSys() || user.getUserUU() < 0) {
 			return;
 		}
 //		if (null == authorities || !authorities.containsKey(user.getUserUU())) {

+ 8 - 11
src/main/java/com/uas/platform/b2b/listener/MessageListener.java

@@ -145,22 +145,19 @@ public class MessageListener implements ApplicationListener<SaveReleaseEvent<?,
 //							userUUs.add(vendors.get(0).getMyUserUU());
 //						}
 //					}
-                    // 查找被分配客户的用户
+                    // 查找被分配客户的业务员
                     if (!CollectionUtils.isEmpty(vendors)) {
                         Long vendorId = vendors.get(0).getId();
                         List<Distribute> distributes = distributeDao.findByVendorId(vendorId);
-                        // 找出当前企业拥有管理员权限的角色
-                        List<Role> roles = roleDao.findByEnUUAndIssys(detail.getVendUU(), Constant.YES);
-                        Set<Long> adminUUs = new HashSet<>();
-                        if (!CollectionUtils.isEmpty(roles)) {
-                            List<User> admins = userDao.findByRole(roles.get(0).getId());
-                            for (User admin : admins) {
-                                adminUUs.add(admin.getUserUU());
+                        List<Role> roles = roleDao.findByEnUUAndDesc(detail.getVendUU(), "业务员");
+                        if (!CollectionUtils.isEmpty(roles) && !CollectionUtils.isEmpty(distributes)) {
+                            List<User> salesmans = userDao.findByRole(roles.get(0).getId());
+                            Set<Long> salesManUUs = new HashSet<>();
+                            for (User salesman : salesmans) {
+                                salesManUUs.add(salesman.getUserUU());
                             }
-                        }
-                        if (!CollectionUtils.isEmpty(distributes)) {
                             for (Distribute distribute : distributes) {
-                                if (!userUUs.contains(distribute.getUserUU()) && !adminUUs.contains(distribute.getUserUU())) {
+                                if (!userUUs.contains(distribute.getUserUU()) && salesManUUs.contains(distribute.getUserUU())) {
                                     userUUs.add(distribute.getUserUU());
                                 }
                             }

+ 22 - 2
src/main/java/com/uas/platform/b2b/model/PurchaseInquiryItem.java

@@ -263,6 +263,18 @@ public class PurchaseInquiryItem {
 	@Column(name = "id_needquantity")
 	private Double needquantity;
 
+    /**
+     * erp传输状态
+     *
+     * <pre>erp发出数据传输请求时,赋给状态,完成后更新状态</pre>
+     *
+     * 1、 传输完成<br>
+     * 0、 正在传输
+     *
+     */
+	@Column(name = "id_erpstatus")
+    private Short erpstatus;
+
 	public Long getId() {
 		return id;
 	}
@@ -569,7 +581,15 @@ public class PurchaseInquiryItem {
 		this.invalid = invalid;
 	}
 
-	/**
+    public Short getErpstatus() {
+        return erpstatus;
+    }
+
+    public void setErpstatus(Short erpstatus) {
+        this.erpstatus = erpstatus;
+    }
+
+    /**
 	 * 回复记录的描述
 	 * 
 	 * @return
@@ -607,7 +627,7 @@ public class PurchaseInquiryItem {
 		}
 		return this.status == Status.NOT_REPLY.value() || (this.status == Status.REPLIED.value()
 				&& (this.inquiry.getCheck() == null || this.inquiry.getCheck() != Constant.YES)
-				&& this.agreed == null);
+				&& this.agreed == null) || this.erpstatus != Constant.NO;
 	}
 
     public static List<PurchaseInquiry> distinct(List<PurchaseInquiryItem> purcitems) {

+ 1 - 0
src/main/java/com/uas/platform/b2b/service/PurchaseInquiryService.java

@@ -267,4 +267,5 @@ public interface PurchaseInquiryService {
 	 * @return 单据id集合
 	 */
 	List<Long> getUnreadIds(String category);
+
 }

+ 1 - 0
src/main/java/com/uas/platform/b2b/service/PurchaseOrderService.java

@@ -384,4 +384,5 @@ public interface PurchaseOrderService {
 	 */
 	List<Object[]> getOrderCount(String category);
 
+	public void replyByBatch(String idString, String username, String userip, Long enuu, Long useruu);
 }

+ 18 - 14
src/main/java/com/uas/platform/b2b/service/impl/AttachServiceImpl.java

@@ -1,26 +1,24 @@
 package com.uas.platform.b2b.service.impl;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.io.FilenameUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-
+import com.alibaba.fastjson.JSONObject;
 import com.uas.dfs.service.FileClient;
 import com.uas.platform.b2b.core.util.PathUtils;
 import com.uas.platform.b2b.dao.AttachDao;
 import com.uas.platform.b2b.model.Attach;
 import com.uas.platform.b2b.model.FileUpload;
 import com.uas.platform.b2b.service.AttachService;
+import com.uas.platform.b2b.support.HttpUtils;
 import com.uas.platform.b2b.support.SystemSession;
+import com.uas.platform.b2b.temporary.model.FileUrl;
 import com.uas.platform.core.util.FileUtils;
+import org.apache.commons.io.FilenameUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
 
 @Service
 public class AttachServiceImpl implements AttachService {
@@ -57,7 +55,13 @@ public class AttachServiceImpl implements AttachService {
 		if(size >  100 * 1024 * 1024) {// 100Mb
 			// 是否限制文件上传大小
 		}
-		String path = fileClient.upload(uploadItem.getFile().getBytes(), size, FilenameUtils.getExtension(filename), null);
+		String path = null;
+        try {
+            path = HttpUtils.upload(FileUrl.FILE_UPLOAD, uploadItem.getFile(), null);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+//		String path = fileClient.upload(uploadItem.getFile().getBytes(), size, FilenameUtils.getExtension(filename), null);
 		Attach attach = new Attach(filename, path, description, size, new Date());
 		return attach;
 	}

+ 0 - 1
src/main/java/com/uas/platform/b2b/service/impl/BrandServiceImpl.java

@@ -109,7 +109,6 @@ public class BrandServiceImpl implements BrandService {
 	public List<Brand> findByNameEn(String brandNameEn) throws Exception {
 		String url = conf.getB2c() + "/api/product/brand/nameEn/" + URLEncoder.encode(brandNameEn, "UTF-8");
 		HttpUtil.Response res = HttpUtil.sendGetRequest(url, null);
-		System.out.println(JSON.toJSON(res));
 		return JSONObject.parseArray(res.getResponseText(), Brand.class);
 	}
 

+ 4 - 1
src/main/java/com/uas/platform/b2b/service/impl/ComponentServiceImpl.java

@@ -47,7 +47,10 @@ public class ComponentServiceImpl implements ComponentService {
 	@Override
 	public List<Component> findByCode(String code) throws Exception {
         HttpUtil.Response res = HttpUtil.sendGetRequest(conf.getB2c() + "/api/product/component/byCode/" + code, null);
-		return JSONObject.parseArray(res.getResponseText(), Component.class);
+        if(res.getStatusCode() == 200) {
+            return JSONObject.parseArray(res.getResponseText(), Component.class);
+        }
+        return null;
 	}
 
 }

+ 12 - 4
src/main/java/com/uas/platform/b2b/service/impl/DeputyOrderServiceImpl.java

@@ -207,7 +207,9 @@ public class DeputyOrderServiceImpl implements DeputyOrderService {
 			order.setDownloadstatus("未下载");
 			order.setSalecode(deorder.getSalecode());
 			order.setSalepocode(deorder.getSalepocode());
-			order.setOrderamount(Double.valueOf(df.format(deorder.getOrderamount())));
+			if(null != deorder.getOrderamount()) {//存在金额为空值的情况
+                order.setOrderamount(Double.valueOf(df.format(deorder.getOrderamount())));
+            }
 			order.setPaymethod(deorder.getPaymethod());
 			order.setDeputyname(deorder.getDeputyname());
 			if (deorder.getStatus().equals("在录入")) {
@@ -218,9 +220,15 @@ public class DeputyOrderServiceImpl implements DeputyOrderService {
 			order.setTervendaddress(deorder.getTervendaddress());
 			order.setTervendor(deorder.getTervendor());
 			order.setTervenduu(deorder.getTervenduu());
-			order.setTotalamount(Double.valueOf(df.format(deorder.getTotalamount())));
-			order.setTotalpayament(Double.valueOf(df.format(deorder.getTotalpayament())));
-			order.setUsdpayment(Double.valueOf(df.format(deorder.getUsdpayment())));
+			if(null != deorder.getTotalamount()) {
+                order.setTotalamount(Double.valueOf(df.format(deorder.getTotalamount())));
+            }
+            if(null != deorder.getTotalpayament()) {
+                order.setTotalpayament(Double.valueOf(df.format(deorder.getTotalpayament())));
+            }
+            if(null != deorder.getUsdpayment()) {
+                order.setUsdpayment(Double.valueOf(df.format(deorder.getUsdpayment())));
+            }
 			order.setUsertel(deorder.getUsertel());
 			order.setVendtel(deorder.getVendtel());
 			order.setVenduser(deorder.getVenduser());

+ 3 - 0
src/main/java/com/uas/platform/b2b/service/impl/PurchaseAcceptServiceImpl.java

@@ -63,6 +63,9 @@ public class PurchaseAcceptServiceImpl implements PurchaseAcceptService {
 					PurchaseOrderItem orderItem = orderItems.get(0);
 					orderItem.setAcceptQty((orderItem.getAcceptQty() == null ? 0 : orderItems.get(0).getAcceptQty())
 							+ acceptItem.getQty());
+					if(orderItem.getAcceptQty() == orderItem.getQty()) { //全部验收则将单据转成已回复
+					    orderItem.setStatus((short) Status.REPLIED.value());
+                    }
 					purchaseOrderItemDao.save(orderItem);
 				}
 			}

+ 1 - 1
src/main/java/com/uas/platform/b2b/service/impl/PurchaseApBillServiceImpl.java

@@ -171,7 +171,7 @@ public class PurchaseApBillServiceImpl implements PurchaseApBillService {
 	public void refreshPrice(List<ProdInOutRefreshPrice> prodInOuts) {
 		if(!CollectionUtils.isEmpty(prodInOuts)) {
 			for(ProdInOutRefreshPrice prod : prodInOuts) {
-				String sql = " merge into purc$apbillitem i using purc$apbill a on (i.papi_papid = a.pab_id and i.papi_pdinoutno = '" + prod.getPbu_inoutno() + "' and a.pad_venduu= " +SystemSession.getUser().getEnterprise().getUu() + ")" +
+				String sql = " merge into purc$apbillitem i using purc$apbill a on (i.papi_papid = a.pab_id and i.papi_pdinoutno = '" + prod.getPbu_inoutno() + "' and a.pad_enuu = " +SystemSession.getUser().getEnterprise().getUu() + ")" +
 						" when matched then update set i.papi_price = " + prod.getPbu_orderprice();
 				commonDao.getJdbcTemplate().update(sql);
 			}

+ 100 - 33
src/main/java/com/uas/platform/b2b/service/impl/PurchaseInquiryServiceImpl.java

@@ -1,5 +1,6 @@
 package com.uas.platform.b2b.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.uas.message.mail.service.MailService;
 import com.uas.platform.b2b.core.util.ContextUtils;
 import com.uas.platform.b2b.core.util.DateFormatUtils;
@@ -10,7 +11,10 @@ import com.uas.platform.b2b.erp.model.Inquiry;
 import com.uas.platform.b2b.erp.model.QuotationDown;
 import com.uas.platform.b2b.erp.model.QuotationDownDetail;
 import com.uas.platform.b2b.erp.support.ErpBufferedLogger;
-import com.uas.platform.b2b.event.*;
+import com.uas.platform.b2b.event.PurchaseInquiryItemDecideReleaseEvent;
+import com.uas.platform.b2b.event.PurchaseInquiryItemInvalidReleaseEvent;
+import com.uas.platform.b2b.event.PurchaseInquiryItemReplyReleaseEvent;
+import com.uas.platform.b2b.event.PurchaseInquiryItemSaveReleaseEvent;
 import com.uas.platform.b2b.model.*;
 import com.uas.platform.b2b.search.SearchService;
 import com.uas.platform.b2b.service.AttachService;
@@ -20,6 +24,7 @@ import com.uas.platform.b2b.support.SystemSession;
 import com.uas.platform.b2b.support.XingePusher;
 import com.uas.platform.b2b.temporary.model.InquiryMessage;
 import com.uas.platform.b2b.temporary.model.SmsMessage;
+import com.uas.platform.b2b.temporary.model.UserInfo;
 import com.uas.platform.core.concurrent.IRunnable;
 import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.exception.IllegalStatusException;
@@ -101,18 +106,43 @@ public class PurchaseInquiryServiceImpl implements PurchaseInquiryService {
 	@Autowired
 	private MailService mailService;
 
+	@Autowired
+	private EnterpriseDao enterpriseDao;
+
 	@Autowired
 	private MessageConf messageConf;
 
+	@Autowired
+	private NoticeDao noticeDao;
+
 	private final static ErpBufferedLogger logger = BufferedLoggerManager.getLogger(ErpBufferedLogger.class);
 
+    static final String TEL_REGEXP = "^((\\(\\d{3}\\))|(\\d{3}\\-))?(13|15|18|17)\\d{9}$";
+
+    static final String EMAIL_REGEXP = "\\w[-\\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\\.)+[A-Za-z]{2,14}";
+
 	@Override
 	public void save(List<PurchaseInquiryItem> inquiryItems) {
-		inquiryItems = purchaseInquiryItemDao.save(inquiryItems);
-		saveUserOrders(inquiryItems);
-		sendRemind(PurchaseInquiryItem.distinct(inquiryItems));
-//		ContextUtils.publishEvent(new PurchaseInquiryItemSaveEvent(inquiryItems));  // 之前的索引分词,已弃用
-		sendMessage(inquiryItems);
+        inquiryItems = purchaseInquiryItemDao.save(inquiryItems);
+        saveUserOrders(inquiryItems);
+        Long userUU = SystemSession.getUser().getUserUU();
+        Long enUU = SystemSession.getUser().getEnterprise().getUu();
+        String userIp = SystemSession.getUser().getIp();
+        String userName = SystemSession.getUser().getUserName();
+		sendRemind(PurchaseInquiryItem.distinct(inquiryItems), userUU, userName, userIp, enUU);
+		// 产生消息
+		List<PurchaseInquiry> inquiries = PurchaseInquiryItem.distinct(inquiryItems);
+		List<PurchaseInquiryItem> items = new ArrayList<>();
+		for (PurchaseInquiry inquiry : inquiries) {
+			Set<Long> enUUs = new HashSet<>();
+			for (PurchaseInquiryItem inquiryItem : inquiry.getInquiryItems()) {
+				if (!enUUs.contains(inquiryItem.getVendUU())) {
+					items.add(inquiryItem);
+					enUUs.add(inquiryItem.getVendUU());
+				}
+			}
+		}
+		ContextUtils.publishEvent(new PurchaseInquiryItemSaveReleaseEvent(items));
 	}
 
 	/**
@@ -201,9 +231,12 @@ public class PurchaseInquiryServiceImpl implements PurchaseInquiryService {
 	 * 发送通知
 	 *
 	 * @param inquiries 采购询价单主表
-	 * @return
+	 * @param userUU
+	 *@param userName
+	 * @param userIp
+	 * @param enUU @return
 	 */
-	private void sendRemind(final List<PurchaseInquiry> inquiries){
+	private void sendRemind(final List<PurchaseInquiry> inquiries, final Long userUU, final String userName, final String userIp, final Long enUU){
 		ThreadTask.getInstance().execute(new Runnable() {
 			@Override
 			public void run() {
@@ -214,47 +247,80 @@ public class PurchaseInquiryServiceImpl implements PurchaseInquiryService {
 					SmsMessage sms = new SmsMessage();
 					List<Object> obj = new ArrayList<Object>();
 					obj.add(inquiry.getEnterprise().getEnName());
+					obj.add(inquiry.getCode());
 					sms.setParams(obj);
 					for (PurchaseInquiryItem inquiryItem : inquiry.getInquiryItems()) {
-						if (!enUUs.contains(inquiryItem.getVendUU())) {
+						if (null != inquiryItem.getVendUU() && !enUUs.contains(inquiryItem.getVendUU())) {
 							// 查找业务员邮箱
-							String userEmailSql = "select distinct us.user_email useremail from sec$users us " +
+							String userEmailSql = "select distinct us.user_email ememail from sec$users us " +
 									" left join sec$userrole ur on us.user_uu = ur.user_uu left join sec$roles sr " +
 									" on ur.role_id = sr.role_id where sr.role_desc = '业务员' and us.user_email is not null " +
-									" and sr.role_enuu = " + inquiryItem.getVendUU();
-							List<String> userEmails = commonDao.query(userEmailSql, String.class);
-							String userTelSql = "select distinct us.user_email useremail from sec$users us " +
+									" and sr.role_enuu = " + inquiryItem.getVendUU() + " and us.user_uu in (" +
+									"select pd_useruu from purc$distribute where pd_vdid = (" +
+									"select ve_id from purc$vendors where ve_myenuu = " + inquiry.getEnUU() + " and ve_vendenuu = " + inquiryItem.getVendUU() + "))";
+							List<UserInfo> userEmails = commonDao.query(userEmailSql, UserInfo.class);
+							String userTelSql = "select distinct us.user_tel emphone from sec$users us " +
 									" left join sec$userrole ur on us.user_uu = ur.user_uu left join sec$roles sr " +
-									" on ur.role_id = sr.role_id where sr.role_desc = '业务员' and us.user_email is not null " +
-									" and sr.role_enuu = " + inquiryItem.getVendUU();
-							List<String> userTels = commonDao.query(userTelSql, String.class);
+									" on ur.role_id = sr.role_id where sr.role_desc = '业务员' and us.user_tel is not null " +
+									" and sr.role_enuu = " + inquiryItem.getVendUU() + " and us.user_uu in (" +
+									"select pd_useruu from purc$distribute where pd_vdid = (" +
+									"select ve_id from purc$vendors where ve_myenuu = " + inquiry.getEnUU() + " and ve_vendenuu = " + inquiryItem.getVendUU() + "))";
+							List<UserInfo> userTels = commonDao.query(userTelSql, UserInfo.class);
 							// 发邮件
 							Map<String, Object> model = new HashMap<String, Object>();
-							model.put("vendorname", inquiryItem.getEnterprise().getEnName());
+							Enterprise vendor = enterpriseDao.findOne(inquiryItem.getVendUU());
+							if (null != vendor) {
+								model.put("vendorname", vendor.getEnName());
+							} else {
+								model.put("vendorname", "供应商");
+							}
 							model.put("custname", inquiry.getEnterprise().getEnName());
+							model.put("code", inquiry.getCode());
 							model.put("date", DateFormatUtils.DATE_FORMAT.format(new Date()));
-							for (String userEmail : userEmails) {
-								String emailRegex = "[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?";
-								if (Pattern.matches(emailRegex, userEmail)) {
+							// 不存在被分配客户的业务员则添加系统管理员
+							if (CollectionUtils.isEmpty(userEmails) && CollectionUtils.isEmpty(userTels)) {
+								Enterprise enterprise = enterpriseDao.findOne(inquiryItem.getVendUU());
+								if (null != enterprise) {
+									User admin = userDao.findOne(enterprise.getEnAdminuu());
+									if (null != admin) {
+										UserInfo adminInfo = new UserInfo(admin);
+										userEmails.add(adminInfo);
+										userTels.add(adminInfo);
+									}
+								}
+							}
+							for (UserInfo userEmail : userEmails) {
+								if (Pattern.matches(EMAIL_REGEXP, userEmail.getEmemail())) {
 									try {
-										mailService.send(messageConf.getTplInquiryForB2B(), userEmail, model);
+										// 调用自动询价消息模版id
+										mailService.send(messageConf.getTplAutoInquiryForB2B(), userEmail.getEmemail(), model);
+										System.out.println("发送邮件成功:" + JSON.toJSON(userEmail));
+										// 线程内无法访问Systemsession,会报nullPoint,采用存储过程
+//										usageLogger.log("询价发送邮件", "企业UU:" + inquiry.getEnUU() + ",单号:" +inquiry.getCode() +" 发送邮件成功", "询价发送邮件成功");
+										noticeDao.saveErpLog(userName, userIp, enUU, userUU, "发送询价单通知邮件", "发送成功,询价单号" + inquiry.getCode() + ",接收邮箱:" + userEmail.getEmemail());
 									} catch (Exception e) {
-										logger.log("内部询价发送邮件出错", inquiry.getEnUU() + "," +inquiry.getCode() +" 发送失败", 0);
-										throw new RuntimeException(e);
+//										usageLogger.log("询价发送邮件", "企业UU:" + inquiry.getEnUU() + ",单号:" +inquiry.getCode() +" 发送邮件失败", "询价发送邮件出错");
+										noticeDao.saveErpLog(userName, userIp, enUU, userUU, "发送询价单通知邮件", "发送失败,询价单号" + inquiry.getCode() + ",接收邮箱:" + userEmail.getEmemail());
+										e.printStackTrace();
 									}
 								}
 							}
 							// 发短信
-							for (String userTel : userTels) {
-								try {
-									sms.setReceiver(userTel);
-									sms.setTemplateId(messageConf.getMsgInquiryForB2B());
-									HttpUtil.sendPost(messageConf.getMessageUrl(), FlexJsonUtils.toJsonDeep(sms));
-
-								} catch (Exception e) {
-									logger.log("内部询价发送短信出错", inquiry.getEnUU() + "," +inquiry.getCode() +" 发送失败", 0);
-									throw new RuntimeException(e);
-								}
+							for (UserInfo userTel : userTels) {
+								if(null != userTel.getEmphone() && userTel.getEmphone().matches(TEL_REGEXP)) {//手机号判断
+                                    try {
+                                        sms.setReceiver(userTel.getEmphone());
+                                        sms.setTemplateId(messageConf.getMsgAutoInquiryForB2B());
+                                        HttpUtil.sendPost(messageConf.getMessageUrl(), FlexJsonUtils.toJsonDeep(sms));
+//										usageLogger.log("询价发送短信", "企业UU:" + inquiry.getEnUU() + ",单号:" +inquiry.getCode() +"短信发送成功", "询价发送短信成功");
+
+										noticeDao.saveErpLog(userName, userIp, enUU, userUU, "发送询价单通知短信", "发送成功,询价单号" + inquiry.getCode() + ",接收手机:" + userTel.getEmphone());
+                                    } catch (Exception e) {
+										noticeDao.saveErpLog(userName, userIp, enUU, userUU, "发送询价单通知短信", "发送失败,询价单号" + inquiry.getCode() + ",接收手机:" + userTel.getEmphone());
+//                                        usageLogger.log("询价发送短信", "企业UU:" + inquiry.getEnUU() + ",单号:" +inquiry.getCode() +"短信发送失败", "询价发送短信出错");
+										e.printStackTrace();
+                                    }
+                                }
 							}
 							enUUs.add(inquiryItem.getVendUU());
 						}
@@ -266,6 +332,7 @@ public class PurchaseInquiryServiceImpl implements PurchaseInquiryService {
 
 	@Override
 	public List<PurchaseInquiryItem> findNotUploadReply() {
+        purchaseInquiryItemDao.updateStatus(SystemSession.getUser().getEnterprise().getUu(), Constant.NO);
 		return purchaseInquiryItemDao.findByEnUUAndBackStatus(SystemSession.getUser().getEnterprise().getUu(),
 				(short) Status.NOT_UPLOAD.value());
 	}

+ 5 - 0
src/main/java/com/uas/platform/b2b/service/impl/PurchaseOrderServiceImpl.java

@@ -1224,4 +1224,9 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
         return purchaseOrderDao.getUnreadCountEveryStatus(ids);
 	}
 
+    @Override
+    public void replyByBatch(String idString, String username, String userip, Long enuu, Long useruu) {
+        purchaseOrderItemDao.replyByBatch(idString, username, userip, enuu, useruu);
+    }
+
 }

+ 0 - 1
src/main/java/com/uas/platform/b2b/service/impl/RoleServiceImpl.java

@@ -115,7 +115,6 @@ public class RoleServiceImpl implements RoleService {
     @Override
     public ModelMap updateDefault(String desc, Set<ResourceItem> resourceItems) {
 		List<Role> roles = roleDao.findByEnUUAndDesc(null, desc);
-		System.out.println(roles);
 		if (roles == null || roles.size() == 0) {
 			throw new RuntimeException("没有找到默认角色");
 		} else if (roles.size() > 1) {

+ 0 - 1
src/main/java/com/uas/platform/b2b/service/impl/VendorsServiceImpl.java

@@ -291,7 +291,6 @@ public class VendorsServiceImpl implements VendorService {
 		for (Vendor vendor : vendors) {
 			i++;
 			addPartnerShipRecord(vendor);
-			System.out.println("共有" + vendors.size() + "个供应商,当前同步到:" + i);
 		}
 	}
 

+ 360 - 0
src/main/java/com/uas/platform/b2b/support/HttpUtils.java

@@ -0,0 +1,360 @@
+package com.uas.platform.b2b.support;
+
+import com.alibaba.fastjson.JSONObject;
+import com.uas.platform.core.util.serializer.FlexJsonUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.http.Consts;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.apache.http.entity.mime.content.FileBody;
+import org.apache.http.entity.mime.content.InputStreamBody;
+import org.apache.http.entity.mime.content.StringBody;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLEncoder;
+import java.util.*;
+import java.util.Map.Entry;
+
+public class HttpUtils {
+
+	/**
+	 * 发起POST、PUT请求
+	 * 
+	 * @param params
+	 * @return
+	 * @throws Exception
+	 */
+	public static Response get(String url, Map<String, Object> params) throws Exception {
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+		HttpEntityEnclosingRequestBase request = null;
+		CloseableHttpResponse response = null;
+		try {
+			StringBuilder buf = new StringBuilder(url);
+			if (params != null && !params.isEmpty()) {
+				if (url.indexOf("?") == -1)
+					buf.append("?");
+				else if (!url.endsWith("&"))
+					buf.append("&");
+				Set<Entry<String, Object>> entrys = params.entrySet();
+				for (Entry<String, Object> entry : entrys) {
+					buf.append(entry.getKey()).append("=").append(URLEncoder.encode(String.valueOf(entry.getValue()), "UTF-8")).append("&");
+				}
+			}
+			request = new HttpPost(buf.toString());
+			response = httpClient.execute(request);
+			return Response.getResponse(response);
+		} finally {
+			request.releaseConnection();
+			try {
+				httpClient.close();
+			} catch (IOException e) {
+			}
+			if (response != null) {
+				try {
+					response.close();
+				} catch (IOException e) {
+				}
+			}
+		}
+	}
+
+	/**
+	 * 发起POST、PUT请求
+	 *
+	 * @param datas
+	 * @return
+	 * @throws Exception
+	 */
+	public static Response post(String url, Collection<?> datas) throws Exception {
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+		HttpEntityEnclosingRequestBase request = new HttpPost(url);
+		CloseableHttpResponse response = null;
+		try {
+			if (datas != null && !datas.isEmpty()) {
+				request.setEntity(new StringEntity(FlexJsonUtils.toJson(datas), ContentType.create("text/plain", Consts.UTF_8)));
+			}
+			response = httpClient.execute(request);
+			return Response.getResponse(response);
+		} finally {
+			request.releaseConnection();
+			try {
+				httpClient.close();
+			} catch (IOException e) {
+			}
+			if (response != null) {
+				try {
+					response.close();
+				} catch (IOException e) {
+				}
+			}
+		}
+	}
+
+	/**
+	 * 发起POST、PUT请求
+	 *
+	 * @param params
+	 * @return
+	 * @throws Exception
+	 */
+	public static Response post(String url, Map<String, String> params) throws Exception {
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+		HttpEntityEnclosingRequestBase request = new HttpPost(url);
+		CloseableHttpResponse response = null;
+		try {
+			List<NameValuePair> nvps = new ArrayList<NameValuePair>();
+			if (params != null && !params.isEmpty()) {
+				Set<Entry<String, String>> entrys = params.entrySet();
+				for (Entry<String, String> entry : entrys) {
+					nvps.add(new BasicNameValuePair(entry.getKey(), URLEncoder.encode(entry.getValue(), "UTF-8")));
+				}
+			}
+			request.setEntity(new UrlEncodedFormEntity(nvps));
+			response = httpClient.execute(request);
+			return Response.getResponse(response);
+		} finally {
+			request.releaseConnection();
+			try {
+				httpClient.close();
+			} catch (IOException e) {
+			}
+			if (response != null) {
+				try {
+					response.close();
+				} catch (IOException e) {
+				}
+			}
+		}
+	}
+
+	/**
+	 * http上传文件
+	 * 
+	 * @param url
+	 *            请求地址
+	 * @param filePath
+	 *            附件路径
+	 * @param params
+	 *            参数
+	 * @return
+	 * @throws Exception
+	 * @throws IOException
+	 * @throws IllegalStateException
+	 */
+	public static Response upload(String url, String filePath, Map<String, String> params) throws IllegalStateException, IOException,
+			Exception {
+		CloseableHttpClient httpClient = null;
+		CloseableHttpResponse response = null;
+		try {
+			httpClient = HttpClients.createDefault();
+			HttpPost httpPost = new HttpPost(url);
+			FileBody fileBody = new FileBody(new File(filePath));
+			MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+			builder.addPart("file", fileBody);
+			if (params != null) {
+				for (String paramKey : params.keySet()) {
+					StringBody body = new StringBody(params.get(paramKey), ContentType.create("text/plain", Consts.UTF_8));
+					builder.addPart(paramKey, body);
+				}
+			}
+			HttpEntity reqEntity = builder.build();
+			httpPost.setEntity(reqEntity);
+			response = httpClient.execute(httpPost);
+			return Response.getResponse(response);
+		} finally {
+			try {
+				if (response != null) {
+					response.close();
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			try {
+				if (httpClient != null) {
+					httpClient.close();
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	/**
+	 * http上传文件
+	 *
+	 * @param url
+	 *            请求地址
+	 * @param multipartFile
+	 *            附件路径
+	 * @param params
+	 *            参数
+	 * @return
+	 * @throws Exception
+	 * @throws IOException
+	 * @throws IllegalStateException
+	 */
+	public static Response upload(String url, MultipartFile multipartFile, Map<String, String> params) throws IllegalStateException, IOException,
+			Exception {
+		CloseableHttpClient httpClient = null;
+		CloseableHttpResponse response = null;
+		try {
+			httpClient = HttpClients.createDefault();
+			HttpPost httpPost = new HttpPost(url);
+			InputStreamBody streamBody = new InputStreamBody(multipartFile.getInputStream(),
+				multipartFile.getOriginalFilename());
+			MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+			builder.addPart("file", streamBody);
+			if (params != null) {
+				for (String paramKey : params.keySet()) {
+					StringBody body = new StringBody(params.get(paramKey), ContentType.create("text/plain", Consts.UTF_8));
+					builder.addPart(paramKey, body);
+				}
+			}
+			HttpEntity reqEntity = builder.build();
+			httpPost.setEntity(reqEntity);
+			response = httpClient.execute(httpPost);
+			return Response.getResponse(response);
+		} finally {
+			try {
+				if (response != null) {
+					response.close();
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			try {
+				if (httpClient != null) {
+					httpClient.close();
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+    /**
+     * http上传文件
+     *
+     * @param url
+     *            请求地址
+     * @param multipartFile
+     *            附件路径
+     * @param params
+     *            参数
+     * @return
+     * @throws Exception
+     * @throws IOException
+     * @throws IllegalStateException
+     */
+    public static String upload(String url, CommonsMultipartFile commonsMultipartFile, Map<String, String> params) throws IllegalStateException, IOException,
+            Exception {
+        String path = null;
+        CloseableHttpClient httpClient = null;
+        CloseableHttpResponse response = null;
+        try {
+            httpClient = HttpClients.createDefault();
+            HttpPost httpPost = new HttpPost(url);
+            InputStreamBody streamBody = new InputStreamBody(commonsMultipartFile.getInputStream(),
+                    commonsMultipartFile.getOriginalFilename());
+            MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+            builder.addPart("file", streamBody);
+            if (params != null) {
+                for (String paramKey : params.keySet()) {
+                    StringBody body = new StringBody(params.get(paramKey), ContentType.create("text/plain", Consts.UTF_8));
+                    builder.addPart(paramKey, body);
+                }
+            }
+            HttpEntity reqEntity = builder.build();
+            httpPost.setEntity(reqEntity);
+            response = httpClient.execute(httpPost);
+            Response res = Response.getResponse(response);
+            if(res.getStatusCode() == 200) {
+                JSONObject obj = JSONObject.parseObject(res.getResponseText());
+                path = (String) obj.get("path");
+            }
+            return path;
+        } finally {
+            try {
+                if (response != null) {
+                    response.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            try {
+                if (httpClient != null) {
+                    httpClient.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+	/**
+	 * 下载
+	 * 
+	 * @param url
+	 * @return
+	 * @throws ClientProtocolException
+	 * @throws IOException
+	 */
+	public static InputStream download(String url) throws ClientProtocolException, IOException {
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+		HttpGet httpGet = new HttpGet(url);
+		CloseableHttpResponse response = httpClient.execute(httpGet);
+		return response.getEntity().getContent();
+	}
+
+	public static class Response {
+		private int statusCode;
+		private String responseText;
+
+		public int getStatusCode() {
+			return statusCode;
+		}
+
+		public void setStatusCode(int statusCode) {
+			this.statusCode = statusCode;
+		}
+
+		public String getResponseText() {
+			return responseText;
+		}
+
+		public void setResponseText(String responseText) {
+			this.responseText = responseText;
+		}
+
+		public Response() {
+		}
+
+		public Response(HttpResponse response) throws IllegalStateException, IOException, Exception {
+			this.statusCode = response.getStatusLine().getStatusCode();
+			this.responseText = IOUtils.toString(response.getEntity().getContent());
+		}
+
+		public static Response getResponse(HttpResponse response) throws IllegalStateException, IOException, Exception {
+			if (response != null)
+				return new Response(response);
+			return null;
+		}
+	}
+}

+ 32 - 2
src/main/java/com/uas/platform/b2b/support/MessageConf.java

@@ -47,19 +47,33 @@ public class MessageConf {
 	private String msgInvitationForERP;
 
 	/**
-	 * 邮件模版id:询价单提醒供应商报价
+	 * 邮件模版id:公共询价单提醒供应商报价
 	 * @return
 	 */
 	@Value("#{message.tplInquiryForB2B}")
 	private String tplInquiryForB2B;
 
 	/**
-	 * 短信模版id:询价单提醒供应商报价
+	 * 邮件模版id:自动询价单提醒供应商报价
+	 * @return
+	 */
+	@Value("#{message.tplAutoInquiryForB2B}")
+	private String tplAutoInquiryForB2B;
+
+	/**
+	 * 短信模版id:公共询价单提醒供应商报价
 	 * @return
 	 */
 	@Value("#{message.msgInquiryForB2B}")
 	private String msgInquiryForB2B;
 
+	/**
+	 * 短信模版id:自动询价单提醒供应商报价
+	 * @return
+	 */
+	@Value("#{message.msgAutoInquiryForB2B}")
+	private String msgAutoInquiryForB2B;
+
 	/**
 	 * 短信接口地址
 	 * @return
@@ -138,4 +152,20 @@ public class MessageConf {
 	public void setMessageUrl(String messageUrl) {
 		this.messageUrl = messageUrl;
 	}
+
+	public String getTplAutoInquiryForB2B() {
+		return tplAutoInquiryForB2B;
+	}
+
+	public void setTplAutoInquiryForB2B(String tplAutoInquiryForB2B) {
+		this.tplAutoInquiryForB2B = tplAutoInquiryForB2B;
+	}
+
+	public String getMsgAutoInquiryForB2B() {
+		return msgAutoInquiryForB2B;
+	}
+
+	public void setMsgAutoInquiryForB2B(String msgAutoInquiryForB2B) {
+		this.msgAutoInquiryForB2B = msgAutoInquiryForB2B;
+	}
 }

+ 35 - 0
src/main/java/com/uas/platform/b2b/temporary/model/FileUrl.java

@@ -0,0 +1,35 @@
+package com.uas.platform.b2b.temporary.model;
+
+/**
+ * 文件服务器的基本链接
+ *
+ * @author yuj 2017-10-12 14:53
+ */
+public class FileUrl {
+
+    /**
+     * 文件上传
+     */
+    public final static String FILE_UPLOAD = "http://10.10.100.200:9999/file/upload";
+
+
+    /**
+     * 文件下载
+     */
+    public final static String FILE_DOWNLOAD = "http://10.10.100.200:9999/file/download";
+
+    /**
+     * 文件删除
+     */
+    public final static String FILE_DELETE = "http://10.10.100.200:9999/file/delete";
+
+    /**
+     * 文件信息
+     */
+    public final static String FILE_INFO = "http://10.10.100.200:9999/file/info";
+
+    /**
+     * 文件额外属性
+     */
+    public final static String FILE_METADATA = "http://10.10.100.200:9999/file/metadata";
+}

+ 14 - 1
src/main/java/com/uas/platform/b2b/temporary/model/UserInfo.java

@@ -1,5 +1,7 @@
 package com.uas.platform.b2b.temporary.model;
 
+import com.uas.platform.b2b.model.User;
+
 import java.io.Serializable;
 
 /**
@@ -23,7 +25,18 @@ public class UserInfo implements Serializable {
 	private String ememail;
 	private Long emimid;
 	private String emsex;
-	public Long getEmcode() {
+
+	public UserInfo (){
+
+	}
+
+    public UserInfo(User user) {
+    	this.emname = user.getUserName();
+    	this.ememail = user.getUserEmail();
+    	this.emphone = user.getUserTel();
+    }
+
+    public Long getEmcode() {
 		return emcode;
 	}
 

+ 19 - 20
src/main/java/com/uas/platform/b2b/v2/controller/EnterpriseController.java

@@ -80,26 +80,25 @@ public class EnterpriseController {
 	@RequestMapping(value = "/renewUserSpace", method = RequestMethod.POST)
 	@ResponseBody
 	public String renewUserSpace(UserSpaceDetail userSpaceDetail) throws Exception {
-	    return null;
-//		Enterprise enterprise = null;
-//		if(userSpaceDetail.getUu() != null) {
-//			enterprise = enterService.findByEnUU(userSpaceDetail.getUu());
-//		}
-//		if (enterprise != null) {
-//			enterprise.setEnName(userSpaceDetail.getName());
-//			enterprise.setEnShortname(userSpaceDetail.getShortName());
-//			enterprise.setEnAddress(userSpaceDetail.getAddress());
-//			enterprise.setEnBussinessCode(userSpaceDetail.getBusinessCode());
-//			try {
-//				enterpriseService.save(enterprise);
-//				return "success";
-//			} catch (Exception e) {
-//				e.printStackTrace();
-//				return "error";
-//			}
-//		} else {
-//			return "未找到相关的企业信息";
-//		}
+		Enterprise enterprise = null;
+		if(userSpaceDetail.getUu() != null) {
+			enterprise = enterService.findByEnUU(userSpaceDetail.getUu());
+		}
+		if (enterprise != null) {
+			enterprise.setEnName(userSpaceDetail.getName());
+			enterprise.setEnShortname(userSpaceDetail.getShortName());
+			enterprise.setEnAddress(userSpaceDetail.getAddress());
+			enterprise.setEnBussinessCode(userSpaceDetail.getBusinessCode());
+			try {
+				enterpriseService.save(enterprise);
+				return "success";
+			} catch (Exception e) {
+				e.printStackTrace();
+				return "error";
+			}
+		} else {
+			return "未找到相关的企业信息";
+		}
 	}
 
 }

+ 3 - 1
src/main/resources/dev/message.properties

@@ -7,5 +7,7 @@ msgInvitationForERP=5081e29f-47af-4556-a560-9213af11753f
 
 ## messageConfig
 tplInquiryForB2B=bc60d592-9651-4ca1-9305-0852fc7c4101
-msgInquiryForB2B=72cc98e4-0c2b-4d16-944b-2e0515048b8d
+tplAutoInquiryForB2B=fe01ead8-1e26-43d9-8278-4f8a9b4b343c
+msgInquiryForB2B=629edeb3-a87e-4a40-a5e5-51d9ae734f1b
+msgAutoInquiryForB2B=8cf71d56-09bb-4d60-993e-ed87ce72ec3b
 messageUrl=http://message.ubtob.com/sms/send

+ 3 - 1
src/main/resources/prod/message.properties

@@ -7,5 +7,7 @@ msgInvitationForERP=5081e29f-47af-4556-a560-9213af11753f
 
 ## messageConfig
 tplInquiryForB2B=bc60d592-9651-4ca1-9305-0852fc7c4101
-msgInquiryForB2B=72cc98e4-0c2b-4d16-944b-2e0515048b8d
+tplAutoInquiryForB2B=fe01ead8-1e26-43d9-8278-4f8a9b4b343c
+msgInquiryForB2B=629edeb3-a87e-4a40-a5e5-51d9ae734f1b
+msgAutoInquiryForB2B=8cf71d56-09bb-4d60-993e-ed87ce72ec3b
 messageUrl=http://message.ubtob.com/sms/send

+ 3 - 1
src/main/resources/test/message.properties

@@ -7,5 +7,7 @@ msgInvitationForERP=5081e29f-47af-4556-a560-9213af11753f
 
 ## messageConfig
 tplInquiryForB2B=bc60d592-9651-4ca1-9305-0852fc7c4101
-msgInquiryForB2B=72cc98e4-0c2b-4d16-944b-2e0515048b8d
+tplAutoInquiryForB2B=fe01ead8-1e26-43d9-8278-4f8a9b4b343c
+msgInquiryForB2B=629edeb3-a87e-4a40-a5e5-51d9ae734f1b
+msgAutoInquiryForB2B=8cf71d56-09bb-4d60-993e-ed87ce72ec3b
 messageUrl=http://message.ubtob.com/sms/send

+ 11 - 4
src/main/webapp/resources/js/common/services.js

@@ -225,7 +225,7 @@ define(['angular', 'toaster', 'big'], function(angular, big) {
                 return query.length ? query.substr(0, query.length - 1) : query;
             }
         };
-    }).factory('ReportService', ['$http', 'BaseService', 'toaster', function($http, BaseService, toaster) {
+    }).factory('ReportService', ['$http', 'BaseService', 'toaster', '$rootScope', function($http, BaseService, toaster, $rootScope) {
         var rootPath = BaseService.getRootPath();
         return {
             /**
@@ -233,9 +233,16 @@ define(['angular', 'toaster', 'big'], function(angular, big) {
 			 * 单据的条件(格式:where tableName.propertyName = value)
 			 * 
 			 */
-            print: function(enuu, reportName, whereCondition) {
-            	window.open(rootPath + "/report/print?enuu=" + enuu + "&reportName=" + reportName + "&whereCondition=" + whereCondition);
-                /*$http.get(rootPath + '/report/print', {
+            print: function(enuu, reportName, whereCondition, newPage) {
+                var printUrl = rootPath + "/report/print?enuu=" + enuu + "&reportName=" + reportName + "&whereCondition=" + whereCondition;
+            	// window.open(rootPath + "/report/print?enuu=" + enuu + "&reportName=" + reportName + "&whereCondition=" + whereCondition);
+                // 不为空的为需要验证权限的,否则是不用验证权限的
+                if (null != newPage) {
+                    newPage.location.href=printUrl;
+                } else {
+                    window.open(rootPath + "/report/print?enuu=" + enuu + "&reportName=" + reportName + "&whereCondition=" + whereCondition);
+                }
+            	/*$http.get(rootPath + '/report/print', {
                     params: {
                         enuu: enuu,
                         reportName: reportName,

+ 27 - 12
src/main/webapp/resources/js/index/app.js

@@ -883,7 +883,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
     }]);
 
     app.controller('PagingReleaseCtrl', ['$scope', 'PagingRelease', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', 'PagingReleaseInfo', function ($scope, PagingRelease, BaseService, ngTableParams, toaster, $modalInstance, PagingReleaseInfo) {
-        BaseService.scrollBackToTop();
+        // BaseService.scrollBackToTop();
         $scope.active = "todo";
         $scope.searchStatus = false; // 默认从数据库直接获取
         $scope.setActive = function (state) {
@@ -2757,12 +2757,15 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 
             // 需方  打印    采购单
             $scope.custPrint = function (order) {
+                var newPage = window.open("about:blank");
                 PurcOrder.printPermission({}, function () {
                     PurcOrder.custPrintCount({id: order.id}, {});//增加打印此次
-                    ReportService.print(order.enUU, 'PURCLIST_CUST', "where purc$orders.pu_id=" + order.id);
+                    ReportService.print(order.enUU, 'PURCLIST_CUST', "where purc$orders.pu_id=" + order.id, newPage);
                 }, function (response) {
+                    newPage.close();
                     toaster.pop('error', '打印失败', response.data);
                 });
+
             };
 
             $scope.openDatePicker = function ($event, item, openParam) {
@@ -2942,7 +2945,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
         };
     }]);
 
-    app.controller('SaleOrderCtrl', ['$scope', '$filter', 'PurcOrderItem', 'PurcOrder', 'ngTableParams', 'toaster', 'ReportService', 'BaseService', 'PurcOrderItemHis', 'PagingRelease', 'SnapshotService', 'PurcOrderItemInfo', 'token', 'CurrentRole', function ($scope, $filter, PurcOrderItem, PurcOrder, ngTableParams, toaster, ReportService, BaseService, PurcOrderItemHis, PagingRelease, SnapshotService, PurcOrderItemInfo, token, CurrentRole) {
+    app.controller('SaleOrderCtrl', ['$scope', '$filter', 'PurcOrderItem', 'PurcOrder', 'ngTableParams', 'toaster', 'ReportService', 'BaseService', 'PurcOrderItemHis', 'PagingRelease', 'SnapshotService', 'PurcOrderItemInfo', 'token', 'CurrentRole', '$timeout', function ($scope, $filter, PurcOrderItem, PurcOrder, ngTableParams, toaster, ReportService, BaseService, PurcOrderItemHis, PagingRelease, SnapshotService, PurcOrderItemInfo, token, CurrentRole, $timeout) {
         BaseService.scrollBackToTop();
 
         // 判断是否为普通用户
@@ -3156,15 +3159,16 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 
         //打印    采购单
         $scope.print = function (order) {
+            var newPage = window.open("about:blank");
             PurcOrder.printPermission({}, function () {
                 PurcOrder.printCount({id: order.id}, {});//增加打印此次 // 在此方法内添加记录日志
                 if (order.display == 1) $scope.setDisplay('setRead', order.id);//设置为已查看状态
-                ReportService.print(order.enUU, 'PURCLIST', "where purc$orders.pu_id=" + order.id);
+                ReportService.print(order.enUU, 'PURCLIST', "where purc$orders.pu_id=" + order.id , newPage);
                 $scope.tableParams.reload();
             },function (response) {
+                newPage.close();
                 toaster.pop('error', '打印失败', response.data);
             });
-            
         };
 
         $scope.getReply = function (item) {
@@ -3356,10 +3360,12 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 
         // 采购单
         $scope.print = function (order) {
+            var newPage = window.open("about:blank");
             PurcOrder.printPermission({}, function () {
                 PurcOrder.printCount({id: order.id}, {});//增加打印此次
-                ReportService.print(order.enUU, 'PURCLIST', "where purc$orders.pu_id=" + order.id);
+                ReportService.print(order.enUU, 'PURCLIST', "where purc$orders.pu_id=" + order.id, newPage);
             },function (response) {
+                newPage.close();
                 toaster.pop('error', '打印失败', response.data);
             });
         };
@@ -7004,11 +7010,13 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 
         //打印    发货单
         $scope.print = function (send) {
+            var newPage = window.open("about:blank");
             SaleSend.printPermission({}, function () {
                 SaleSend.printCount({id: send.id}, {});   //增加打印此次
+                ReportService.print(send.custUU, 'SALESEND', "where sale$send.ss_id=" + send.id, newPage);
                 $scope.tableParams.reload();
-                ReportService.print(send.custUU, 'SALESEND', "where sale$send.ss_id=" + send.id);
             }, function (response) {
+                newPage.close();
                 toaster.pop('error', '打印失败', response.data);
             });
         };
@@ -7740,10 +7748,12 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
         };
         //打印  样品采购单
         $scope.print = function (sample) {
+            var newPage = window.open("about:blank");
             PurcSample.printPermission({}, function () {
                 PurcSample.printCount({id: sample.id}, {});//增加打印此次
-                ReportService.print(sample.proofing.enUU, 'PURCPROOFING', "where purc$proofingitems.ppi_id =" + sample.id);
+                ReportService.print(sample.proofing.enUU, 'PURCPROOFING', "where purc$proofingitems.ppi_id =" + sample.id, newPage);
             }, function (response) {
+                newPage.close();
                 toaster.pop('error', '打印失败', response.data);
             });
             };
@@ -9547,10 +9557,12 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 
         //打印  对账单
         $scope.print = function (check) {
+            var newPage = window.open("about:blank");
             FaApCheck.printPermission({}, function () {
                 FaApCheck.printCount({id: check.id}, {});//增加打印此次
-                ReportService.print(check.custUu, 'PURCCHECK', 'where purc$apcheck.pa_id =' + check.id);
+                ReportService.print(check.custUu, 'PURCCHECK', 'where purc$apcheck.pa_id =' + check.id, newPage);
             }, function (response) {
+                newPage.close();
                 toaster.pop('error', '打印失败', response.data);
             });
         };
@@ -10622,10 +10634,10 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 
         var getMangagerInfo = function() {
             CurrentRole.isManager({}, function(data) {
-               $scope.isManager = data.isManager;
+               $scope.isManager = data.isManager || $scope.user.sys;
             });
             CurrentRole.roles({}, function(data) {
-               $scope.roles = data.count;
+               $scope.roles = data.count || $scope.user.sys;
             });
         };
         getMangagerInfo();
@@ -16256,6 +16268,8 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
      */
     app.controller('NewDeputyOrderCtrl', ['$scope', 'toaster', '$modal', 'DeputyOrder', '$filter', 'ngTableParams', 'BaseService', 'DecimalNumber', function ($scope, toaster, $modal, DeputyOrder, $filter, ngTableParams, BaseService, DecimalNumber) {
         BaseService.scrollBackToTop();
+        //默认采购单号不重复
+        $scope.orderCodeEnable = true;
         $scope.deOrder = {
             code: 'DC' + $filter('date')(new Date(), 'yyMMddHHmmss_sss'),
             entrydate: new Date(),
@@ -16782,7 +16796,8 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
             });
         };
         loadData();
-
+        //默认采购单号不重复
+        $scope.orderCodeEnable = true;
         // 查询历史供应商
         DeputyOrder.hisvendors({}, function (data) {
             $scope.hisvendors = data;

+ 2 - 2
src/main/webapp/resources/tpl/index/fa/apcheck_customer.html

@@ -47,7 +47,7 @@
 			<div class="col-md-2 col-sm-2"></div>
 			<div class="col-md-8 col-sm-8">
 				<input type="text" class="form-control input-sm"
-					required placeholder="输入供应商名称关键字查询" autofocus ng-model="keyword" ng-search="onSearch(keyword)">
+					required placeholder="输入客户名称关键字查询" autofocus ng-model="keyword" ng-search="onSearch(keyword)">
 				<a class="btn input-group-addon" ng-click="onSearch(keyword)">搜索</a>
 			</div>
 		</div>
@@ -57,7 +57,7 @@
 		<thead>
 			<tr class="header">
 				<th>UU</th>
-				<th>供应商名称</th>
+				<th>客户名称</th>
 				<th>地址</th>
 				<td>启用对账</td>
 				<th>操作</th>

+ 9 - 0
src/main/webapp/resources/tpl/index/make/order.html

@@ -117,6 +117,13 @@
 	top: -2px;
 }
 
+.order-table>tbody:hover .operates {
+	display: block;
+}
+.order-table>tbody:hover .operates-status {
+	display: none;
+}
+
 </style>
 <link rel="stylesheet" href="static/css/public.css">
 <div class="block" id="public">
@@ -265,6 +272,8 @@
 				ng-bind="::(isUser?'-':(order.qty * order.price| number : 2))"
 				class="text-num text-bold"></span>
 			<td colspan="1" class="text-center">
+				<span ng-if="order.print" class="label ng-scope operates-status" style="margin-right: 5px;background-color: #5D6C79">已打印</span>
+				<span ng-if="!order.print" class="label ng-scope operates-status" style="margin-right: 5px;background-color: #CA3955">未打印</span>
 				<div class="operates">
 					<a ng-click="print(order)" title="打印{{order.print? '(已打印)':'(未打印)'}}" ng-class="{'unPrinted' : !order.print, 'text-muted': order.print}"><i
 						class="fa fa-print fa-lg"></i></a><a 

+ 2 - 1
src/main/webapp/resources/tpl/index/purc/deputyOrder.html

@@ -326,7 +326,8 @@
                             <div>录入日期:<span ng-bind="order.entrydate| date: 'yyyy-MM-dd'"></span></div>
                             <div>提交日期:<span ng-bind="order.date| date: 'yyyy-MM-dd'"></span></div>
                             <div>终端供应商:<span ng-bind="order.tervendor"></span></div>
-                            <div>订单金额:<span ng-if="!isUser" ng-bind="order.totalamount | number"></span><span ng-if="isUser">-</span></div>
+                            <div>订单金额: <span ng-if="!isUser" ng-bind="order.totalamount | number"></span><span ng-if="isUser">-</span></div>
+                            <div>订单状态:<span ng-bind="order.entrystatus"></span></div>
                         </div>
                         <div class="col-md-3">
                             <div>订单编号:<a ng-bind="order.salecode" ui-sref="purc.deputydetail({id:order.id})"></a></div>

+ 0 - 3
src/main/webapp/resources/tpl/index/sale/inquiry_mould.html

@@ -416,9 +416,6 @@ tbody td div.text-mould {
 							<span ng-show="inquiryMould.$editing">
 								<a ng-click="inquiryMould.$editing=!inquiryMould.$editing;reload()"
 									class="btn btn-xs btn-link text-error">取消</a>&nbsp;
-								<a ng-click="onReplyClick(inquiryMould)"
-									ng-disabled="!canSave"
-									class="btn btn-link btn-xs text-success">保存</a>&nbsp;
 								<a ng-click="onReplyClick(inquiryMould, true);setOrdersRead(inquiryMould.id)"
 									ng-disabled="!canSave"
 									class="btn btn-link btn-xs text-inverse">

+ 1 - 1
src/main/webapp/resources/tpl/index/sale/order.html

@@ -414,7 +414,7 @@
 				<span ng-if="order.print" class="label ng-scope operates-status" style="margin-right: 5px;background-color: #5D6C79">已打印</span>
 				<span ng-if="!order.print" class="label ng-scope operates-status" style="margin-right: 5px;background-color: #CA3955">未打印</span>
 				<div class="operates">
-					<a ng-click="print(order)" title="打印{{order.print? '(已打印)':'(未打印)'}}" ng-class="{'unPrinted' : !order.print, 'text-muted': order.print}"><i
+					<a ng-click="print(order);" title="打印{{order.print? '(已打印)':'(未打印)'}}" ng-class="{'unPrinted' : !order.print, 'text-muted': order.print}"><i
 						class="fa fa-print fa-lg"></i></a> <a
 						ng-click="order.$collapsed=!order.$collapsed" class="text-muted"
 						title="收拢"><i class="fa fa-toggle-down fa-lg"></i></a>