Просмотр исходного кода

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@450 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d

administrator 11 лет назад
Родитель
Сommit
96a11a388f

+ 7 - 0
src/main/java/com/uas/platform/b2b/dao/PurchaseNoticeDao.java

@@ -25,4 +25,11 @@ public interface PurchaseNoticeDao extends JpaSpecificationExecutor<PurchaseNoti
 	 */
 	List<PurchaseNotice> findByVendUUAndSendStatus(long vendUU, Short sendStatus);
 
+	/**
+	 * 按供应商企业ID、是否结案和结案状态查找送货提醒
+	 * 
+	 * @return
+	 */
+	List<PurchaseNotice> findByVendUUAndEndAndEndStatus(long vendUU, Short end, Short sendStatus);
+
 }

+ 17 - 3
src/main/java/com/uas/platform/b2b/erp/controller/PurchaseNotifyController.java

@@ -48,7 +48,7 @@ public class PurchaseNotifyController {
 		List<PurchaseNotify> notifies = FlexJsonUtils.fromJsonArray(jsonStr, PurchaseNotify.class);
 		purchaseNoticeService.save(purchaseNotifyService.convertPurchaseNotify(notifies));
 	}
-	
+
 	/**
 	 * 从买家ERP获取平台的发货单
 	 * 
@@ -59,7 +59,7 @@ public class PurchaseNotifyController {
 	public List<AcceptNotify> getAcceptNotify() {
 		return purchaseNotifyService.convertSaleSend(purchaseNoticeService.findNotUploadSend());
 	}
-	
+
 	/**
 	 * 平台的发货单传到ERP之后,修改平台里面的发货单的状态
 	 * 
@@ -71,7 +71,7 @@ public class PurchaseNotifyController {
 	public void onSendSuccess(@RequestParam("data") String data) throws UnsupportedEncodingException {
 		purchaseNoticeService.onSendUploadSuccess(URLDecoder.decode(data, "UTF-8").split(","));
 	}
-	
+
 	/**
 	 * 买家ERP主动收料的记录上传到平台 <br>
 	 * 买卖双方直接电话沟通之后,结果由买家填写到ERP系统的情况
@@ -87,4 +87,18 @@ public class PurchaseNotifyController {
 		purchaseNoticeService.send(purchaseNotifyService.convertAcceptNotify(accepts));
 	}
 
+	/**
+	 * 买家结案送货提醒后,传到平台
+	 * 
+	 * @return
+	 * @throws UnsupportedEncodingException
+	 */
+	@RequestMapping(value = "/end", method = RequestMethod.POST)
+	@ResponseBody
+	public void end(@RequestParam("data") String data) throws UnsupportedEncodingException {
+		String jsonStr = URLDecoder.decode(data, "UTF-8");
+		List<PurchaseNotify> ends = FlexJsonUtils.fromJsonArray(jsonStr, PurchaseNotify.class);
+		purchaseNoticeService.end(ends);
+	}
+
 }

+ 24 - 0
src/main/java/com/uas/platform/b2b/erp/controller/SaleNotifyDownController.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 import com.uas.platform.b2b.erp.model.SaleNotifyDown;
+import com.uas.platform.b2b.erp.model.SaleNotifyDownEnd;
 import com.uas.platform.b2b.erp.model.SaleOut;
 import com.uas.platform.b2b.erp.service.SaleNotifyDownService;
 import com.uas.platform.b2b.service.PurchaseNoticeService;
@@ -95,4 +96,27 @@ public class SaleNotifyDownController {
 		purchaseNoticeService.onSendDownSuccess(URLDecoder.decode(data, "UTF-8").split(","));
 	}
 
+	/**
+	 * 卖家ERP从平台获取结案、反结案客户送货提醒
+	 * 
+	 * @return
+	 */
+	@RequestMapping(value = "/end", method = RequestMethod.GET)
+	@ResponseBody
+	public List<SaleNotifyDownEnd> getSaleNotifyEnd() {
+		return saleNotifyDownService.convertPurchaseNoticeEnd(purchaseNoticeService.findNotSendEnd());
+	}
+
+	/**
+	 * 平台的结案、反结案客户送货提醒单传到供应商ERP之后,修改平台里面的上传状态
+	 * 
+	 * @return
+	 * @throws UnsupportedEncodingException
+	 */
+	@RequestMapping(value = "/end/back", method = RequestMethod.POST)
+	@ResponseBody
+	public void onEndDownSuccess(@RequestParam("data") String data) throws UnsupportedEncodingException {
+		purchaseNoticeService.onEndDownSuccess(URLDecoder.decode(data, "UTF-8").split(","));
+	}
+
 }

+ 42 - 0
src/main/java/com/uas/platform/b2b/erp/model/SaleNotifyDownEnd.java

