feat:寄单放单申请提交校验
This commit is contained in:
parent
1fd8b042e5
commit
0488315433
@ -13,6 +13,7 @@ import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -27,47 +28,49 @@ import static com.yem.wm.es.contractamtlist.util.FunUtil.getShipBills;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class ExportPresentSubmitValidator extends AbstractValidator {
|
public class ExportPresentSubmitValidator extends AbstractValidator {
|
||||||
// @Override
|
|
||||||
// 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)) {
|
|
||||||
//
|
|
||||||
// if ("A".equals(isladingbill)) {
|
|
||||||
// prePayAmtValidator(data, orders, detailC, receiveC);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate()
|
public void validate() {
|
||||||
{
|
|
||||||
ExtendedDataEntity[] dataEntities = this.getDataEntities();
|
ExtendedDataEntity[] dataEntities = this.getDataEntities();
|
||||||
for (ExtendedDataEntity data : dataEntities) {
|
for (ExtendedDataEntity data : dataEntities) {
|
||||||
DynamicObject dataEntity = data.getDataEntity();
|
DynamicObject dataEntity = data.getDataEntity();
|
||||||
// 款项类型
|
// 款项类型
|
||||||
String paymenttype = dataEntity.getString("yem_paymenttype");
|
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)});
|
||||||
|
DynamicObjectCollection payColl = dataEntity.getDynamicObjectCollection("yem_es_exportpre_erw");
|
||||||
|
Map<Object, Boolean> isVail = new HashMap<>();
|
||||||
|
for (Map.Entry<Object, DynamicObject> entry : orders.entrySet()) {
|
||||||
|
DynamicObject order = entry.getValue();
|
||||||
|
String billno = order.getString("billno");
|
||||||
|
for (DynamicObject pay : payColl) {
|
||||||
|
String contractnumC = pay.getString("yem_contractnum_c");
|
||||||
|
DynamicObject payment = pay.getDynamicObject("yem_payment");
|
||||||
|
String isladingbill = "B";
|
||||||
|
if (payment.containsProperty("yem_isladingbill")) {
|
||||||
|
payment = BusinessDataServiceHelper.loadSingleFromCache(payment.getPkValue(), payment.getDataEntityType().getName());
|
||||||
|
isladingbill = payment.getString("yem_isladingbill");
|
||||||
|
}
|
||||||
|
if (billno.equals(contractnumC) && "A".equals(isladingbill)) {
|
||||||
|
isVail.put(entry.getKey(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ("A".equals(paymenttype)) {
|
if ("A".equals(paymenttype)) {
|
||||||
arrearsVerification(dataEntity, data);
|
|
||||||
|
prePayAmtValidator(data, orders, isVail, receiveC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,72 +85,83 @@ public class ExportPresentSubmitValidator extends AbstractValidator {
|
|||||||
* 3、未件提单并且正常款项:判断合同是否认领完成
|
* 3、未件提单并且正常款项:判断合同是否认领完成
|
||||||
* 4、未件提单并且特殊款项:判断合同是否认领完成
|
* 4、未件提单并且特殊款项:判断合同是否认领完成
|
||||||
* 3或4通过不进行后续校验
|
* 3或4通过不进行后续校验
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
// private void prePayAmtValidator(ExtendedDataEntity data, Map<Object, DynamicObject> orders, DynamicObjectCollection detailC, DynamicObjectCollection receiveC) {
|
private void prePayAmtValidator(ExtendedDataEntity data, Map<Object, DynamicObject> orders, Map<Object, Boolean> isVail, DynamicObjectCollection receiveC) {
|
||||||
// StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
// for (Map.Entry<Object, DynamicObject> entry : orders.entrySet()) {
|
for (Map.Entry<Object, DynamicObject> entry : orders.entrySet()) {
|
||||||
// DynamicObject order = entry.getValue();
|
boolean isDoVail = false;
|
||||||
// BigDecimal shipPreRapRate = PaymentControlUtil.getShipPreRapRate(order);
|
if (isVail.containsKey(entry.getKey())) {
|
||||||
// BigDecimal procPreRapRate = PaymentControlUtil.getProcPreRapRate(order);
|
isDoVail = isVail.get(entry.getKey());
|
||||||
// // 该合同是否包含预付
|
}
|
||||||
// boolean isPre = shipPreRapRate.add(procPreRapRate).compareTo(BigDecimal.ZERO) > 0;
|
|
||||||
// DynamicObjectCollection collection = order.getDynamicObjectCollection("yem_es_salescontrac_s");
|
DynamicObject order = entry.getValue();
|
||||||
// boolean isSpecialRapStyle = false;
|
BigDecimal shipPreRapRate = PaymentControlUtil.getShipPreRapRate(order);
|
||||||
// for (DynamicObject d : collection) {
|
BigDecimal procPreRapRate = PaymentControlUtil.getProcPreRapRate(order);
|
||||||
// DynamicObject rapstyle = d.getDynamicObject("yem_rapstyle_c");
|
// 该合同是否包含预付
|
||||||
// if (YEM.isNotEmpty(rapstyle) && "D/A JSFS08 L/C OA D/A".contains(rapstyle.getString("number"))) {
|
boolean isPre = shipPreRapRate.add(procPreRapRate).compareTo(BigDecimal.ZERO) > 0;
|
||||||
// isSpecialRapStyle = true;
|
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"))) {
|
||||||
// BigDecimal offeramount = order.getBigDecimal("yem_offeramount");
|
isSpecialRapStyle = true;
|
||||||
// String billno = order.getString("billno");
|
}
|
||||||
// // 合同已认领金额
|
}
|
||||||
// BigDecimal climeAmt = PaymentControlUtil.getContractClimeAmt(order, "");
|
|
||||||
// // 只判断预付款是否认领完成
|
// 合同金额
|
||||||
// if (isSpecialRapStyle && isPre) {
|
BigDecimal offeramount = order.getBigDecimal("yem_offeramount");
|
||||||
// BigDecimal climeAmtShip = PaymentControlUtil.getContractClimeAmt(order, "D");
|
String billno = order.getString("billno");
|
||||||
// BigDecimal climeAmtProc = PaymentControlUtil.getContractClimeAmt(order, "E");
|
// 合同已认领金额
|
||||||
//
|
BigDecimal climeAmt = PaymentControlUtil.getContractClimeAmt(order, "");
|
||||||
// BigDecimal climePreAmt = climeAmtShip.add(climeAmtProc);
|
// 只判断预付款是否认领完成
|
||||||
//
|
if (!isDoVail) {
|
||||||
// BigDecimal shipAmt = PaymentControlUtil.getAdvancePayment(shipPreRapRate, offeramount);
|
if (isSpecialRapStyle) {
|
||||||
// BigDecimal procAmt = PaymentControlUtil.getAdvancePayment(procPreRapRate, offeramount);
|
if (climeAmt.compareTo(offeramount) < 0) {
|
||||||
//
|
sb.append(String.format("合同 [ %s ] ,合同金额 [ %s ], 合同已认领金额合计 [ %s ],合同未认领完成,请全部认领后提交单据!(L/C、OA、DP、DA)",
|
||||||
// BigDecimal orderPreAmt = shipAmt.add(procAmt);
|
billno,
|
||||||
//
|
offeramount.setScale(4, RoundingMode.HALF_UP).toPlainString(),
|
||||||
// if (climePreAmt.compareTo(orderPreAmt) < 0) {
|
climeAmt.setScale(4, RoundingMode.HALF_UP).toPlainString())).append("\r\n");
|
||||||
// sb.append(String.format("合同 [ %s ] ,合同预收金额 [ %s ], 合同预收已认领金额合计 [ %s ],合同预收款未认领完成,请核对后提交!(L/C、OA、DP、DA)",
|
}
|
||||||
// billno,
|
|
||||||
// orderPreAmt.setScale(4, RoundingMode.HALF_UP).toPlainString(),
|
} else {
|
||||||
// climePreAmt.setScale(4, RoundingMode.HALF_UP).toPlainString())).append("\r\n");
|
|
||||||
// }
|
BigDecimal climeAmtShip = PaymentControlUtil.getContractClimeAmt(order, "D");
|
||||||
// } else {
|
BigDecimal climeAmtProc = PaymentControlUtil.getContractClimeAmt(order, "E");
|
||||||
// if (climeAmt.compareTo(offeramount) < 0) {
|
|
||||||
// boolean passed = arrearsVerification(data.getDataEntity(), data, receiveC);
|
BigDecimal climePreAmt = climeAmtShip.add(climeAmtProc);
|
||||||
// if (!passed) {
|
|
||||||
// sb.append(String.format("合同 [ %s ] ,合同金额 [ %s ], 合同已认领金额合计 [ %s ],合同未认领完成,请核对后提交!",
|
BigDecimal shipAmt = PaymentControlUtil.getAdvancePayment(shipPreRapRate, offeramount);
|
||||||
// billno,
|
BigDecimal procAmt = PaymentControlUtil.getAdvancePayment(procPreRapRate, offeramount);
|
||||||
// offeramount.setScale(4, RoundingMode.HALF_UP).toPlainString(),
|
|
||||||
// climeAmt.setScale(4, RoundingMode.HALF_UP).toPlainString())).append("\r\n");
|
BigDecimal orderPreAmt = shipAmt.add(procAmt);
|
||||||
// }
|
|
||||||
// }
|
if (climePreAmt.compareTo(orderPreAmt) < 0) {
|
||||||
// }
|
sb.append(String.format("合同 [ %s ] ,合同预收金额 [ %s ], 合同预收已认领金额合计 [ %s ],合同预收款未认领完成,请核对后提交!",
|
||||||
// }
|
billno,
|
||||||
//
|
orderPreAmt.setScale(4, RoundingMode.HALF_UP).toPlainString(),
|
||||||
// if (sb.length() > 0) {
|
climePreAmt.setScale(4, RoundingMode.HALF_UP).toPlainString())).append("\r\n");
|
||||||
// this.addErrorMessage(data, String.valueOf(sb));
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
|
} else {
|
||||||
|
if (climeAmt.compareTo(offeramount) < 0) {
|
||||||
|
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 void arrearsVerification(DynamicObject dataEntity, ExtendedDataEntity data)
|
private boolean arrearsVerification(DynamicObject dataEntity, ExtendedDataEntity data, DynamicObjectCollection collection) {
|
||||||
{
|
|
||||||
DynamicObjectCollection collection = dataEntity.getDynamicObjectCollection("yem_es_exportpre_erf");
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (DynamicObject dynamicObject : collection) {
|
for (DynamicObject dynamicObject : collection) {
|
||||||
DynamicObject saleOrder = dynamicObject.getDynamicObject("yem_saleorder");
|
DynamicObject saleOrder = dynamicObject.getDynamicObject("yem_saleorder");
|
||||||
@ -171,5 +185,7 @@ public class ExportPresentSubmitValidator extends AbstractValidator {
|
|||||||
if (sb.length() > 0) {
|
if (sb.length() > 0) {
|
||||||
this.addErrorMessage(data, String.valueOf(sb));
|
this.addErrorMessage(data, String.valueOf(sb));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return sb.length() == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user