merger:信保回填相关

This commit is contained in:
zzs 2024-12-18 14:19:53 +08:00
parent 6a717fa9f8
commit e3de4132ff
3 changed files with 149 additions and 10 deletions

View File

@ -293,7 +293,10 @@ public class TotalUtil {
if (YEM.isNotEmpty(customer) && YEM.isNotEmpty(method) && YEM.isNotEmpty(company)) {
String selectfields = DynamicObjectUtil.getSelectfields("yem_im_csrcreditline", false);
selectfields = DynamicObjectUtil.getEntrySelectfields(selectfields, "yem_im_csrcreditline", "yem_im_info", false);
QFilter qFilter = new QFilter("yem_customer", QCP.equals, customer.getPkValue());
if (!customer.containsProperty("yem_customer")) {
customer = BusinessDataServiceHelper.loadSingleFromCache(customer.getPkValue(), customer.getDynamicObjectType().getName());
}
QFilter qFilter = new QFilter("yem_customer.yem_customer", QCP.equals, customer.getString("yem_customer"));
qFilter.and(new QFilter("yem_payment.id", QCP.equals, method.getPkValue()));
// qFilter.and(new QFilter("org", QCP.equals, company.getPkValue()));
qFilter.and(new QFilter("billstatus", QCP.equals, "C"));

View File

@ -1,9 +1,13 @@
package com.yem.wm.es.storagetrans.dynamic;
import com.yem.rf.utils.RFUtils;
import com.yem.wm.es.Util.CreditBackFillUtils;
import com.yem.wm.es.Util.TotalUtil;
import com.yem.wm.es.shippingdetails.util.PaymentControlUtil;
import com.yem.wm.utils.CalendarUtils;
import com.yem.wm.utils.RptUtil;
import com.yem.wm.utils.YEM;
import kd.bos.algo.DataSet;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.datamodel.IDataModel;
@ -13,17 +17,17 @@ import kd.bos.form.IFormView;
import kd.bos.form.control.Control;
import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.orm.ORM;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.tmc.cfm.formplugin.bd.PayMentbyInstalments;
import org.apache.commons.compress.utils.Lists;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.EventObject;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
/**
* @author xwudd
@ -45,6 +49,7 @@ public class CreditBackFillEdit extends AbstractFormPlugin {
model.setValue("yem_storagetransno", parentModel.getValue("billno"));//储运托单号
model.setValue("yem_currency", parentModel.getValue("yem_creditcurr"));//信保币别
model.setValue("yem_settlementcurr", parentModel.getValue("yem_currency"));//结算币别
model.setValue("yem_currencybase", parentModel.getValue("yem_currencybase"));//本位币
model.setValue("yem_actulpreamount", parentModel.getValue("yem_actualsinkamount"));//实际收汇金额汇总
model.setValue("yem_actulpreamountbase", parentModel.getValue("yem_actualsinkamountba"));//实际收汇本位币金额汇总
@ -115,6 +120,10 @@ public class CreditBackFillEdit extends AbstractFormPlugin {
String key = control.getKey();
if ("btnok".equals(key)) {
if (!beforeOkOperationValidator()) {
return;
}
IFormView view = this.getView();
IDataModel model = this.getModel();
DynamicObject dataEntity = model.getDataEntity(true);
@ -151,14 +160,15 @@ public class CreditBackFillEdit extends AbstractFormPlugin {
parentModel.setValue("yem_creditremark", subMap.get("creditRemark"), i);//信保备注
parentModel.setValue("yem_creditquotation", subMap.get("yem_creditquotation"), i);
parentModel.setValue("yem_sinosurerate_cd", subMap.get("yem_sinosurerate_cd"));
parentModel.setValue("yem_term_cd", subMap.get("yem_term_cd"));
parentModel.setValue("yem_sinosurerate_cd", subMap.get("yem_sinosurerate_cd"), i);
parentModel.setValue("yem_term_cd", subMap.get("yem_term_cd"), i);
// parentModel.setValue("yem_year_e", subMap.get("year"));
dynamicObject.set("yem_year_e", subMap.get("year"));
parentModel.setValue("yem_creditstatus_e", subMap.get("creditstatus"));
parentModel.setValue("yem_creditstatus_e", subMap.get("creditstatus"), i);
parentModel.setValue("yem_insuranceamt_cd", subMap.get("yem_premium"));//保险费
parentModel.setValue("yem_insuranceamt_cd", subMap.get("yem_premium"), i);//保险费
parentModel.setValue("yem_contractpayamt", subMap.get("yem_contractpayamt"), i);//合同回款金额
}
}
subEntryBackFill();
@ -172,6 +182,107 @@ public class CreditBackFillEdit extends AbstractFormPlugin {
}
}
/**
*
* 信保回填弹窗界面业务手动维护当前收款币别对应的合同回款币别金额点击确认时合同回款金额必填
* <br/>
* 信保回填弹窗界面确认时判断当前合同下的合同回款金额汇总值  是否超出收款单认领到该合同尾款的收款认领金额汇总值如果超出不允许通过并提示合同号***合同回款总金额***尾款账期认领总金额***已超额请认领完成后在操作信保回款否则可以通过
* <br/>
*
* @link <a href="https://docs.qq.com/sheet/DTEluRXJXbW5lY0xD?tab=000001">文档</>
*
* @return Boolean
*/
private boolean beforeOkOperationValidator() {
IDataModel model = this.getModel();
IFormView view = this.getView();
IFormView parentView = view.getParentView();
IDataModel parentModel = parentView.getModel();
DynamicObject dataEntity = model.getDataEntity(true);
StringBuilder sb = new StringBuilder();
DynamicObjectCollection collection = dataEntity.getDynamicObjectCollection("yem_creditentry");
// 当前订舱合同回款金额
Map<String, BigDecimal> contractPayAmtMap = new HashMap<>();
for (DynamicObject d : collection) {
int idx = collection.indexOf(d);
BigDecimal contractpayamt = d.getBigDecimal("yem_contractpayamt");
String salecontractno = d.getString("yem_salecontractno");
if (contractPayAmtMap.containsKey(salecontractno)) {
BigDecimal decimal = contractPayAmtMap.get(salecontractno);
decimal = decimal.add(contractpayamt);
contractPayAmtMap.put(salecontractno, decimal);
} else {
contractPayAmtMap.put(salecontractno, contractpayamt);
}
if (contractpayamt.compareTo(BigDecimal.ZERO) <= 0) {
sb.append(String.format("请填写明细信息第 %s 行,合同回款金额!!", idx + 1)).append("\n\r");
}
}
if (sb.length() > 0) {
view.showErrorNotification(sb.toString());
return false;
}
QFilter qFilter = RFUtils.getBaseQFilter();
// 当前单涉及需要校验的合同
Set<String> salesorder = new HashSet<>();
for (DynamicObject d : collection) {
salesorder.add(d.getString("yem_salecontractno"));
}
qFilter.and("yem_creditdetail.yem_salecontractno.billno", "in", salesorder);
qFilter.and("billno", "not in", parentModel.getValue("billno"));
ArrayList<String> selectfileds = Lists.newArrayList();
selectfileds.add("yem_creditdetail.yem_salecontractno.billno yem_salecontractno");//外销合同号
selectfileds.add("yem_creditdetail.yem_contractpayamt yem_contractpayamt");//合同回款金额
DataSet st = ORM.create().queryDataSet("com.yem.wm.es.storagetrans.dynamic.CreditBackFillEdit.beforeOkOperationValidator", "yem_es_storagetrans", String.join(",", selectfileds), qFilter.toArray());
st = st.groupBy(new String[]{"yem_salecontractno"}).sum("yem_contractpayamt").finish();
DynamicObjectCollection dataSetCollection = ORM.create().toPlainDynamicObjectCollection(st);
// 历史除去本单订舱合同回款金额 + 当前订舱合同回款金额
for (DynamicObject setObj : dataSetCollection) {
String salecontractno = setObj.getString("yem_salecontractno");
BigDecimal contractpayamt = setObj.getBigDecimal("yem_contractpayamt");
if (contractPayAmtMap.containsKey(salecontractno)) {
BigDecimal decimal = contractPayAmtMap.get(salecontractno);
decimal = decimal.add(contractpayamt);
contractPayAmtMap.put(salecontractno, decimal);
} else {
contractPayAmtMap.put(salecontractno, contractpayamt);
}
}
StringBuilder amtSb = new StringBuilder();
DynamicObject[] load = BusinessDataServiceHelper.load("yem_es_salesorder", "id, billno", new QFilter[]{new QFilter("billno", "in", salesorder)});
for (DynamicObject object : load) {
for (Map.Entry<String, BigDecimal> map : contractPayAmtMap.entrySet()) {
BigDecimal amt = map.getValue();
String billno = map.getKey();
if (object.getString("billno").equals(billno)) {
BigDecimal contractClimeAmt = PaymentControlUtil.getContractClimeAmt(object, "F");
if (amt.compareTo(contractClimeAmt) > 0) {
amtSb.append(String.format("合同号:%s合同回款总金额%s元尾款账期认领总金额%s元已超额请认领完成后在操作信保回款。"
, billno
, amt.setScale(4, RoundingMode.HALF_UP).toPlainString()
, contractClimeAmt.setScale(4, RoundingMode.HALF_UP).toPlainString()
)).append("\n\r");
}
}
}
}
if (amtSb.length() > 0) {
view.showErrorNotification(amtSb.toString());
return false;
}
return true;
}
/**
* 缓存分录数据
*
@ -237,6 +348,8 @@ public class CreditBackFillEdit extends AbstractFormPlugin {
map.put("yem_premium", model.getValue("yem_premium", i));//保险费
map.put("yem_contractpayamt", model.getValue("yem_contractpayamt", i));//合同回款金额
Long pkValue = dynamicObject.getLong("yem_parententryid");
collectionMap.put(pkValue, map);
}
@ -308,6 +421,7 @@ public class CreditBackFillEdit extends AbstractFormPlugin {
dynamicObject.set("yem_creditstatus_e", map.get("creditstatus"));
dynamicObject.set("yem_premium", map.get("yem_premium"));
dynamicObject.set("yem_contractpayamt", map.get("yem_contractpayamt"));
}
}
SaveServiceHelper.save(new DynamicObject[]{csrCreditLine});
@ -366,6 +480,7 @@ public class CreditBackFillEdit extends AbstractFormPlugin {
addNew.set("yem_crenote", crecollection.getString("yem_crenote"));//收款备注
addNew.set("yem_crecollecurrency", crecollection.getDynamicObject("yem_crecollecurrency"));//收款币别
addNew.set("yem_crecollecamt", crecollection.getBigDecimal("yem_crecollecamt"));//收款金额
addNew.set("yem_contractpayamt_e", crecollection.getBigDecimal("yem_contractpayamt_e"));
}
}
} else {
@ -418,6 +533,7 @@ public class CreditBackFillEdit extends AbstractFormPlugin {
parentAddNer.set("yem_crenote", crecollection.getString("yem_crenote"));//收款备注
parentAddNer.set("yem_crecollecurrency", crecollection.getDynamicObject("yem_crecollecurrency"));//收款币别
parentAddNer.set("yem_crecollecamt", crecollection.getBigDecimal("yem_crecollecamt"));//收款金额
parentAddNer.set("yem_contractpayamt_e", crecollection.getBoolean("yem_contractpayamt_e"));//合同回款金额
}
}
BigDecimal creactualamt = BigDecimal.ZERO;// 实际收汇金额
@ -501,6 +617,21 @@ public class CreditBackFillEdit extends AbstractFormPlugin {
this.getModel().setValue("yem_creactuallocamt", creactualamt.multiply(crerate), row);
// this.getView().updateView();
}
// 汇总子分录合同回款金额到分录
if ("yem_contractpayamt_e".equals(key)) {
DynamicObjectCollection collection = dataEntity.getDynamicObjectCollection("yem_creditentry");
for (DynamicObject entry : collection) {
int idx = collection.indexOf(entry);
DynamicObjectCollection subEntry = entry.getDynamicObjectCollection("yem_crecollection");
BigDecimal calc = BigDecimal.ZERO;
for (DynamicObject subObj : subEntry) {
BigDecimal contractpayamt_e = subObj.getBigDecimal("yem_contractpayamt_e");
calc = calc.add(contractpayamt_e);
}
model.setValue("yem_contractpayamt", calc, idx);
}
}
}
private void carryCreditInsuranceRate(int rowIndex) {

View File

@ -30,7 +30,12 @@ public class CsrCreditSubmitLineValidator extends AbstractValidator {
String swiftcode = dataEntity.getString("yem_swiftcode");
Date yearBegin = getYearBegin(bizDate);
Date yearLast = getYearLast(bizDate);
QFilter qFilter = new QFilter("yem_customer", QCP.equals, customer.getPkValue());
if (!customer.containsProperty("yem_customer")) {
customer = BusinessDataServiceHelper.loadSingleFromCache(customer.getPkValue(), customer.getDynamicObjectType().getName());
}
QFilter qFilter = new QFilter("yem_customer.yem_customer", QCP.equals, customer.getString("yem_customer"));
// QFilter qFilter = new QFilter("yem_customer", QCP.equals, customer.getPkValue());
// qFilter.and(new QFilter("org", QCP.equals, org.getPkValue()));
qFilter.and(new QFilter("yem_bizdate", QCP.large_than, yearBegin));
qFilter.and(new QFilter("yem_bizdate", QCP.less_equals, yearLast));