parent
79d12f479a
commit
8395da6ef4
|
|
@ -6,6 +6,8 @@ import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
import kd.bos.entity.datamodel.ListSelectedRow;
|
import kd.bos.entity.datamodel.ListSelectedRow;
|
||||||
import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
||||||
import kd.bos.form.control.events.ItemClickEvent;
|
import kd.bos.form.control.events.ItemClickEvent;
|
||||||
|
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||||
|
import kd.bos.form.operate.AbstractOperate;
|
||||||
import kd.bos.list.BillList;
|
import kd.bos.list.BillList;
|
||||||
import kd.bos.list.plugin.AbstractListPlugin;
|
import kd.bos.list.plugin.AbstractListPlugin;
|
||||||
import kd.bos.logging.Log;
|
import kd.bos.logging.Log;
|
||||||
|
|
@ -15,16 +17,12 @@ import kd.bos.orm.query.QFilter;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
import kd.bos.servicehelper.coderule.CodeRuleServiceHelper;
|
import kd.bos.servicehelper.coderule.CodeRuleServiceHelper;
|
||||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||||
import kd.scmc.pm.forecast.business.helper.DateHelper;
|
import kd.bos.entity.operate.Delete;
|
||||||
import kd.sdk.plugin.Plugin;
|
import kd.sdk.plugin.Plugin;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标准单据列表插件
|
* 标准单据列表插件
|
||||||
|
|
@ -44,28 +42,38 @@ public class LpzListPlugin extends AbstractListPlugin implements Plugin {
|
||||||
ListSelectedRowCollection selectedRows = list.getSelectedRows();
|
ListSelectedRowCollection selectedRows = list.getSelectedRows();
|
||||||
|
|
||||||
if ("shkd_combined".equals(itemKey)) {
|
if ("shkd_combined".equals(itemKey)) {
|
||||||
if (selectedRows.isEmpty() || selectedRows.size() == 1) {
|
if (selectedRows.isEmpty() || selectedRows.size() == 2) {
|
||||||
this.getView().showTipNotification("请至少选择两条数据");
|
this.getView().showTipNotification("请至少选择两条数据");
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
|
List<Object> selectedRowPKValues = new ArrayList<>();
|
||||||
|
for (ListSelectedRow selectedRow : selectedRows) {
|
||||||
|
selectedRowPKValues.add(selectedRow.getPrimaryKeyValue());
|
||||||
|
}
|
||||||
|
selectedRowPKValues = new ArrayList<>(new HashSet<>(selectedRowPKValues));
|
||||||
|
|
||||||
//合并的凭证
|
//合并的凭证
|
||||||
List<DynamicObject> allMergeVoucher = new ArrayList<>();
|
List<DynamicObject> allMergeVoucher = new ArrayList<>();
|
||||||
//核算组织的类型
|
//核算组织的类型
|
||||||
List<Long> tallycompanys = new ArrayList<>();
|
List<Long> tallycompanys = new ArrayList<>();
|
||||||
for (ListSelectedRow selectedRow : selectedRows) {
|
for (Object primaryKeyValue : selectedRowPKValues) {
|
||||||
Object primaryKeyValue = selectedRow.getPrimaryKeyValue();
|
|
||||||
|
|
||||||
//获取凭证全部数据
|
//获取凭证全部数据
|
||||||
// DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(primaryKeyValue, "fr_manualtallybill");
|
// DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(primaryKeyValue, "fr_manualtallybill");
|
||||||
|
|
||||||
DynamicObject[] dynamicObjects = BusinessDataServiceHelper.load("shkd_fr_manualtallybi_inh", "id,billno,tallycompany,biztype,company,currency,accountbook,applydate," +
|
DynamicObject[] dynamicObjects = BusinessDataServiceHelper.load("shkd_fr_manualtallybi_inh",
|
||||||
"bizdate,bookdate,period,vouchertype,biztype,amount,shkd_combined,shkd_combinedtime,tallyentryentity,tallyentryentity.tallyabstract,tallyentryentity.loanstanamount,tallyentryentity.standardamount,tallyentryentity.shkd_hswd," +
|
"id,billno,tallycompany,biztype,company,currency,accountbook,applydate,bizdate," +
|
||||||
"tallyentryentity.account,tallyentryentity.loanamount,tallyentryentity.oriamount,tallyentryentity.maincfitem,tallyentryentity.shkd_zbhswd,tallyentryentity.maincfamount,tallyentryentity.cuscurrency," +
|
"bookdate,period,vouchertype,biztype,amount,shkd_combined,shkd_combinedtime,shkd_bemerged," +
|
||||||
"tallyentryentity.exrate,tallyentryentity.ratedate,tallyentryentity.tallyamount", new QFilter("id", QCP.equals, primaryKeyValue).toArray());
|
"shkd_bemergedtime,tallyentryentity,tallyentryentity.tallyabstract,tallyentryentity.loanstanamount," +
|
||||||
|
"tallyentryentity.standardamount,tallyentryentity.shkd_hswd,tallyentryentity.account," +
|
||||||
|
"tallyentryentity.loanamount,tallyentryentity.oriamount,tallyentryentity.maincfitem," +
|
||||||
|
"tallyentryentity.shkd_zbhswd,tallyentryentity.maincfamount,tallyentryentity.cuscurrency," +
|
||||||
|
"tallyentryentity.exrate,tallyentryentity.ratedate,tallyentryentity.tallyamount," +
|
||||||
|
"shkd_djhbjlentryentity,shkd_djhbjlentryentity.shkd_hbdj,shkd_djhbjlentryentity.shkd_djbzywlx",
|
||||||
|
new QFilter("id", QCP.equals, primaryKeyValue).toArray());
|
||||||
DynamicObject dynamicObject = dynamicObjects[0];
|
DynamicObject dynamicObject = dynamicObjects[0];
|
||||||
|
|
||||||
boolean shkdCombined = dynamicObject.getBoolean("shkd_combined");
|
boolean shkdCombined = dynamicObject.getBoolean("shkd_combined");
|
||||||
if (shkdCombined) {
|
boolean shkd_bemerged = dynamicObject.getBoolean("shkd_bemerged");
|
||||||
|
if (shkdCombined || shkd_bemerged) {
|
||||||
this.getView().showTipNotification("所选数据存在已合并凭证");
|
this.getView().showTipNotification("所选数据存在已合并凭证");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -81,6 +89,11 @@ public class LpzListPlugin extends AbstractListPlugin implements Plugin {
|
||||||
// 核算组织去重
|
// 核算组织去重
|
||||||
tallycompanys = new ArrayList<>(new HashSet<>(tallycompanys));
|
tallycompanys = new ArrayList<>(new HashSet<>(tallycompanys));
|
||||||
|
|
||||||
|
// 币种
|
||||||
|
DynamicObject[] bdCurrency = BusinessDataServiceHelper.load("bd_currency", "id,name", new QFilter("name", QCP.equals, "人民币").toArray());
|
||||||
|
// 当前日期
|
||||||
|
Date currentDate = new Date();
|
||||||
|
|
||||||
for (Long tallycompany : tallycompanys) {
|
for (Long tallycompany : tallycompanys) {
|
||||||
// 根据核算组织分类后的合并凭证
|
// 根据核算组织分类后的合并凭证
|
||||||
List<DynamicObject> mergeVoucher = new ArrayList<>();
|
List<DynamicObject> mergeVoucher = new ArrayList<>();
|
||||||
|
|
@ -140,6 +153,20 @@ public class LpzListPlugin extends AbstractListPlugin implements Plugin {
|
||||||
// 创建一个合并单据
|
// 创建一个合并单据
|
||||||
DynamicObject frManualtallybill = BusinessDataServiceHelper.newDynamicObject("shkd_fr_manualtallybi_inh");
|
DynamicObject frManualtallybill = BusinessDataServiceHelper.newDynamicObject("shkd_fr_manualtallybi_inh");
|
||||||
|
|
||||||
|
// 单据合并记录分录
|
||||||
|
DynamicObjectCollection shkdDjhbjlentryentity = frManualtallybill.getDynamicObjectCollection("shkd_djhbjlentryentity");
|
||||||
|
for (DynamicObject consolidateDocument : consolidateDocuments) {
|
||||||
|
DynamicObject dynamicObject = shkdDjhbjlentryentity.addNew();
|
||||||
|
|
||||||
|
dynamicObject.set("shkd_hbdj", consolidateDocument);
|
||||||
|
dynamicObject.set("shkd_djbzywlx", consolidateDocument.getDynamicObject("biztype"));
|
||||||
|
|
||||||
|
consolidateDocument.set("shkd_bemerged", true);
|
||||||
|
consolidateDocument.set("shkd_bemergedtime", currentDate);
|
||||||
|
SaveServiceHelper.save(new DynamicObject[]{consolidateDocument});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DynamicObject packagenoObject = mergeVoucher.get(0);
|
DynamicObject packagenoObject = mergeVoucher.get(0);
|
||||||
// CodeRuleServiceHelper(编码规则帮助服务类)
|
// CodeRuleServiceHelper(编码规则帮助服务类)
|
||||||
CodeRuleInfo codeRule = CodeRuleServiceHelper.getCodeRule(packagenoObject.getDataEntityType().getName(), packagenoObject, null);
|
CodeRuleInfo codeRule = CodeRuleServiceHelper.getCodeRule(packagenoObject.getDataEntityType().getName(), packagenoObject, null);
|
||||||
|
|
@ -152,12 +179,6 @@ public class LpzListPlugin extends AbstractListPlugin implements Plugin {
|
||||||
frManualtallybill.set("company", tallycompany);
|
frManualtallybill.set("company", tallycompany);
|
||||||
// 核算组织
|
// 核算组织
|
||||||
frManualtallybill.set("tallycompany", tallycompany);
|
frManualtallybill.set("tallycompany", tallycompany);
|
||||||
|
|
||||||
// 币种
|
|
||||||
DynamicObject[] bdCurrency = BusinessDataServiceHelper.load("bd_currency", "id,name", new QFilter("name", QCP.equals, "人民币").toArray());
|
|
||||||
// 当前日期
|
|
||||||
Date currentDate = new Date();
|
|
||||||
|
|
||||||
// 本位币种
|
// 本位币种
|
||||||
frManualtallybill.set("currency", bdCurrency[0]);
|
frManualtallybill.set("currency", bdCurrency[0]);
|
||||||
// 账簿类型
|
// 账簿类型
|
||||||
|
|
@ -411,4 +432,34 @@ public class LpzListPlugin extends AbstractListPlugin implements Plugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||||
|
super.beforeDoOperation(args);
|
||||||
|
AbstractOperate argsSource = (AbstractOperate)args.getSource();
|
||||||
|
String operateKey = argsSource.getOperateKey();
|
||||||
|
if (("delete").equals(operateKey)) {
|
||||||
|
ListSelectedRowCollection listSelectedData = ((Delete) argsSource).getListSelectedData();
|
||||||
|
List<Object> listFocusRowPKIds = new ArrayList<>();
|
||||||
|
for (ListSelectedRow listSelectedRow : listSelectedData) {
|
||||||
|
Object primaryKeyValue = listSelectedRow.getPrimaryKeyValue();
|
||||||
|
listFocusRowPKIds.add(primaryKeyValue);
|
||||||
|
}
|
||||||
|
listFocusRowPKIds = new ArrayList<>(new HashSet<>(listFocusRowPKIds));
|
||||||
|
for (Object listFocusRowPKId : listFocusRowPKIds) {
|
||||||
|
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(listFocusRowPKId, "shkd_fr_manualtallybi_inh");
|
||||||
|
boolean shkdCombined = dynamicObject.getBoolean("shkd_combined");
|
||||||
|
if (shkdCombined) {
|
||||||
|
DynamicObjectCollection shkdDjhbjlentryentitys = dynamicObject.getDynamicObjectCollection("shkd_djhbjlentryentity");
|
||||||
|
List<DynamicObject> dynamicObjects = new ArrayList<>();
|
||||||
|
for (DynamicObject shkdDjhbjlentryentity : shkdDjhbjlentryentitys) {
|
||||||
|
DynamicObject shkdFrManualtallybiInh = BusinessDataServiceHelper.loadSingle(shkdDjhbjlentryentity.getDynamicObject("shkd_hbdj").getPkValue(), "shkd_fr_manualtallybi_inh");
|
||||||
|
shkdFrManualtallybiInh.set("shkd_bemerged", false);
|
||||||
|
shkdFrManualtallybiInh.set("shkd_bemergedtime", null);
|
||||||
|
dynamicObjects.add(shkdFrManualtallybiInh);
|
||||||
|
}
|
||||||
|
SaveServiceHelper.save(dynamicObjects.toArray(new DynamicObject[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue