寄单放单提交校验
This commit is contained in:
parent
822ff96961
commit
20467a3b60
@ -1,15 +1,21 @@
|
||||
package com.yem.wm.es.exportpresent.validator;
|
||||
|
||||
import com.yem.wm.es.shippingdetails.util.PaymentControlUtil;
|
||||
import com.yem.wm.utils.DynamicObjectUtil;
|
||||
import com.yem.wm.utils.YEM;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.entity.validate.AbstractValidator;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.yem.wm.es.contractamtlist.util.FunUtil.getPayBills;
|
||||
import static com.yem.wm.es.contractamtlist.util.FunUtil.getShipBills;
|
||||
@ -20,25 +26,112 @@ import static com.yem.wm.es.contractamtlist.util.FunUtil.getShipBills;
|
||||
* @Created by ZZSLL
|
||||
*/
|
||||
|
||||
public class ExportPresentSubmitValidator extends AbstractValidator
|
||||
{
|
||||
public class ExportPresentSubmitValidator extends AbstractValidator {
|
||||
@Override
|
||||
public void validate()
|
||||
{
|
||||
public void validate() {
|
||||
ExtendedDataEntity[] dataEntities = this.getDataEntities();
|
||||
for (ExtendedDataEntity data : dataEntities) {
|
||||
DynamicObject dataEntity = data.getDataEntity();
|
||||
// 款项类型
|
||||
String paymenttype = dataEntity.getString("yem_paymenttype");
|
||||
|
||||
// 是否见提单
|
||||
String isladingbill = dataEntity.getString("yem_isladingbill");
|
||||
// 收汇信息
|
||||
DynamicObjectCollection receiveC = dataEntity.getDynamicObjectCollection("yem_es_exportpre_erf");
|
||||
DynamicObjectCollection detailC = dataEntity.getDynamicObjectCollection("yem_es_exportpre_el");
|
||||
|
||||
Set<String> salesOrder = new HashSet<>();
|
||||
for (DynamicObject d : detailC) {
|
||||
salesOrder.add(d.getString("yem_contractnum"));
|
||||
}
|
||||
String selectfields = DynamicObjectUtil.getSelectfields("yem_es_salesorder");
|
||||
selectfields = DynamicObjectUtil.getEntrySelectfields(selectfields, "yem_es_salesorder", "yem_es_salescontrac_s");
|
||||
Map<Object, DynamicObject> orders = BusinessDataServiceHelper.loadFromCache("yem_es_salesorder", selectfields, new QFilter[]{new QFilter("billno", "in", salesOrder)});
|
||||
|
||||
if ("A".equals(paymenttype)) {
|
||||
arrearsVerification(dataEntity, data);
|
||||
|
||||
if ("A".equals(isladingbill)) {
|
||||
prePayAmtValidator(data, orders, detailC, receiveC);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void arrearsVerification(DynamicObject dataEntity, ExtendedDataEntity data)
|
||||
{
|
||||
DynamicObjectCollection collection = dataEntity.getDynamicObjectCollection("yem_es_exportpre_erf");
|
||||
/**
|
||||
* 0、见提单并且100%L/C,100%OA、100%DP、100%DA并且没有预收款:判断预收款项是否认领完成
|
||||
* 0、见提单并且100%L/C,100%OA、100%DP、100%DA并且有预收款:只判断预收款项是否认领完成
|
||||
* 通过或不进行1234校验
|
||||
* 1、见提单并且正常款项:判断合同是否认领完成
|
||||
* 2、见提单并且特殊款项:判断合同是否认领完成
|
||||
* 1或2通过不进行后续校验
|
||||
* 3、未件提单并且正常款项:判断合同是否认领完成
|
||||
* 4、未件提单并且特殊款项:判断合同是否认领完成
|
||||
* 3或4通过不进行后续校验
|
||||
*
|
||||
*/
|
||||
private void prePayAmtValidator(ExtendedDataEntity data, Map<Object, DynamicObject> orders, DynamicObjectCollection detailC, DynamicObjectCollection receiveC) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Map.Entry<Object, DynamicObject> entry : orders.entrySet()) {
|
||||
DynamicObject order = entry.getValue();
|
||||
BigDecimal shipPreRapRate = PaymentControlUtil.getShipPreRapRate(order);
|
||||
BigDecimal procPreRapRate = PaymentControlUtil.getProcPreRapRate(order);
|
||||
// 该合同是否包含预付
|
||||
boolean isPre = shipPreRapRate.add(procPreRapRate).compareTo(BigDecimal.ZERO) > 0;
|
||||
DynamicObjectCollection collection = order.getDynamicObjectCollection("yem_es_salescontrac_s");
|
||||
boolean isSpecialRapStyle = false;
|
||||
for (DynamicObject d : collection) {
|
||||
DynamicObject rapstyle = d.getDynamicObject("yem_rapstyle_c");
|
||||
if (YEM.isNotEmpty(rapstyle) && "D/A JSFS08 L/C OA D/A".contains(rapstyle.getString("number"))) {
|
||||
isSpecialRapStyle = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 合同金额
|
||||
BigDecimal offeramount = order.getBigDecimal("yem_offeramount");
|
||||
String billno = order.getString("billno");
|
||||
// 合同已认领金额
|
||||
BigDecimal climeAmt = PaymentControlUtil.getContractClimeAmt(order, "");
|
||||
// 只判断预付款是否认领完成
|
||||
if (isSpecialRapStyle && isPre) {
|
||||
BigDecimal climeAmtShip = PaymentControlUtil.getContractClimeAmt(order, "D");
|
||||
BigDecimal climeAmtProc = PaymentControlUtil.getContractClimeAmt(order, "E");
|
||||
|
||||
BigDecimal climePreAmt = climeAmtShip.add(climeAmtProc);
|
||||
|
||||
BigDecimal shipAmt = PaymentControlUtil.getAdvancePayment(shipPreRapRate, offeramount);
|
||||
BigDecimal procAmt = PaymentControlUtil.getAdvancePayment(procPreRapRate, offeramount);
|
||||
|
||||
BigDecimal orderPreAmt = shipAmt.add(procAmt);
|
||||
|
||||
if (climePreAmt.compareTo(orderPreAmt) < 0) {
|
||||
sb.append(String.format("合同 [ %s ] ,合同预收金额 [ %s ], 合同预收已认领金额合计 [ %s ],合同预收款未认领完成,请核对后提交!(L/C、OA、DP、DA)",
|
||||
billno,
|
||||
orderPreAmt.setScale(4, RoundingMode.HALF_UP).toPlainString(),
|
||||
climePreAmt.setScale(4, RoundingMode.HALF_UP).toPlainString())).append("\r\n");
|
||||
}
|
||||
} else {
|
||||
if (climeAmt.compareTo(offeramount) < 0) {
|
||||
boolean passed = arrearsVerification(data.getDataEntity(), data, receiveC);
|
||||
if (!passed) {
|
||||
sb.append(String.format("合同 [ %s ] ,合同金额 [ %s ], 合同已认领金额合计 [ %s ],合同未认领完成,请核对后提交!",
|
||||
billno,
|
||||
offeramount.setScale(4, RoundingMode.HALF_UP).toPlainString(),
|
||||
climeAmt.setScale(4, RoundingMode.HALF_UP).toPlainString())).append("\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sb.length() > 0) {
|
||||
this.addErrorMessage(data, String.valueOf(sb));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 走储备申请或者走欠条申请,但是款项未认领完成,不允许提交寄单放单
|
||||
*/
|
||||
private boolean arrearsVerification(DynamicObject dataEntity, ExtendedDataEntity data, DynamicObjectCollection collection) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (DynamicObject dynamicObject : collection) {
|
||||
DynamicObject saleOrder = dynamicObject.getDynamicObject("yem_saleorder");
|
||||
@ -62,5 +155,7 @@ public class ExportPresentSubmitValidator extends AbstractValidator
|
||||
if (sb.length() > 0) {
|
||||
this.addErrorMessage(data, String.valueOf(sb));
|
||||
}
|
||||
|
||||
return sb.length() == 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user