@@ -0,0 +1,42 @@
+package com.uas.platform.b2b.erp.model;
+
+import com.uas.platform.b2b.model.PurchaseNotice;
+
+/**
+ * 卖家ERP系统的已结案客户送货提醒单
+ * 
+ * @author yingp
+ * 
+ */
+public class SaleNotifyDownEnd {
+
+	private long b2b_pn_id;
+	private long cu_uu;
+
+	public long getB2b_pn_id() {
+		return b2b_pn_id;
+	}
+
+	public void setB2b_pn_id(long b2b_pn_id) {
+		this.b2b_pn_id = b2b_pn_id;
+	}
+
+	public long getCu_uu() {
+		return cu_uu;
+	}
+
+	public void setCu_uu(long cu_uu) {
+		this.cu_uu = cu_uu;
+	}
+
+	/**
+	 * 平台的已结案客户送货提醒,转为卖家的已结案客户送货提醒
+	 * 
+	 * @param notice
+	 */
+	public SaleNotifyDownEnd(PurchaseNotice notice) {
+		this.b2b_pn_id = notice.getId();
+		this.cu_uu = notice.getEnUU();
+	}
+
+}

+ 9 - 0
src/main/java/com/uas/platform/b2b/erp/service/SaleNotifyDownService.java

@@ -3,6 +3,7 @@ package com.uas.platform.b2b.erp.service;
 import java.util.List;
 
 import com.uas.platform.b2b.erp.model.SaleNotifyDown;
+import com.uas.platform.b2b.erp.model.SaleNotifyDownEnd;
 import com.uas.platform.b2b.erp.model.SaleOut;
 import com.uas.platform.b2b.model.PurchaseNotice;
 import com.uas.platform.b2b.model.SaleSend;
@@ -32,5 +33,13 @@ public interface SaleNotifyDownService {
 	 * @return
 	 */
 	List<SaleOut> convertSaleSend(List<SaleSend> sends);
+	
+	/**
+	 * 将平台的已结案客户送货提醒,转为卖家ERP的已结案客户送货提醒
+	 * 
+	 * @param notices
+	 * @return
+	 */
+	List<SaleNotifyDownEnd> convertPurchaseNoticeEnd(List<PurchaseNotice> notices);
 
 }

+ 9 - 0
src/main/java/com/uas/platform/b2b/erp/service/impl/SaleNotifyDownServiceImpl.java

@@ -6,6 +6,7 @@ import java.util.List;
 import org.springframework.stereotype.Service;
 
 import com.uas.platform.b2b.erp.model.SaleNotifyDown;
+import com.uas.platform.b2b.erp.model.SaleNotifyDownEnd;
 import com.uas.platform.b2b.erp.model.SaleOut;
 import com.uas.platform.b2b.erp.service.SaleNotifyDownService;
 import com.uas.platform.b2b.model.PurchaseNotice;
@@ -41,4 +42,12 @@ public class SaleNotifyDownServiceImpl implements SaleNotifyDownService {
 		return outs;
 	}
 
+	@Override
+	public List<SaleNotifyDownEnd> convertPurchaseNoticeEnd(List<PurchaseNotice> notices) {
+		List<SaleNotifyDownEnd> ends = new ArrayList<SaleNotifyDownEnd>();
+		for (PurchaseNotice notice : notices)
+			ends.add(new SaleNotifyDownEnd(notice));
+		return ends;
+	}
+
 }

+ 28 - 0
src/main/java/com/uas/platform/b2b/model/PurchaseNotice.java

@@ -95,6 +95,18 @@ public class PurchaseNotice implements Serializable {
 	@Column(name = "pn_sendstatus")
 	private Short sendStatus;
 
+	/**
+	 * 是否已结案
+	 */
+	@Column(name = "pn_end")
+	private Short end;
+
+	/**
+	 * 结案状态是否已传输到卖家ERP的情况
+	 */
+	@Column(name = "pn_endstatus")
+	private Short endStatus;
+
 	public Long getId() {
 		return id;
 	}
@@ -183,4 +195,20 @@ public class PurchaseNotice implements Serializable {
 		this.sendStatus = sendStatus;
 	}
 
+	public Short getEnd() {
+		return end;
+	}
+
+	public void setEnd(Short end) {
+		this.end = end;
+	}
+
+	public Short getEndStatus() {
+		return endStatus;
+	}
+
+	public void setEndStatus(Short endStatus) {
+		this.endStatus = endStatus;
+	}
+
 }

+ 23 - 0
src/main/java/com/uas/platform/b2b/service/PurchaseNoticeService.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import org.springframework.data.domain.Page;
 
+import com.uas.platform.b2b.erp.model.PurchaseNotify;
 import com.uas.platform.b2b.model.PurchaseNotice;
 import com.uas.platform.b2b.model.SaleSend;
 import com.uas.platform.b2b.model.SaleSendItem;
@@ -19,6 +20,14 @@ public interface PurchaseNoticeService {
 	 */
 	public void save(List<PurchaseNotice> notices);
 
+	/**
+	 * 批量结案客户送货提醒
+	 * 
+	 * @param notifies
+	 * @return
+	 */
+	public void end(List<PurchaseNotify> notifies);
+
 	/**
 	 * 分页查找送货提醒单
 	 * 
@@ -99,4 +108,18 @@ public interface PurchaseNoticeService {
 	 */
 	public void onSendDownSuccess(String[] idArray);
 
+	/**
+	 * 查找所有待上传到卖家的已结案送货提醒
+	 * 
+	 * @return
+	 */
+	public List<PurchaseNotice> findNotSendEnd();
+
+	/**
+	 * 已结案送货提醒单成功传到卖家ERP之后
+	 * 
+	 * @param idArray
+	 */
+	public void onEndDownSuccess(String[] idArray);
+
 }

+ 39 - 9
src/main/java/com/uas/platform/b2b/service/impl/PurchaseNoticeServiceImpl.java

@@ -7,6 +7,7 @@ import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
 
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.jpa.domain.Specification;
@@ -15,6 +16,7 @@ import org.springframework.stereotype.Service;
 import com.uas.platform.b2b.dao.PurchaseNoticeDao;
 import com.uas.platform.b2b.dao.SaleSendDao;
 import com.uas.platform.b2b.dao.SaleSendItemDao;
+import com.uas.platform.b2b.erp.model.PurchaseNotify;
 import com.uas.platform.b2b.model.PurchaseNotice;
 import com.uas.platform.b2b.model.PurchaseOrder;
 import com.uas.platform.b2b.model.SaleSend;
@@ -22,6 +24,7 @@ import com.uas.platform.b2b.model.SaleSendItem;
 import com.uas.platform.b2b.service.PurchaseNoticeService;
 import com.uas.platform.b2b.support.SystemSession;
 import com.uas.platform.b2b.support.XingePusher;
+import com.uas.platform.core.model.Constant;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.Status;
 
@@ -45,12 +48,11 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
 			PurchaseOrder order = notice.getOrderItem().getOrder();
 			if (order.getVendUserUU() != null) {
 				// Android
-				XingePusher.pushSingleAccountAndroid(order.getVendUserUU().toString(), "新增一个送货提醒-",
-						"单号:" + notice.getCode() + ",客户:" + order.getEnterprise().getEnName(),
-						"com.sas.mobile.activity.PurchaseChangeActivity");
+				XingePusher.pushSingleAccountAndroid(order.getVendUserUU().toString(), "新增一个送货提醒-", "单号:" + notice.getCode() + ",客户:"
+						+ order.getEnterprise().getEnName(), "com.sas.mobile.activity.PurchaseChangeActivity");
 				// IOS
-				XingePusher.pushSingleAccountIOS(order.getVendUserUU().toString(),
-						"新增一个送货提醒-" + "单号:" + notice.getCode() + ",客户:" + order.getEnterprise().getEnName());
+				XingePusher.pushSingleAccountIOS(order.getVendUserUU().toString(), "新增一个送货提醒-" + "单号:" + notice.getCode() + ",客户:"
+						+ order.getEnterprise().getEnName());
 			}
 		}
 	}
@@ -105,14 +107,12 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
 
 	@Override
 	public List<SaleSend> findNotUploadSend() {
-		return saleSendDao.findByCustUUAndSendStatus(SystemSession.getUser().getEnterprise().getUu(),
-				(short) Status.NOT_UPLOAD.value());
+		return saleSendDao.findByCustUUAndSendStatus(SystemSession.getUser().getEnterprise().getUu(), (short) Status.NOT_UPLOAD.value());
 	}
 
 	@Override
 	public List<SaleSend> findNotSendSend() {
-		return saleSendDao.findByEnUUAndBackStatus(SystemSession.getUser().getEnterprise().getUu(),
-				(short) Status.NOT_UPLOAD.value());
+		return saleSendDao.findByEnUUAndBackStatus(SystemSession.getUser().getEnterprise().getUu(), (short) Status.NOT_UPLOAD.value());
 	}
 
 	@Override
@@ -137,4 +137,34 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
 		}
 	}
 
+	@Override
+	public void end(List<PurchaseNotify> notifies) {
+		long enUU = SystemSession.getUser().getEnterprise().getUu();
+		for (PurchaseNotify notify : notifies) {
+			List<PurchaseNotice> notices = purchaseNoticeDao.findByEnUUAndCode(enUU, notify.getPn_code());
+			if (!CollectionUtils.isEmpty(notices)) {
+				PurchaseNotice notice = notices.get(0);
+				notice.setEnd(Constant.YES);
+				notice.setEndStatus((short) Status.NOT_UPLOAD.value());
+			}
+		}
+	}
+
+	@Override
+	public List<PurchaseNotice> findNotSendEnd() {
+		return purchaseNoticeDao.findByVendUUAndEndAndEndStatus(SystemSession.getUser().getEnterprise().getUu(), Constant.YES,
+				(short) Status.NOT_UPLOAD.value());
+	}
+
+	@Override
+	public void onEndDownSuccess(String[] idArray) {
+		for (String id : idArray) {
+			PurchaseNotice notice = purchaseNoticeDao.findOne(Long.parseLong(id));
+			if (notice != null) {
+				notice.setEndStatus((short) Status.DOWNLOADED.value());
+				purchaseNoticeDao.save(notice);
+			}
+		}
+	}
+
 }