feat:发货联系书款项信息
This commit is contained in:
parent
752f50ebc3
commit
ddb6ffd8b7
@ -1,7 +1,10 @@
|
|||||||
package com.yem.wm.es.contactbook.op;
|
package com.yem.wm.es.contactbook.op;
|
||||||
|
|
||||||
import com.yem.wm.es.contactbook.validator.ContactBookSaveValidator;
|
import com.yem.wm.es.contactbook.validator.ContactBookSaveValidator;
|
||||||
|
import com.yem.wm.es.shippingdetails.util.PaymentControlUtil;
|
||||||
|
import com.yem.wm.utils.YEM;
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
||||||
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
||||||
@ -12,11 +15,17 @@ import kd.bos.orm.query.QFilter;
|
|||||||
import kd.bos.servicehelper.AttachmentServiceHelper;
|
import kd.bos.servicehelper.AttachmentServiceHelper;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.List;
|
import java.math.BigDecimal;
|
||||||
import java.util.Map;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.yem.wm.es.contractamtlist.util.FunUtil.*;
|
||||||
|
import static com.yem.wm.es.shippingdetails.util.PaymentControlUtil.calcIOUAmount;
|
||||||
|
import static com.yem.wm.fm.gathering.dynamic.GatheringClaimFormPlugin.getPercentagePeriod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Classname ContactBookSaveOp
|
* @Classname ContactBookSaveOp
|
||||||
* @Description TODO
|
* @Description TODO
|
||||||
@ -26,16 +35,15 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class ContactBookSaveOp extends AbstractOperationServicePlugIn
|
public class ContactBookSaveOp extends AbstractOperationServicePlugIn
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ContactBookSaveOp.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPreparePropertys(PreparePropertysEventArgs e)
|
public void onPreparePropertys(PreparePropertysEventArgs e)
|
||||||
{
|
{
|
||||||
super.onPreparePropertys(e);
|
super.onPreparePropertys(e);
|
||||||
List<String> keys = e.getFieldKeys();
|
List<String> keys = e.getFieldKeys();
|
||||||
keys.add("yem_attachmentpanelap2");
|
keys.addAll(this.billEntityType.getAllFields().keySet());
|
||||||
keys.add("yem_attachmentpanelap3");
|
|
||||||
keys.add("yem_attachmentpanelap");
|
|
||||||
keys.add("billno");
|
|
||||||
keys.add("id");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -57,17 +65,19 @@ public class ContactBookSaveOp extends AbstractOperationServicePlugIn
|
|||||||
String operationKey = e.getOperationKey();
|
String operationKey = e.getOperationKey();
|
||||||
if ("save".equals(operationKey)) {
|
if ("save".equals(operationKey)) {
|
||||||
for (DynamicObject dataEntity : dataEntities) {
|
for (DynamicObject dataEntity : dataEntities) {
|
||||||
String billno = dataEntity.getString("billno");
|
// String billno = dataEntity.getString("billno");
|
||||||
|
|
||||||
QFilter qFilter = new QFilter("billno", QCP.equals, billno);
|
// QFilter qFilter = new QFilter("billno", QCP.equals, billno);
|
||||||
DynamicObject[] load = BusinessDataServiceHelper.load("yem_es_storagetrans", "id, billno", qFilter.toArray());
|
// DynamicObject[] load = BusinessDataServiceHelper.load("yem_es_storagetrans", "id, billno", qFilter.toArray());
|
||||||
|
|
||||||
for (DynamicObject dynamicObject : load) {
|
// for (DynamicObject dynamicObject : load) {
|
||||||
|
|
||||||
AttachmentServiceHelper.remove("yem_es_storagetrans", dynamicObject.getLong("id"));
|
// AttachmentServiceHelper.remove("yem_es_storagetrans", dynamicObject.getLong("id"));
|
||||||
|
//
|
||||||
|
// uploadAttachmentPanel(dataEntity, dynamicObject);
|
||||||
|
// }
|
||||||
|
|
||||||
uploadAttachmentPanel(dataEntity, dynamicObject);
|
updatePaymentControlStatus(dataEntity);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 反写关联发货联系数量
|
// 反写关联发货联系数量
|
||||||
@ -144,4 +154,109 @@ public class ContactBookSaveOp extends AbstractOperationServicePlugIn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param dataEntity
|
||||||
|
*/
|
||||||
|
private void updatePaymentControlStatus(DynamicObject dataEntity) {
|
||||||
|
DynamicObjectCollection c = dataEntity.getDynamicObjectCollection("yem_es_materialinfo");
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
|
||||||
|
for (DynamicObject d : c) {
|
||||||
|
String shipmentnumbers_m = d.getString("yem_shipmentnumbers_m");
|
||||||
|
String contractnumbers_m = d.getString("yem_contractnumbers_m");
|
||||||
|
if (YEM.isNotEmpty(shipmentnumbers_m) && YEM.isNotEmpty(contractnumbers_m)) {
|
||||||
|
map.put(contractnumbers_m, shipmentnumbers_m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Boolean> proc = new ArrayList<>();
|
||||||
|
List<Boolean> ship = new ArrayList<>();
|
||||||
|
List<Boolean> last = new ArrayList<>();
|
||||||
|
int iou = 0;
|
||||||
|
StringBuilder debugMsg = new StringBuilder();
|
||||||
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||||
|
|
||||||
|
boolean isProcClaimFinish = false;//下单预收金额是否认领完成
|
||||||
|
boolean isShipClaimFinish = false;//本次发运 发运预收认领是否完成
|
||||||
|
boolean isFinalClaimFinish = false;//尾款是否认领完成
|
||||||
|
|
||||||
|
String salesorder_no = entry.getKey();
|
||||||
|
String ship_no = entry.getValue();
|
||||||
|
|
||||||
|
logger.info("发货联系书保存: salesorder_no:{} , ship_no:{}", salesorder_no, ship_no);
|
||||||
|
debugMsg.append(String.format("发货联系书保存: salesorder_no:%s , ship_no:%s", salesorder_no, ship_no)).append("\n");
|
||||||
|
DynamicObject saleOrder = BusinessDataServiceHelper.loadSingle("yem_es_salesorder", new QFilter[]{new QFilter("billno", "=", salesorder_no)});
|
||||||
|
DynamicObject shipDetail = BusinessDataServiceHelper.loadSingle("yem_shippingdetails", new QFilter[]{new QFilter("billno", "=", ship_no)});
|
||||||
|
|
||||||
|
DynamicObject[] shipBills = getShipBills(saleOrder, shipDetail, "A");//出运
|
||||||
|
DynamicObject[] payBills = getPayBills(saleOrder, shipDetail, "B");//收款单
|
||||||
|
|
||||||
|
BigDecimal procPreRapRate = PaymentControlUtil.getProcPreRapRate(saleOrder);//生产预收汇比例
|
||||||
|
BigDecimal shipPreRapRate = PaymentControlUtil.getShipPreRapRate(saleOrder);//发货预收汇比例
|
||||||
|
|
||||||
|
logger.info("下单预收比例:{},发货预收比例:{}", procPreRapRate, shipPreRapRate);
|
||||||
|
debugMsg.append(String.format("下单预收比例:%s,发货预收比例::%s", procPreRapRate, shipPreRapRate)).append("\n");
|
||||||
|
|
||||||
|
BigDecimal procClaimAnt = PaymentControlUtil.getPreCollection(saleOrder, payBills, "D");//下单已认领金额
|
||||||
|
BigDecimal offeramount = saleOrder.getBigDecimal("yem_offeramount");//合同价格条款金额
|
||||||
|
BigDecimal advancePayment = PaymentControlUtil.getAdvancePayment(offeramount, procPreRapRate);
|
||||||
|
|
||||||
|
logger.info("下单已认领金额:{}, 下单预收金额:{}", procClaimAnt, advancePayment);
|
||||||
|
debugMsg.append(String.format("下单已认领金额:%s, 下单预收金额:%s", procClaimAnt, advancePayment)).append("\n");
|
||||||
|
// 下单已认领金额 >= 下单预收金额
|
||||||
|
if (procClaimAnt.compareTo(advancePayment) >= 0) {
|
||||||
|
isProcClaimFinish = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 本次发运已认领金额 >= 发运预收金额
|
||||||
|
BigDecimal thisShipIOUAmt = PaymentControlUtil.getThisRealityAmt(saleOrder, shipBills, payBills, shipDetail);//本次发运欠款金额,本次发运应认领金额
|
||||||
|
thisShipIOUAmt = thisShipIOUAmt.abs();
|
||||||
|
BigDecimal shipClaimAmt = PaymentControlUtil.getAmountClaimed(new DynamicObject[]{shipDetail}, "E");//本次发运已认领金额
|
||||||
|
logger.info("本次发运已认领金额:{},发运预收金额:{}", shipClaimAmt, thisShipIOUAmt);
|
||||||
|
debugMsg.append(String.format("本次发运已认领金额:%s, 发运预收金额:%s", shipClaimAmt, thisShipIOUAmt)).append("\n");
|
||||||
|
if (shipClaimAmt.compareTo(thisShipIOUAmt) >= 0) {
|
||||||
|
isShipClaimFinish = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal lastRate = getPercentagePeriod(shipPreRapRate, procPreRapRate);//尾款比例
|
||||||
|
logger.info("尾款比例:{}", lastRate);
|
||||||
|
debugMsg.append(String.format("尾款比例:%s", lastRate)).append("\n");
|
||||||
|
BigDecimal amount = shipDetail.getBigDecimal("yem_offeramount");//发运 价格条款金额
|
||||||
|
BigDecimal periodrefundamt = lastRate.multiply(amount);//尾款 应收金额
|
||||||
|
BigDecimal shipClaimAmt_periodrefund = PaymentControlUtil.getAmountClaimed(new DynamicObject[]{shipDetail}, "F");//本次发运已认领金额_尾款
|
||||||
|
logger.info("尾款认领金额:{}, 尾款 应收金额:{}", shipClaimAmt_periodrefund, periodrefundamt);
|
||||||
|
debugMsg.append(String.format("尾款认领金额:%s, 尾款 应收金额:%s", shipClaimAmt_periodrefund, periodrefundamt)).append("\n");
|
||||||
|
// 尾款认领金额 >= 尾款 应收金额
|
||||||
|
if (shipClaimAmt_periodrefund.compareTo(periodrefundamt) >= 0) {
|
||||||
|
isFinalClaimFinish = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
proc.add(isProcClaimFinish);
|
||||||
|
ship.add(isShipClaimFinish);
|
||||||
|
last.add(isFinalClaimFinish);
|
||||||
|
|
||||||
|
DynamicObject[] tradeapps = BusinessDataServiceHelper.load("yem_im_tradeapp", "id, billno", new QFilter[]{new QFilter("yem_im_tradeapp_em.yem_shippingnumber", QCP.equals, shipDetail.getString("billno")), new QFilter("billstatus", QCP.equals, "C")});
|
||||||
|
iou = iou + tradeapps.length;
|
||||||
|
logger.info("欠条个数:{}", tradeapps.length);
|
||||||
|
logger.info("欠条个数(累计):{}", iou);
|
||||||
|
debugMsg.append(String.format("欠条个数:%s", tradeapps.length)).append("\n");
|
||||||
|
debugMsg.append(String.format("欠条个数(累计):%s", iou)).append("\n");
|
||||||
|
debugMsg.append("=============split=============").append("\n");
|
||||||
|
}
|
||||||
|
if (!proc.contains(false) && !ship.contains(false) && !last.contains(false)) {
|
||||||
|
//全款完成
|
||||||
|
dataEntity.set("yem_paystatus", "A");
|
||||||
|
} else if (!proc.contains(false) && !ship.contains(false)) {
|
||||||
|
//预收完成
|
||||||
|
dataEntity.set("yem_paystatus", "B");
|
||||||
|
} else if (iou > 0) {
|
||||||
|
//欠条到位
|
||||||
|
dataEntity.set("yem_paystatus", "C");
|
||||||
|
} else {
|
||||||
|
dataEntity.set("yem_paystatus", null);
|
||||||
|
}
|
||||||
|
dataEntity.set("yem_debugmsg", debugMsg.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -924,7 +924,7 @@ public class GatheringClaimFormPlugin extends AbstractFormPlugin implements RowC
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private BigDecimal getPercentagePeriod(BigDecimal shipPreRapRate, BigDecimal procPreRapRate) {
|
public static BigDecimal getPercentagePeriod(BigDecimal shipPreRapRate, BigDecimal procPreRapRate) {
|
||||||
return BigDecimal.ONE.subtract(procPreRapRate.multiply(BigDecimal.valueOf(0.01))).subtract(shipPreRapRate.multiply(BigDecimal.valueOf(0.01)));
|
return BigDecimal.ONE.subtract(procPreRapRate.multiply(BigDecimal.valueOf(0.01))).subtract(shipPreRapRate.multiply(BigDecimal.valueOf(0.01)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user