1.修改贷记单提交后获取上次贷记单号节点
This commit is contained in:
parent
9d395b1f7b
commit
676b128aa6
@ -4,9 +4,12 @@ import com.yem.wm.im.debcrednotenew.validator.DebCredNewAuditValidatorOp;
|
||||
import com.yem.wm.utils.DynamicObjectUtil;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
||||
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
||||
import kd.bos.entity.plugin.args.BeforeOperationArgs;
|
||||
import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
|
||||
import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
@ -43,102 +46,119 @@ public class DebCredNewSubmitOp extends AbstractOperationServicePlugIn {
|
||||
public void endOperationTransaction(EndOperationTransactionArgs e) {
|
||||
DynamicObject[] dataEnties = e.getDataEntities();
|
||||
for (DynamicObject temp : dataEnties) {
|
||||
temp = BusinessDataServiceHelper.loadSingle(temp.getPkValue(), temp.getDynamicObjectType().getName());
|
||||
//借贷业务类型
|
||||
DynamicObject yem_credittype = temp.getDynamicObject("yem_credittype");
|
||||
//集团客户
|
||||
DynamicObject yem_customer = temp.getDynamicObject("yem_groupcusfields");
|
||||
//产品类型
|
||||
DynamicObject yem_bd_products = temp.getDynamicObject("yem_bd_products");
|
||||
QFilter qFilter1 = new QFilter("billstatus", QCP.equals, "C");
|
||||
qFilter1.and(new QFilter("yem_credittype.id", QCP.equals, yem_credittype.getLong("id")));
|
||||
qFilter1.and(new QFilter("yem_groupcusfields.id", QCP.equals, yem_customer.getLong("id")));
|
||||
//借/贷类型
|
||||
qFilter1.and(new QFilter("yem_debcredtype", QCP.equals, temp.getString("yem_debcredtype")));
|
||||
qFilter1.and(new QFilter("yem_bd_products.id", QCP.equals, yem_bd_products.getLong("id")));
|
||||
qFilter1.and(new QFilter("id", QCP.not_equals, temp.getPkValue()));
|
||||
String selectfielddebcrednote = DynamicObjectUtil.getSelectfields("yem_debcrednote", false);
|
||||
DynamicObjectCollection debcrednote = QueryServiceHelper.query("yem_debcrednote",
|
||||
selectfielddebcrednote, new QFilter[]{qFilter1}, "billno desc");
|
||||
if (debcrednote.size() > 0) {
|
||||
String billno = debcrednote.get(0).getString("billno");
|
||||
temp.set("yem_lastbillno", billno);
|
||||
}
|
||||
//组织
|
||||
DynamicObject org = temp.getDynamicObject("org");
|
||||
String products = "";
|
||||
if (yem_bd_products != null) {
|
||||
String number = yem_bd_products.getString("number");
|
||||
if (number.contains("ZZJ")) {
|
||||
products = "ZZJ";
|
||||
} else if (number.contains("CC")) {
|
||||
products = "CC";
|
||||
} else if (number.contains("TLJ")) {
|
||||
products = "TLJ";
|
||||
}
|
||||
}
|
||||
if (org != null && yem_customer != null && yem_credittype != null && products != null) {
|
||||
QFilter qFilter = new QFilter("billstatus", QCP.equals, "C");//
|
||||
qFilter.and(new QFilter("org.id", QCP.equals, org.getLong("id")));
|
||||
qFilter.and(new QFilter("yem_customer.id", QCP.equals, yem_customer.getLong("id")));
|
||||
qFilter.and(new QFilter("yem_bd_products.number", QCP.equals, products));
|
||||
qFilter.and(new QFilter("yem_spcapitalpool_a.yem_creditype.id", QCP.equals, yem_credittype.getLong("id")));
|
||||
qFilter.and(new QFilter("yem_spcapitalpool_a.yem_debcredtype", QCP.equals, temp.getString("yem_debcredtype")));
|
||||
String selectfield = DynamicObjectUtil.getSelectfields("yem_spcapitalpool", false);
|
||||
String selectfields = DynamicObjectUtil.getEntrySelectfields(selectfield, "yem_spcapitalpool", "yem_spcapitalpool_a", false);
|
||||
DynamicObjectCollection data = QueryServiceHelper.query("yem_spcapitalpool", selectfields, new QFilter[]{qFilter}, "billno");
|
||||
Map<Long, BigDecimal> map = new HashMap<>();
|
||||
Map<Long, BigDecimal> map1 = new HashMap<>();
|
||||
if (data.size() > 0) {
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
DynamicObject dynamicObject = data.get(i);
|
||||
long yem_curr = dynamicObject.getLong("yem_spcapitalpool_a.yem_curr");
|
||||
BigDecimal yem_noamo = dynamicObject.getBigDecimal("yem_spcapitalpool_a.yem_actremaamount");//实际剩余金额
|
||||
BigDecimal yem_estamount = dynamicObject.getBigDecimal("yem_spcapitalpool_a.yem_estamount");//预计剩余金额
|
||||
if (map.containsKey(yem_curr)) {
|
||||
BigDecimal bigDecimal = map.get(yem_curr);
|
||||
map.put(yem_curr, bigDecimal.add(yem_noamo));
|
||||
BigDecimal bigDecimal1 = map1.get(yem_curr);
|
||||
map1.put(yem_curr, bigDecimal1.add(yem_estamount));
|
||||
} else {
|
||||
map.put(yem_curr, yem_noamo);
|
||||
map1.put(yem_curr, yem_estamount);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (map.size() > 0) {
|
||||
for (Long mapkey : map.keySet()) {
|
||||
BigDecimal bigDecimal = map.get(mapkey);
|
||||
DynamicObject yem_em_replace = BusinessDataServiceHelper.loadSingle(mapkey, "bd_currency");
|
||||
if (yem_em_replace != null) {
|
||||
String number = yem_em_replace.getString("number");
|
||||
if (number.equals("CNY")) {
|
||||
temp.set("yem_creditrmbamt", bigDecimal);
|
||||
}
|
||||
if (number.equals("USD")) {
|
||||
temp.set("yem_creditusdamt", bigDecimal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (map1.size() > 0) {
|
||||
for (Long mapkey : map1.keySet()) {
|
||||
BigDecimal bigDecimal = map1.get(mapkey);
|
||||
DynamicObject yem_em_replace = BusinessDataServiceHelper.loadSingle(mapkey, "bd_currency");
|
||||
if (yem_em_replace != null) {
|
||||
String number = yem_em_replace.getString("number");
|
||||
if (number.equals("CNY")) {
|
||||
temp.set("yem_lastrmbamt", bigDecimal);
|
||||
}
|
||||
if (number.equals("USD")) {
|
||||
temp.set("yem_lastusdamt", bigDecimal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SaveServiceHelper.update(temp);
|
||||
//2024-10-08 zhouc 修改至提交前计算
|
||||
// getlast(temp);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
|
||||
super.beforeExecuteOperationTransaction(e);
|
||||
for (ExtendedDataEntity dataEntity : e.getSelectedRows()) {
|
||||
DynamicObject billObj = dataEntity.getDataEntity();
|
||||
getlast(billObj);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 计算上次美元金额(实际) 上次人民币金额(实际)
|
||||
* @param temp
|
||||
*/
|
||||
public void getlast(DynamicObject temp){
|
||||
temp = BusinessDataServiceHelper.loadSingle(temp.getPkValue(), temp.getDynamicObjectType().getName());
|
||||
//借贷业务类型
|
||||
DynamicObject yem_credittype = temp.getDynamicObject("yem_credittype");
|
||||
//集团客户
|
||||
DynamicObject yem_customer = temp.getDynamicObject("yem_groupcusfields");
|
||||
//产品类型
|
||||
DynamicObject yem_bd_products = temp.getDynamicObject("yem_bd_products");
|
||||
QFilter qFilter1 = new QFilter("billstatus", QCP.equals, "C");
|
||||
qFilter1.and(new QFilter("yem_credittype.id", QCP.equals, yem_credittype.getLong("id")));
|
||||
qFilter1.and(new QFilter("yem_groupcusfields.id", QCP.equals, yem_customer.getLong("id")));
|
||||
//借/贷类型
|
||||
qFilter1.and(new QFilter("yem_debcredtype", QCP.equals, temp.getString("yem_debcredtype")));
|
||||
qFilter1.and(new QFilter("yem_bd_products.id", QCP.equals, yem_bd_products.getLong("id")));
|
||||
qFilter1.and(new QFilter("id", QCP.not_equals, temp.getPkValue()));
|
||||
String selectfielddebcrednote = DynamicObjectUtil.getSelectfields("yem_debcrednote", false);
|
||||
DynamicObjectCollection debcrednote = QueryServiceHelper.query("yem_debcrednote",
|
||||
selectfielddebcrednote, new QFilter[]{qFilter1}, "billno desc");
|
||||
if (debcrednote.size() > 0) {
|
||||
String billno = debcrednote.get(0).getString("billno");
|
||||
temp.set("yem_lastbillno", billno);
|
||||
}
|
||||
//组织
|
||||
DynamicObject org = temp.getDynamicObject("org");
|
||||
String products = "";
|
||||
if (yem_bd_products != null) {
|
||||
String number = yem_bd_products.getString("number");
|
||||
if (number.contains("ZZJ")) {
|
||||
products = "ZZJ";
|
||||
} else if (number.contains("CC")) {
|
||||
products = "CC";
|
||||
} else if (number.contains("TLJ")) {
|
||||
products = "TLJ";
|
||||
}
|
||||
}
|
||||
if (org != null && yem_customer != null && yem_credittype != null && products != null) {
|
||||
QFilter qFilter = new QFilter("billstatus", QCP.equals, "C");//
|
||||
qFilter.and(new QFilter("org.id", QCP.equals, org.getLong("id")));
|
||||
qFilter.and(new QFilter("yem_customer.id", QCP.equals, yem_customer.getLong("id")));
|
||||
qFilter.and(new QFilter("yem_bd_products.number", QCP.equals, products));
|
||||
qFilter.and(new QFilter("yem_spcapitalpool_a.yem_creditype.id", QCP.equals, yem_credittype.getLong("id")));
|
||||
qFilter.and(new QFilter("yem_spcapitalpool_a.yem_debcredtype", QCP.equals, temp.getString("yem_debcredtype")));
|
||||
String selectfield = DynamicObjectUtil.getSelectfields("yem_spcapitalpool", false);
|
||||
String selectfields = DynamicObjectUtil.getEntrySelectfields(selectfield, "yem_spcapitalpool", "yem_spcapitalpool_a", false);
|
||||
DynamicObjectCollection data = QueryServiceHelper.query("yem_spcapitalpool", selectfields, new QFilter[]{qFilter}, "billno");
|
||||
Map<Long, BigDecimal> map = new HashMap<>();
|
||||
Map<Long, BigDecimal> map1 = new HashMap<>();
|
||||
if (data.size() > 0) {
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
DynamicObject dynamicObject = data.get(i);
|
||||
long yem_curr = dynamicObject.getLong("yem_spcapitalpool_a.yem_curr");
|
||||
BigDecimal yem_noamo = dynamicObject.getBigDecimal("yem_spcapitalpool_a.yem_actremaamount");//实际剩余金额
|
||||
BigDecimal yem_estamount = dynamicObject.getBigDecimal("yem_spcapitalpool_a.yem_estamount");//预计剩余金额
|
||||
if (map.containsKey(yem_curr)) {
|
||||
BigDecimal bigDecimal = map.get(yem_curr);
|
||||
map.put(yem_curr, bigDecimal.add(yem_noamo));
|
||||
BigDecimal bigDecimal1 = map1.get(yem_curr);
|
||||
map1.put(yem_curr, bigDecimal1.add(yem_estamount));
|
||||
} else {
|
||||
map.put(yem_curr, yem_noamo);
|
||||
map1.put(yem_curr, yem_estamount);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (map.size() > 0) {
|
||||
for (Long mapkey : map.keySet()) {
|
||||
BigDecimal bigDecimal = map.get(mapkey);
|
||||
DynamicObject yem_em_replace = BusinessDataServiceHelper.loadSingle(mapkey, "bd_currency");
|
||||
if (yem_em_replace != null) {
|
||||
String number = yem_em_replace.getString("number");
|
||||
if (number.equals("CNY")) {
|
||||
temp.set("yem_creditrmbamt", bigDecimal);
|
||||
}
|
||||
if (number.equals("USD")) {
|
||||
temp.set("yem_creditusdamt", bigDecimal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (map1.size() > 0) {
|
||||
for (Long mapkey : map1.keySet()) {
|
||||
BigDecimal bigDecimal = map1.get(mapkey);
|
||||
DynamicObject yem_em_replace = BusinessDataServiceHelper.loadSingle(mapkey, "bd_currency");
|
||||
if (yem_em_replace != null) {
|
||||
String number = yem_em_replace.getString("number");
|
||||
if (number.equals("CNY")) {
|
||||
temp.set("yem_lastrmbamt", bigDecimal);
|
||||
}
|
||||
if (number.equals("USD")) {
|
||||
temp.set("yem_lastusdamt", bigDecimal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SaveServiceHelper.update(temp);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user