理财申购单新增两个功能按钮
This commit is contained in:
parent
64d7eb4feb
commit
aaa92f87da
|
|
@ -0,0 +1,119 @@
|
|||
package shjh.jhzj7.fi.fi.plugin.form;
|
||||
|
||||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.db.DB;
|
||||
import kd.bos.db.DBRoute;
|
||||
import kd.bos.form.control.events.ItemClickEvent;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.EventObject;
|
||||
|
||||
/**
|
||||
* 单据界面插件
|
||||
* 理财申购单表单插件
|
||||
*/
|
||||
public class CimFinancialBillPlugin extends AbstractBillPlugIn implements Plugin {
|
||||
|
||||
private static final String DELETE = "delete from t_cim_finsubscribe_v where fentryid=?;";
|
||||
|
||||
private static final String UPDATE = "update t_cim_finsubscribe set fexpiredate = ?,fterm = ?,fplanamount = ? where fid=?;";
|
||||
|
||||
@Override
|
||||
public void registerListener(EventObject e) {
|
||||
super.registerListener(e);
|
||||
this.addItemClickListeners("tbmain");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void itemClick(ItemClickEvent evt) {
|
||||
super.itemClick(evt);
|
||||
switch (evt.getItemKey()){
|
||||
//删除最新估值行
|
||||
case "shjh_deletevalue":
|
||||
this.deleteValue();
|
||||
break;
|
||||
//更新到期日、期限、预计收益金额
|
||||
case "shjh_updatedate":
|
||||
this.updateBillInfo();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteValue() {
|
||||
DynamicObject financialBill = BusinessDataServiceHelper.loadSingle(this.getModel().getValue("id"), this.getModel().getDataEntityType().getName());
|
||||
if (financialBill !=null){
|
||||
// 获取估值分录
|
||||
DynamicObjectCollection entryEntity = financialBill.getDynamicObjectCollection("valuationentry");
|
||||
if (entryEntity == null || entryEntity.size()<=1) {
|
||||
this.getView().showTipNotification("无可删除数据!");
|
||||
return;
|
||||
}
|
||||
DynamicObject maxSeqItem = findMaxSeqItem(entryEntity);
|
||||
if (maxSeqItem!=null){
|
||||
DynamicObject redeemBill = maxSeqItem.getDynamicObject("shjh_shdh");
|
||||
if (redeemBill!=null){
|
||||
this.getView().showTipNotification("最新估值分录存在已审核赎回单!");
|
||||
}else {
|
||||
entryEntity.remove(maxSeqItem);
|
||||
DynamicObject newMaxSeqItem = findMaxSeqItem(entryEntity);
|
||||
if (newMaxSeqItem!=null){
|
||||
BigDecimal e_surpcopies = newMaxSeqItem.getBigDecimal("e_surpcopies");
|
||||
financialBill.set("surpluscopies",e_surpcopies);
|
||||
SaveServiceHelper.update(financialBill);
|
||||
}
|
||||
DB.update(DBRoute.of("fi"),DELETE,new Object[]{maxSeqItem.getPkValue()});
|
||||
this.getView().invokeOperation("refresh");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateBillInfo() {
|
||||
boolean dataChanged = this.getModel().getDataChanged();
|
||||
if (dataChanged){
|
||||
int update = DB.update(DBRoute.of("fi"), UPDATE, new Object[]{
|
||||
this.getModel().getValue("expiredate"),
|
||||
this.getModel().getValue("term"),
|
||||
this.getModel().getValue("planamount"),
|
||||
this.getModel().getValue("id")
|
||||
});
|
||||
if (update==1){
|
||||
this.getView().showMessage("已更新到期日、期限、预计收益金额");
|
||||
this.getView().invokeOperation("refresh");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从分录中查找行号最大的记录
|
||||
* @param entryEntity 分录集合
|
||||
* @return 行号最大的记录,如果没有记录则返回null
|
||||
*/
|
||||
private DynamicObject findMaxSeqItem(DynamicObjectCollection entryEntity) {
|
||||
if (entryEntity == null || entryEntity.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
DynamicObject maxSeqItem = null;
|
||||
int maxSeq = -1;
|
||||
|
||||
for (DynamicObject item : entryEntity) {
|
||||
int currentSeq = item.getInt("seq");
|
||||
if (currentSeq==0){
|
||||
throw new RuntimeException("初始行不可删除!");
|
||||
}
|
||||
if (currentSeq > maxSeq) {
|
||||
maxSeq = currentSeq;
|
||||
maxSeqItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
return maxSeqItem;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue