Ver código fonte

增加货款调账反过账单据上传处理,字段赋值更新

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@8588 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d
hejq 9 anos atrás
pai
commit
891047aed9

+ 13 - 0
src/main/java/com/uas/platform/b2b/erp/controller/PurchaseAPBillController.java

@@ -92,4 +92,17 @@ public class PurchaseAPBillController {
 		logger.log("货款调账", "上传货款调账", apBills.size());
 	}
 
+	/**
+	 * 将ERP反过账的货款调账传到平台
+	 * 
+	 * @param data
+	 * @throws UnsupportedEncodingException
+	 */
+	@RequestMapping(value = "/nonPostAdjustment", method = RequestMethod.POST)
+	@ResponseBody
+	public void nonPostAdjustment(@RequestParam("data") String data) throws UnsupportedEncodingException {
+		String jsonStr = URLDecoder.decode(data, "UTF-8");
+		List<PurchaseAPBill> apBills = FlexJsonUtils.fromJsonArray(jsonStr, PurchaseAPBill.class);
+		apbillAdjustmentService.nonPosting(apbillAdjustmentService.convertnonPostAdjustment(apBills));
+	}
 }

+ 2 - 1
src/main/java/com/uas/platform/b2b/erp/service/impl/PurchaseAPBillServiceImpl.java

@@ -86,7 +86,6 @@ public class PurchaseAPBillServiceImpl implements PurchaseAPBillService {
 				if (!CollectionUtils.isEmpty(apBill.getDetails())) {
 					for (PurchaseAPBillDetail detail : apBill.getDetails()) {
 						ApbillAdjustment adjust = new ApbillAdjustment(apBill);
-						adjust.setInoutno(detail.getAbd_pdinoutno());
 						Product product = new Product();
 						product.setCode(detail.getAbd_prodcode());
 						adjust.setPrid(product.getId());
@@ -99,6 +98,8 @@ public class PurchaseAPBillServiceImpl implements PurchaseAPBillService {
 						adjust.setOrderdetno(detail.getAbd_orderdetno());
 						adjust.setTaxrate(detail.getAbd_taxrate());
 						adjust.setYcheckqty(detail.getAbd_yqty());
+						Enterprise enterprise = enterpriseDao.findEnterpriseByUu(adjust.getEnuu());
+						adjust.setReceivename(enterprise.getEnName());
 						List<Product> products = productDao.findByEnUUAndCode(enUU, adjust.getProdcode());
 						if (!CollectionUtils.isEmpty(products)) {
 							Product productInfo = products.get(0);

+ 30 - 0
src/main/java/com/uas/platform/b2b/model/ApbillAdjustment.java

@@ -204,6 +204,18 @@ public class ApbillAdjustment implements Serializable {
 	@Column(name = "aa_factory")
 	private String factory;
 
+	/**
+	 * 传到erp状态
+	 */
+	@Column(name = "aa_sendstatus")
+	private Integer sendstatus;
+
+	/**
+	 * 反过账状态
+	 */
+	@Column(name = "aa_nonposting")
+	private Short nonposting;
+
 	public Long getId() {
 		return id;
 	}
@@ -428,6 +440,22 @@ public class ApbillAdjustment implements Serializable {
 		this.orderdate = orderdate;
 	}
 
+	public Integer getSendstatus() {
+		return sendstatus;
+	}
+
+	public void setSendstatus(Integer sendstatus) {
+		this.sendstatus = sendstatus;
+	}
+
+	public Short getNonposting() {
+		return nonposting;
+	}
+
+	public void setNonposting(Short nonposting) {
+		this.nonposting = nonposting;
+	}
+
 	public ApbillAdjustment(PurchaseAPBill apBill) {
 		Enterprise enterprise = SystemSession.getUser().getEnterprise();
 		this.setCurrency(apBill.getAb_currency());
@@ -437,6 +465,8 @@ public class ApbillAdjustment implements Serializable {
 		this.setEnuu(apBill.getAb_vendoruu());
 		this.setCustuu(enterprise.getUu());
 		this.setCustname(enterprise.getEnName());
+		this.setInoutno(apBill.getAb_code());
+		this.setRate(apBill.getAb_rate());
 	}
 
 	public ApbillAdjustment() {

+ 15 - 0
src/main/java/com/uas/platform/b2b/service/ApbillAdjustmentService.java

@@ -2,6 +2,7 @@ package com.uas.platform.b2b.service;
 
 import java.util.List;
 
+import com.uas.platform.b2b.erp.model.PurchaseAPBill;
 import com.uas.platform.b2b.model.ApbillAdjustment;
 
 public interface ApbillAdjustmentService {
@@ -20,4 +21,18 @@ public interface ApbillAdjustmentService {
 	 * @return
 	 */
 	public List<ApbillAdjustment> getAdjustList(List<Long> filter, String keyword, Long fromDate, Long endDate);
+
+	/**
+	 * 将ERP的已反过账的货款调账,转为反过账的货款调账
+	 * 
+	 * @param apBills
+	 * @return
+	 */
+	public List<ApbillAdjustment> convertnonPostAdjustment(List<PurchaseAPBill> apBills);
+
+	/**
+	 * 
+	 * @param Adjustment
+	 */
+	public void nonPosting(List<ApbillAdjustment> adjustments);
 }

+ 35 - 0
src/main/java/com/uas/platform/b2b/service/impl/ApbillAdjustmentServiceImpl.java

@@ -1,5 +1,6 @@
 package com.uas.platform.b2b.service.impl;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -11,9 +12,12 @@ import org.springframework.util.CollectionUtils;
 
 import com.uas.platform.b2b.dao.ApbillAdjustmentDao;
 import com.uas.platform.b2b.dao.CommonDao;
+import com.uas.platform.b2b.erp.model.PurchaseAPBill;
 import com.uas.platform.b2b.model.ApbillAdjustment;
 import com.uas.platform.b2b.service.ApbillAdjustmentService;
 import com.uas.platform.b2b.support.SystemSession;
+import com.uas.platform.core.model.Constant;
+import com.uas.platform.core.model.Status;
 
 
 @Service
@@ -125,4 +129,35 @@ public class ApbillAdjustmentServiceImpl implements ApbillAdjustmentService {
 			return null;
 		}
 	}
+
+	@Override
+	public List<ApbillAdjustment> convertnonPostAdjustment(List<PurchaseAPBill> apBills) {
+		List<ApbillAdjustment> adjusts = new ArrayList<ApbillAdjustment>();
+		if (!CollectionUtils.isEmpty(apBills)) {
+			Long enUU = SystemSession.getUser().getEnterprise().getUu();
+			for (PurchaseAPBill apBill : apBills) {
+				List<ApbillAdjustment> list = apbillAdjustmentDao.findByEnuuAndInoutno(enUU, apBill.getAb_code());
+				if (list.size() > 0) {
+					adjusts.add(list.get(0));
+				}
+			}
+		}
+		return adjusts;
+	}
+
+	@Override
+	public void nonPosting(List<ApbillAdjustment> adjustments) {
+		if (!CollectionUtils.isEmpty(adjustments)) {
+			for (ApbillAdjustment adjustment : adjustments) {
+				if (adjustment.getSendstatus() == Status.DOWNLOADED.value()) {
+					// 已传输到供应商ERP,修改单据反过账状态
+					adjustment.setNonposting(Constant.YES);
+					apbillAdjustmentDao.save(adjustment);
+				} else {
+					// 未传输到供应商ERP,直接删除平台上的单据
+					apbillAdjustmentDao.delete(adjustment);
+				}
+			}
+		}
+	}
 }