设备维修确认分录选择
This commit is contained in:
parent
663baefb2c
commit
83931a9dc5
|
@ -11,6 +11,7 @@ import kd.bos.entity.datamodel.ListSelectedRow;
|
||||||
import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
||||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||||
import kd.bos.form.CloseCallBack;
|
import kd.bos.form.CloseCallBack;
|
||||||
|
import kd.bos.form.FormShowParameter;
|
||||||
import kd.bos.form.ShowFormHelper;
|
import kd.bos.form.ShowFormHelper;
|
||||||
import kd.bos.form.ShowType;
|
import kd.bos.form.ShowType;
|
||||||
import kd.bos.form.control.EntryGrid;
|
import kd.bos.form.control.EntryGrid;
|
||||||
|
@ -43,14 +44,16 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
@Override
|
@Override
|
||||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||||
super.beforeDoOperation(args);
|
super.beforeDoOperation(args);
|
||||||
FormOperate operate = (FormOperate)args.getSource();
|
FormOperate operate = (FormOperate) args.getSource();
|
||||||
String key = operate.getOperateKey();
|
String key = operate.getOperateKey();
|
||||||
if (StringUtils.equals(key, "newsubentry")) { //选择发票
|
if (StringUtils.equals(key, "newsubentry")) { //选择发票
|
||||||
this.beforeNewSubEntry(args);
|
this.beforeNewSubEntry(args);
|
||||||
} else if (StringUtils.equals(key, "selectinvoice")) { //导入发票
|
} else if (StringUtils.equals(key, "selectinvoice")) { //导入发票
|
||||||
this.showInvoiceImport(args);
|
this.showInvoiceImport(args);
|
||||||
}else if (key.equals("deletesubentry")) {
|
} else if (key.equals("deletesubentry")) {
|
||||||
this.beforeDeleteSubEntry(args);
|
this.beforeDeleteSubEntry(args);
|
||||||
|
} else if (key.equals("addnewentry")) {
|
||||||
|
this.beforeAddNewEntry(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +65,8 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
this.invoiceCloseCallBack(event);
|
this.invoiceCloseCallBack(event);
|
||||||
} else if (actionId.toLowerCase().startsWith("selectinvoice") && returnData != null) {
|
} else if (actionId.toLowerCase().startsWith("selectinvoice") && returnData != null) {
|
||||||
this.importInvoiceCallBack(returnData);
|
this.importInvoiceCallBack(returnData);
|
||||||
|
} else if (actionId.toLowerCase().startsWith("tb_new") && returnData != null) {
|
||||||
|
this.importMaintenanceCallBack(returnData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,8 +82,8 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showInvoice(String entryType) {
|
private void showInvoice(String entryType) {
|
||||||
long currencyId = ((DynamicObject)this.getModel().getValue("zcgj_currency")).getLong("id");
|
long currencyId = ((DynamicObject) this.getModel().getValue("zcgj_currency")).getLong("id");
|
||||||
long orgId = ((DynamicObject)this.getModel().getValue("zcgj_accountorg")).getLong("id");
|
long orgId = ((DynamicObject) this.getModel().getValue("zcgj_accountorg")).getLong("id");
|
||||||
QFilter filter = new QFilter("org", "=", orgId);
|
QFilter filter = new QFilter("org", "=", orgId);
|
||||||
filter.and(new QFilter("isclaimed", "=", false));
|
filter.and(new QFilter("isclaimed", "=", false));
|
||||||
filter.and(new QFilter("billstatus", "=", "C"));
|
filter.and(new QFilter("billstatus", "=", "C"));
|
||||||
|
@ -96,7 +101,7 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
if (contInvEntryCol.size() > 0) {
|
if (contInvEntryCol.size() > 0) {
|
||||||
List<Long> selectedInvIds = new ArrayList(8);
|
List<Long> selectedInvIds = new ArrayList(8);
|
||||||
|
|
||||||
for(DynamicObject contInvEntryObj : contInvEntryCol) {
|
for (DynamicObject contInvEntryObj : contInvEntryCol) {
|
||||||
DynamicObject invoice = contInvEntryObj.getDynamicObject("zcgj_invoice");
|
DynamicObject invoice = contInvEntryObj.getDynamicObject("zcgj_invoice");
|
||||||
selectedInvIds.add(invoice.getLong("id"));
|
selectedInvIds.add(invoice.getLong("id"));
|
||||||
}
|
}
|
||||||
|
@ -114,11 +119,11 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void invoiceCloseCallBack(ClosedCallBackEvent event) {
|
protected void invoiceCloseCallBack(ClosedCallBackEvent event) {
|
||||||
ListSelectedRowCollection rows = (ListSelectedRowCollection)event.getReturnData();
|
ListSelectedRowCollection rows = (ListSelectedRowCollection) event.getReturnData();
|
||||||
DynamicObject[] invArr = new DynamicObject[rows.size()];
|
DynamicObject[] invArr = new DynamicObject[rows.size()];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
// DynamicObject upContract = (DynamicObject)this.getModel().getValue("zcgj_contract");
|
// DynamicObject upContract = (DynamicObject)this.getModel().getValue("zcgj_contract");
|
||||||
for(ListSelectedRow row : rows) {
|
for (ListSelectedRow row : rows) {
|
||||||
Object invoicePk = row.getPrimaryKeyValue().toString();
|
Object invoicePk = row.getPrimaryKeyValue().toString();
|
||||||
int rowIndex = this.getModel().createNewEntryRow("zcgj_entryentity");
|
int rowIndex = this.getModel().createNewEntryRow("zcgj_entryentity");
|
||||||
this.getModel().setValue("zcgj_invoice", invoicePk.toString(), rowIndex);
|
this.getModel().setValue("zcgj_invoice", invoicePk.toString(), rowIndex);
|
||||||
|
@ -133,7 +138,7 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
invArr[index++] = invoice;
|
invArr[index++] = invoice;
|
||||||
invoice.set("isclaimed", true);
|
invoice.set("isclaimed", true);
|
||||||
// invoice.set("contract", upContract);
|
// invoice.set("contract", upContract);
|
||||||
invoice.set("project", (DynamicObject)this.getModel().getValue("zcgj_project"));
|
invoice.set("project", (DynamicObject) this.getModel().getValue("zcgj_project"));
|
||||||
invoice.set("connecttype", "contract");
|
invoice.set("connecttype", "contract");
|
||||||
}
|
}
|
||||||
SaveServiceHelper.save(invArr);
|
SaveServiceHelper.save(invArr);
|
||||||
|
@ -144,8 +149,8 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
int rowCount = this.getModel().getEntryRowCount(entryId);
|
int rowCount = this.getModel().getEntryRowCount(entryId);
|
||||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||||
|
|
||||||
for(int i = 0; i < rowCount; ++i) {
|
for (int i = 0; i < rowCount; ++i) {
|
||||||
BigDecimal amount = (BigDecimal)this.getModel().getValue(columnId, i);
|
BigDecimal amount = (BigDecimal) this.getModel().getValue(columnId, i);
|
||||||
amount = amount == null ? BigDecimal.ZERO : amount;
|
amount = amount == null ? BigDecimal.ZERO : amount;
|
||||||
totalAmount = totalAmount.add(amount);
|
totalAmount = totalAmount.add(amount);
|
||||||
}
|
}
|
||||||
|
@ -165,7 +170,7 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
if (!ImportInvoiceUtils.isXhInvoiceCloud()) {
|
if (!ImportInvoiceUtils.isXhInvoiceCloud()) {
|
||||||
args.setCancel(true);
|
args.setCancel(true);
|
||||||
ImportInvoiceUtils.showImportView(this);
|
ImportInvoiceUtils.showImportView(this);
|
||||||
}else{
|
} else {
|
||||||
args.setCancel(true);
|
args.setCancel(true);
|
||||||
DynamicObject org = (DynamicObject) this.getModel().getValue("zcgj_accountorg");
|
DynamicObject org = (DynamicObject) this.getModel().getValue("zcgj_accountorg");
|
||||||
InvoiceCollectHelper.showSelectInvoice(this, org);
|
InvoiceCollectHelper.showSelectInvoice(this, org);
|
||||||
|
@ -178,11 +183,11 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void importInvoiceCallBack(Object returnData) {
|
protected void importInvoiceCallBack(Object returnData) {
|
||||||
DynamicObject org = (DynamicObject)this.getModel().getValue("zcgj_accountorg");
|
DynamicObject org = (DynamicObject) this.getModel().getValue("zcgj_accountorg");
|
||||||
//List<InvoiceVO> invoiceVOList = InvoiceDataHandleHelper.parseXhInvoiceCloudReturnData(returnData);
|
//List<InvoiceVO> invoiceVOList = InvoiceDataHandleHelper.parseXhInvoiceCloudReturnData(returnData);
|
||||||
List<InvoiceVO> invoiceVOList = CustomInvoiceDataHandleHelper.parseXhInvoiceCloudReturnData(returnData);
|
List<InvoiceVO> invoiceVOList = CustomInvoiceDataHandleHelper.parseXhInvoiceCloudReturnData(returnData);
|
||||||
Map<Boolean, Set<DynamicObject>> invoiceMap = InvoiceDataHandleHelper.processInvoiceVO(invoiceVOList, RequestContext.get().getCurrUserId(),
|
Map<Boolean, Set<DynamicObject>> invoiceMap = InvoiceDataHandleHelper.processInvoiceVO(invoiceVOList, RequestContext.get().getCurrUserId(),
|
||||||
org.getLong("id"), new Date(), "ec_in_invoice", (DynamicObject)this.getModel().getValue("zcgj_currency"), true);
|
org.getLong("id"), new Date(), "ec_in_invoice", (DynamicObject) this.getModel().getValue("zcgj_currency"), true);
|
||||||
ImportInvoiceUtils invoiceUtils = new ImportInvoiceUtils(this.getView(), this.getPageCache());
|
ImportInvoiceUtils invoiceUtils = new ImportInvoiceUtils(this.getView(), this.getPageCache());
|
||||||
this.addInvoiceToEntry(invoiceUtils, invoiceMap);
|
this.addInvoiceToEntry(invoiceUtils, invoiceMap);
|
||||||
}
|
}
|
||||||
|
@ -191,11 +196,11 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
if (invoiceMap.isEmpty()) {
|
if (invoiceMap.isEmpty()) {
|
||||||
this.getView().showTipNotification(ResManager.loadKDString("导入发票为空。", "PaymentApplyEditUI_19", "ec-contract-formplugin", new Object[0]));
|
this.getView().showTipNotification(ResManager.loadKDString("导入发票为空。", "PaymentApplyEditUI_19", "ec-contract-formplugin", new Object[0]));
|
||||||
} else {
|
} else {
|
||||||
long orgId = (Long)((DynamicObject)this.getModel().getValue("zcgj_accountorg")).getPkValue();
|
long orgId = (Long) ((DynamicObject) this.getModel().getValue("zcgj_accountorg")).getPkValue();
|
||||||
Set<DynamicObject> newInvoices = (Set)invoiceMap.get(Boolean.TRUE);
|
Set<DynamicObject> newInvoices = (Set) invoiceMap.get(Boolean.TRUE);
|
||||||
Set<DynamicObject> existInvoices = (Set)invoiceMap.get(Boolean.FALSE);
|
Set<DynamicObject> existInvoices = (Set) invoiceMap.get(Boolean.FALSE);
|
||||||
if (newInvoices != null && !newInvoices.isEmpty()) {
|
if (newInvoices != null && !newInvoices.isEmpty()) {
|
||||||
for(DynamicObject newInvoice : newInvoices) {
|
for (DynamicObject newInvoice : newInvoices) {
|
||||||
DynamicObject buyerOrg = newInvoice.getDynamicObject("buyer");
|
DynamicObject buyerOrg = newInvoice.getDynamicObject("buyer");
|
||||||
if (buyerOrg != null && buyerOrg.getLong("id") != orgId) {
|
if (buyerOrg != null && buyerOrg.getLong("id") != orgId) {
|
||||||
this.getView().showErrorNotification(ResManager.loadKDString("导入失败:当前发票购买方不为当前财务记账组织,请确认信息。", "PaymentApplyEditUI_20", "ec-contract-formplugin", new Object[0]));
|
this.getView().showErrorNotification(ResManager.loadKDString("导入失败:当前发票购买方不为当前财务记账组织,请确认信息。", "PaymentApplyEditUI_20", "ec-contract-formplugin", new Object[0]));
|
||||||
|
@ -206,7 +211,7 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
this.saveInvoiceData(invoiceUtils, newInvoices, existInvoices);
|
this.saveInvoiceData(invoiceUtils, newInvoices, existInvoices);
|
||||||
} else if (existInvoices != null) {
|
} else if (existInvoices != null) {
|
||||||
DynamicObjectCollection contInvEntryCol = this.getModel().getEntryEntity("zcgj_entryentity");
|
DynamicObjectCollection contInvEntryCol = this.getModel().getEntryEntity("zcgj_entryentity");
|
||||||
Map<Object, Object> entryMap = (Map)contInvEntryCol.stream().collect(Collectors.toMap(this::getInvoicePK, this::getInvoicePK));
|
Map<Object, Object> entryMap = (Map) contInvEntryCol.stream().collect(Collectors.toMap(this::getInvoicePK, this::getInvoicePK));
|
||||||
this.initSubEntryEntity(existInvoices, entryMap);
|
this.initSubEntryEntity(existInvoices, entryMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,18 +224,18 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
newInvoices.addAll(existInvoices);
|
newInvoices.addAll(existInvoices);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.initSubEntryEntity(newInvoices, (Map)null);
|
this.initSubEntryEntity(newInvoices, (Map) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initSubEntryEntity(Set<DynamicObject> invoices, Map<Object, Object> entryMap) {
|
protected void initSubEntryEntity(Set<DynamicObject> invoices, Map<Object, Object> entryMap) {
|
||||||
if (invoices != null) {
|
if (invoices != null) {
|
||||||
List<DynamicObject> invArr = new ArrayList(invoices.size());
|
List<DynamicObject> invArr = new ArrayList(invoices.size());
|
||||||
for(DynamicObject invoice : invoices) {
|
for (DynamicObject invoice : invoices) {
|
||||||
if (entryMap != null && entryMap.get(invoice.getPkValue()) != null) {
|
if (entryMap != null && entryMap.get(invoice.getPkValue()) != null) {
|
||||||
this.getView().showTipNotification(String.format(ResManager.loadKDString("发票号码%s,已存在分录行", "PaymentApplyEditUI_22", "ec-contract-formplugin", new Object[0]), invoice.getString("invoiceno")));
|
this.getView().showTipNotification(String.format(ResManager.loadKDString("发票号码%s,已存在分录行", "PaymentApplyEditUI_22", "ec-contract-formplugin", new Object[0]), invoice.getString("invoiceno")));
|
||||||
} else {
|
} else {
|
||||||
BigDecimal unApplyAmount = invoice.getBigDecimal("unapplyamount");
|
BigDecimal unApplyAmount = invoice.getBigDecimal("unapplyamount");
|
||||||
if (unApplyAmount != null && unApplyAmount.doubleValue() <= (double)0.0F) {
|
if (unApplyAmount != null && unApplyAmount.doubleValue() <= (double) 0.0F) {
|
||||||
this.getView().showTipNotification(String.format(ResManager.loadKDString("发票号码%s,金额已经被关联完毕,不可重复使用", "PaymentApplyEditUI_23", "ec-contract-formplugin", new Object[0]), invoice.getString("invoiceno")));
|
this.getView().showTipNotification(String.format(ResManager.loadKDString("发票号码%s,金额已经被关联完毕,不可重复使用", "PaymentApplyEditUI_23", "ec-contract-formplugin", new Object[0]), invoice.getString("invoiceno")));
|
||||||
} else {
|
} else {
|
||||||
// DynamicObject upContract = (DynamicObject)this.getModel().getValue("zcgj_contract");
|
// DynamicObject upContract = (DynamicObject)this.getModel().getValue("zcgj_contract");
|
||||||
|
@ -245,7 +250,7 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
this.getModel().setValue("zcgj_applyinvoftaxamt", invoice.getBigDecimal("unapplyamount"), rowIndex);
|
this.getModel().setValue("zcgj_applyinvoftaxamt", invoice.getBigDecimal("unapplyamount"), rowIndex);
|
||||||
invoice.set("isclaimed", true);
|
invoice.set("isclaimed", true);
|
||||||
// invoice.set("contract", upContract);
|
// invoice.set("contract", upContract);
|
||||||
invoice.set("project", (DynamicObject)this.getModel().getValue("zcgj_project"));
|
invoice.set("project", (DynamicObject) this.getModel().getValue("zcgj_project"));
|
||||||
invoice.set("connecttype", "contract");
|
invoice.set("connecttype", "contract");
|
||||||
invArr.add(invoice);
|
invArr.add(invoice);
|
||||||
}
|
}
|
||||||
|
@ -253,7 +258,7 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invArr.size() > 0) {
|
if (invArr.size() > 0) {
|
||||||
SaveServiceHelper.save((DynamicObject[])invArr.toArray(new DynamicObject[invoices.size()]));
|
SaveServiceHelper.save((DynamicObject[]) invArr.toArray(new DynamicObject[invoices.size()]));
|
||||||
}
|
}
|
||||||
this.getView().invokeOperation("invoicesave");
|
this.getView().invokeOperation("invoicesave");
|
||||||
}
|
}
|
||||||
|
@ -266,7 +271,7 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
|
|
||||||
//删除发票 开始
|
//删除发票 开始
|
||||||
protected void beforeDeleteSubEntry(BeforeDoOperationEventArgs args) {
|
protected void beforeDeleteSubEntry(BeforeDoOperationEventArgs args) {
|
||||||
EntryGrid subGrid = (EntryGrid)this.getControl("zcgj_entryentity");
|
EntryGrid subGrid = (EntryGrid) this.getControl("zcgj_entryentity");
|
||||||
int[] selRows = subGrid.getEntryState().getSelectedRows();
|
int[] selRows = subGrid.getEntryState().getSelectedRows();
|
||||||
if (selRows.length == 0) {
|
if (selRows.length == 0) {
|
||||||
this.getView().showMessage(ResManager.loadKDString("请选择发票。", "PaymentApplyEditUI_3", "ec-contract-formplugin", new Object[0]));
|
this.getView().showMessage(ResManager.loadKDString("请选择发票。", "PaymentApplyEditUI_3", "ec-contract-formplugin", new Object[0]));
|
||||||
|
@ -276,11 +281,11 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
Set<Object> updateInvoicePks = new HashSet(selRows.length);
|
Set<Object> updateInvoicePks = new HashSet(selRows.length);
|
||||||
DynamicObjectCollection subEntryEntityCol = this.getModel().getEntryEntity("zcgj_entryentity");
|
DynamicObjectCollection subEntryEntityCol = this.getModel().getEntryEntity("zcgj_entryentity");
|
||||||
|
|
||||||
for(int i = selRows.length - 1; i >= 0; --i) {
|
for (int i = selRows.length - 1; i >= 0; --i) {
|
||||||
int rowIndex = selRows[i];
|
int rowIndex = selRows[i];
|
||||||
DynamicObject invoice = (DynamicObject)this.getModel().getValue("zcgj_invoice", rowIndex);
|
DynamicObject invoice = (DynamicObject) this.getModel().getValue("zcgj_invoice", rowIndex);
|
||||||
updateInvoicePks.add(invoice.getPkValue());
|
updateInvoicePks.add(invoice.getPkValue());
|
||||||
delPks[i] = ((DynamicObject)subEntryEntityCol.get(selRows[i])).getPkValue();
|
delPks[i] = ((DynamicObject) subEntryEntityCol.get(selRows[i])).getPkValue();
|
||||||
this.getModel().deleteEntryRow("zcgj_entryentity", rowIndex);
|
this.getModel().deleteEntryRow("zcgj_entryentity", rowIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,7 +297,7 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
filter.and("id", "!=", this.getModel().getDataEntity().getPkValue());
|
filter.and("id", "!=", this.getModel().getDataEntity().getPkValue());
|
||||||
DynamicObjectCollection invoiceApplyEntries = QueryServiceHelper.query("zcgj_ec_out_finaceconfirm", "zcgj_entryentity.zcgj_invoice", new QFilter[]{filter});
|
DynamicObjectCollection invoiceApplyEntries = QueryServiceHelper.query("zcgj_ec_out_finaceconfirm", "zcgj_entryentity.zcgj_invoice", new QFilter[]{filter});
|
||||||
if (invoiceApplyEntries != null && !invoiceApplyEntries.isEmpty()) {
|
if (invoiceApplyEntries != null && !invoiceApplyEntries.isEmpty()) {
|
||||||
for(DynamicObject subEntry : invoiceApplyEntries) {
|
for (DynamicObject subEntry : invoiceApplyEntries) {
|
||||||
updateInvoicePks.remove(subEntry.get("zcgj_entryentity.zcgj_invoice"));
|
updateInvoicePks.remove(subEntry.get("zcgj_entryentity.zcgj_invoice"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,11 +306,11 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
DynamicObject[] invoices = BusinessDataServiceHelper.load("ec_in_invoice", "isinvoiceclaim,isclaimed,contract,project,connecttype",
|
DynamicObject[] invoices = BusinessDataServiceHelper.load("ec_in_invoice", "isinvoiceclaim,isclaimed,contract,project,connecttype",
|
||||||
new QFilter[]{new QFilter("id", "in", updateInvoicePks)});
|
new QFilter[]{new QFilter("id", "in", updateInvoicePks)});
|
||||||
|
|
||||||
for(DynamicObject invoice : invoices) {
|
for (DynamicObject invoice : invoices) {
|
||||||
if (!invoice.getBoolean("isinvoiceclaim")) {
|
if (!invoice.getBoolean("isinvoiceclaim")) {
|
||||||
invoice.set("isclaimed", false);
|
invoice.set("isclaimed", false);
|
||||||
invoice.set("contract", (Object)null);
|
invoice.set("contract", (Object) null);
|
||||||
invoice.set("project", (Object)null);
|
invoice.set("project", (Object) null);
|
||||||
invoice.set("connecttype", "null");
|
invoice.set("connecttype", "null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -320,13 +325,66 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
}
|
}
|
||||||
//删除发票 结束
|
//删除发票 结束
|
||||||
|
|
||||||
|
protected void beforeAddNewEntry(BeforeDoOperationEventArgs args) {
|
||||||
|
Object value = this.getModel().getValue("zcgj_maintenance");
|
||||||
|
if (value != null) {
|
||||||
|
DynamicObject maintenance = (DynamicObject) value;
|
||||||
|
QFilter filter = new QFilter("zcgj_maintenance.id", QCP.equals, maintenance.getLong("id"));
|
||||||
|
DynamicObject[] maintenanceackbill = BusinessDataServiceHelper.load("zcgj_maintenanceackbill", "entryentity.zcgj_sourceid", new QFilter[]{filter});
|
||||||
|
Set set = new HashSet();
|
||||||
|
set.add("9999999");
|
||||||
|
for (DynamicObject dynamicObject : maintenanceackbill) {
|
||||||
|
for (DynamicObject object : dynamicObject.getDynamicObjectCollection("entryentity")) {
|
||||||
|
set.add(object.getString("zcgj_sourceid"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DynamicObjectCollection entryentity = (DynamicObjectCollection) getModel().getEntryEntity("entryentity");
|
||||||
|
for (DynamicObject dynamicObject : entryentity) {
|
||||||
|
String sourceid = dynamicObject.getString("zcgj_sourceid");
|
||||||
|
set.add(sourceid);
|
||||||
|
}
|
||||||
|
FormShowParameter formShowParameter = new FormShowParameter();
|
||||||
|
// 弹窗案例-动态表单 页面标识
|
||||||
|
formShowParameter.setFormId("zcgj_repairselection");
|
||||||
|
// 自定义传参,把当前单据的文本字段传过去
|
||||||
|
formShowParameter.setCustomParam("set", set);
|
||||||
|
formShowParameter.setCustomParam("id", maintenance.getLong("id"));
|
||||||
|
// 设置回调事件,回调插件为当前插件,标识为zcgj_
|
||||||
|
formShowParameter.setCloseCallBack(new CloseCallBack(this, "tb_new"));
|
||||||
|
// 设置打开类型为模态框(不设置的话指令参数缺失,没办法打开页面)
|
||||||
|
formShowParameter.getOpenStyle().setShowType(ShowType.Modal);
|
||||||
|
// 当前页面发送showform指令。注意也可以从其他页面发送指令,后续有文章介绍
|
||||||
|
this.getView().showForm(formShowParameter);
|
||||||
|
}else{
|
||||||
|
this.getView().showErrorNotification("请先选择关联维修申请单!");
|
||||||
|
args.setCancel(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void importMaintenanceCallBack(Object returnData) {
|
||||||
|
if (returnData!=null){
|
||||||
|
DynamicObjectCollection data = (DynamicObjectCollection) returnData;
|
||||||
|
for (DynamicObject datum : data) {
|
||||||
|
int i = this.getModel().createNewEntryRow("entryentity");
|
||||||
|
this.getModel().setValue("zcgj_equipment", datum.getDynamicObject("zcgj_equipment"), i);
|
||||||
|
this.getModel().setValue("zcgj_fault", datum.getString("zcgj_fault"), i);
|
||||||
|
this.getModel().setValue("zcgj_faultreason", datum.getString("zcgj_faultreason"), i);
|
||||||
|
this.getModel().setValue("zcgj_amount", datum.getBigDecimal("zcgj_amount"), i);
|
||||||
|
this.getModel().setValue("zcgj_contacts", datum.getString("zcgj_contacts"), i);
|
||||||
|
this.getModel().setValue("zcgj_supplier", datum.getDynamicObject("zcgj_supplier"), i);
|
||||||
|
this.getModel().setValue("zcgj_sourceid", datum.getString("zcgj_sourceid"), i);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void propertyChanged(PropertyChangedArgs e) {
|
public void propertyChanged(PropertyChangedArgs e) {
|
||||||
super.propertyChanged(e);
|
super.propertyChanged(e);
|
||||||
String name = e.getProperty().getName();
|
String name = e.getProperty().getName();
|
||||||
if (name.equals("zcgj_maintenance")){
|
if (name.equals("zcgj_maintenance")) {
|
||||||
Object value = this.getModel().getValue("zcgj_maintenance");
|
Object value = this.getModel().getValue("zcgj_maintenance");
|
||||||
if (value!=null){
|
if (value != null) {
|
||||||
DynamicObject maintenance = (DynamicObject) value;
|
DynamicObject maintenance = (DynamicObject) value;
|
||||||
QFilter filter = new QFilter("zcgj_maintenance.id", QCP.equals, maintenance.getLong("id"));
|
QFilter filter = new QFilter("zcgj_maintenance.id", QCP.equals, maintenance.getLong("id"));
|
||||||
DynamicObject[] maintenanceackbill = BusinessDataServiceHelper.load("zcgj_maintenanceackbill", "entryentity.zcgj_sourceid", new QFilter[]{filter});
|
DynamicObject[] maintenanceackbill = BusinessDataServiceHelper.load("zcgj_maintenanceackbill", "entryentity.zcgj_sourceid", new QFilter[]{filter});
|
||||||
|
@ -339,15 +397,15 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
|
||||||
}
|
}
|
||||||
QFilter qf = new QFilter("id", QCP.equals, maintenance.getLong("id"));
|
QFilter qf = new QFilter("id", QCP.equals, maintenance.getLong("id"));
|
||||||
DynamicObject maintenancebill = BusinessDataServiceHelper.loadSingle("zcgj_maintenancebill", new QFilter[]{qf});
|
DynamicObject maintenancebill = BusinessDataServiceHelper.loadSingle("zcgj_maintenancebill", new QFilter[]{qf});
|
||||||
this.getModel().setValue("zcgj_project",maintenancebill.getDynamicObject("zcgj_project"));//项目
|
this.getModel().setValue("zcgj_project", maintenancebill.getDynamicObject("zcgj_project"));//项目
|
||||||
this.getModel().setValue("zcgj_accountorg",maintenancebill.getDynamicObject("zcgj_accountorg"));//财务记账组织
|
this.getModel().setValue("zcgj_accountorg", maintenancebill.getDynamicObject("zcgj_accountorg"));//财务记账组织
|
||||||
this.getModel().setValue("zcgj_totalamount",maintenancebill.getBigDecimal("zcgj_totalamount"));//预估维修金额
|
this.getModel().setValue("zcgj_totalamount", maintenancebill.getBigDecimal("zcgj_totalamount"));//预估维修金额
|
||||||
this.getModel().setValue("zcgj_currency",maintenancebill.getDynamicObject("zcgj_currency"));//币别
|
this.getModel().setValue("zcgj_currency", maintenancebill.getDynamicObject("zcgj_currency"));//币别
|
||||||
DynamicObjectCollection entrys = (DynamicObjectCollection) getModel().getValue("entryentity");
|
DynamicObjectCollection entrys = (DynamicObjectCollection) getModel().getValue("entryentity");
|
||||||
DynamicObjectCollection maintenanceentry = maintenancebill.getDynamicObjectCollection("entryentity");
|
DynamicObjectCollection maintenanceentry = maintenancebill.getDynamicObjectCollection("entryentity");
|
||||||
maintenanceentry.removeIf(entry -> set.contains(entry.getString("id")));//去除之前单据已有的数据
|
maintenanceentry.removeIf(entry -> set.contains(entry.getString("id")));//去除之前单据已有的数据
|
||||||
entrys.clear();
|
entrys.clear();
|
||||||
for (int i = 0; i<maintenanceentry.size();i++) {
|
for (int i = 0; i < maintenanceentry.size(); i++) {
|
||||||
DynamicObject object = maintenanceentry.get(i);
|
DynamicObject object = maintenanceentry.get(i);
|
||||||
i = this.getModel().createNewEntryRow("entryentity");
|
i = this.getModel().createNewEntryRow("entryentity");
|
||||||
this.getModel().setValue("zcgj_equipment", object.getDynamicObject("zcgj_equipment"), i);
|
this.getModel().setValue("zcgj_equipment", object.getDynamicObject("zcgj_equipment"), i);
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
|
import kd.bos.form.control.Button;
|
||||||
|
import kd.bos.form.control.Control;
|
||||||
|
import kd.bos.form.control.EntryGrid;
|
||||||
|
import kd.bos.form.control.events.CellClickEvent;
|
||||||
|
import kd.bos.form.control.events.CellClickListener;
|
||||||
|
import kd.bos.form.events.ClosedCallBackEvent;
|
||||||
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||||
|
import kd.bos.orm.query.QCP;
|
||||||
|
import kd.bos.orm.query.QFilter;
|
||||||
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
|
||||||
|
import java.util.EventObject;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class RepairSelectionFromPlugin extends AbstractFormPlugin implements CellClickListener {
|
||||||
|
@Override
|
||||||
|
public void cellClick(CellClickEvent cellClickEvent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cellDoubleClick(CellClickEvent cellClickEvent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterCreateNewData(EventObject e) {
|
||||||
|
super.afterCreateNewData(e);
|
||||||
|
Map<String, Object> customParams = this.getView().getFormShowParameter().getCustomParams();
|
||||||
|
Object set = customParams.get("set");
|
||||||
|
Object id = customParams.get("id");
|
||||||
|
if (set != null) {
|
||||||
|
Set source = new HashSet();
|
||||||
|
JSONArray objects = JSONArray.parseArray(set.toString());
|
||||||
|
for (Object object : objects) {
|
||||||
|
source.add(object);
|
||||||
|
}
|
||||||
|
QFilter qf = new QFilter("id", QCP.equals, Long.valueOf(id.toString()));
|
||||||
|
DynamicObject maintenancebill = BusinessDataServiceHelper.loadSingle("zcgj_maintenancebill", new QFilter[]{qf});
|
||||||
|
DynamicObjectCollection maintenanceentry = maintenancebill.getDynamicObjectCollection("entryentity");
|
||||||
|
maintenanceentry.removeIf(entry -> source.contains(entry.getString("id")));//去除之前单据已有的数据
|
||||||
|
DynamicObjectCollection entryentity = (DynamicObjectCollection) getModel().getValue("zcgj_entryentity");
|
||||||
|
entryentity.clear();
|
||||||
|
for (int i = 0; i < maintenanceentry.size(); i++) {
|
||||||
|
DynamicObject object = maintenanceentry.get(i);
|
||||||
|
i = this.getModel().createNewEntryRow("zcgj_entryentity");
|
||||||
|
this.getModel().setValue("zcgj_equipment", object.getDynamicObject("zcgj_equipment"), i);
|
||||||
|
this.getModel().setValue("zcgj_fault", object.getString("zcgj_fault"), i);
|
||||||
|
this.getModel().setValue("zcgj_faultreason", object.getString("zcgj_faultreason"), i);
|
||||||
|
this.getModel().setValue("zcgj_amount", object.getBigDecimal("zcgj_amount"), i);
|
||||||
|
this.getModel().setValue("zcgj_contacts", object.getString("zcgj_contacts"), i);
|
||||||
|
this.getModel().setValue("zcgj_supplier", object.getDynamicObject("zcgj_supplier"), i);
|
||||||
|
this.getModel().setValue("zcgj_sourceid", object.getString("id"), i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerListener(EventObject e) {
|
||||||
|
super.registerListener(e);
|
||||||
|
Button btnok = this.getControl("btnok");//确定
|
||||||
|
btnok.addClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void click(EventObject evt) {
|
||||||
|
super.click(evt);
|
||||||
|
Control source = (Control) evt.getSource();
|
||||||
|
String key = source.getKey();
|
||||||
|
if(key.equals("btnok")){
|
||||||
|
EntryGrid entryGrid = this.getControl("zcgj_entryentity");
|
||||||
|
int[] selectRows = entryGrid.getSelectRows();
|
||||||
|
int count = selectRows.length;
|
||||||
|
//分录行数只有一条的时候才能通过接下来两个if
|
||||||
|
if (count == 0) {
|
||||||
|
this.getView().showErrorNotification("请选择至少一条维修申请信息!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DynamicObjectCollection qeug_entryentity = getModel().getEntryEntity("zcgj_entryentity");//分录
|
||||||
|
DynamicObjectCollection collection = new DynamicObjectCollection();
|
||||||
|
for (int selectRow : selectRows) {
|
||||||
|
collection.add(qeug_entryentity.get(selectRow));
|
||||||
|
}
|
||||||
|
this.getView().returnDataToParent(collection);
|
||||||
|
this.getView().close();
|
||||||
|
} else if (key.equals("btncancel")) {
|
||||||
|
this.getView().close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue