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.RoundingMode;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -27,47 +28,49 @@ import static com.yem.wm.es.contractamtlist.util.FunUtil.getShipBills;
|
||||
*/
|
||||
|
||||
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
|
||||
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)});
|
||||
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)) {
|
||||
arrearsVerification(dataEntity, data);
|
||||
|
||||
prePayAmtValidator(data, orders, isVail, receiveC);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -82,72 +85,83 @@ public class ExportPresentSubmitValidator extends AbstractValidator {
|
||||
* 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 void prePayAmtValidator(ExtendedDataEntity data, Map<Object, DynamicObject> orders, Map<Object, Boolean> isVail, DynamicObjectCollection receiveC) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Map.Entry<Object, DynamicObject> entry : orders.entrySet()) {
|
||||
boolean isDoVail = false;
|
||||
if (isVail.containsKey(entry.getKey())) {
|
||||
isDoVail = isVail.get(entry.getKey());
|
||||
}
|
||||
|
||||
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 (!isDoVail) {
|
||||
if (isSpecialRapStyle) {
|
||||
if (climeAmt.compareTo(offeramount) < 0) {
|
||||
sb.append(String.format("合同 [ %s ] ,合同金额 [ %s ], 合同已认领金额合计 [ %s ],合同未认领完成,请全部认领后提交单据!(L/C、OA、DP、DA)",
|
||||
billno,
|
||||
offeramount.setScale(4, RoundingMode.HALF_UP).toPlainString(),
|
||||
climeAmt.setScale(4, RoundingMode.HALF_UP).toPlainString())).append("\r\n");
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
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 ],合同预收款未认领完成,请核对后提交!",
|
||||
billno,
|
||||
orderPreAmt.setScale(4, RoundingMode.HALF_UP).toPlainString(),
|
||||
climePreAmt.setScale(4, RoundingMode.HALF_UP).toPlainString())).append("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
} 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)
|
||||
{
|
||||
DynamicObjectCollection collection = dataEntity.getDynamicObjectCollection("yem_es_exportpre_erf");
|
||||
private boolean arrearsVerification(DynamicObject dataEntity, ExtendedDataEntity data, DynamicObjectCollection collection) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (DynamicObject dynamicObject : collection) {
|
||||
DynamicObject saleOrder = dynamicObject.getDynamicObject("yem_saleorder");
|
||||
@ -171,5 +185,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