资金计划申请发票导入
This commit is contained in:
parent
1a0173dcc0
commit
62a7a538c8
|
|
@ -0,0 +1,98 @@
|
||||||
|
package zcgj.zcdev.zcdev.pr.plugin.operate;
|
||||||
|
|
||||||
|
import kd.bos.dataentity.OperateOption;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
|
import kd.bos.dataentity.entity.LocaleString;
|
||||||
|
import kd.bos.entity.operate.OperateOptionConst;
|
||||||
|
import kd.bos.entity.operate.result.OperationResult;
|
||||||
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||||
|
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
||||||
|
import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
|
||||||
|
import kd.bos.logging.Log;
|
||||||
|
import kd.bos.logging.LogFactory;
|
||||||
|
import kd.bos.message.api.MessageChannels;
|
||||||
|
import kd.bos.metadata.dao.MetaCategory;
|
||||||
|
import kd.bos.metadata.dao.MetadataDao;
|
||||||
|
import kd.bos.metadata.form.FormMetadata;
|
||||||
|
import kd.bos.orm.query.QCP;
|
||||||
|
import kd.bos.orm.query.QFilter;
|
||||||
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import kd.bos.servicehelper.operation.DeleteServiceHelper;
|
||||||
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||||
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||||
|
import kd.bos.servicehelper.workflow.MessageCenterServiceHelper;
|
||||||
|
import kd.bos.workflow.engine.msg.info.MessageInfo;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支出财务确认单删除时删除发票绑定关系
|
||||||
|
*/
|
||||||
|
public class OutFinaceconfirmDelInvoiceBindOp extends AbstractOperationServicePlugIn {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(OutFinaceconfirmDelInvoiceBindOp.class);
|
||||||
|
//OperationResult result = OperationServiceHelper.executeOperate("submit", "ec_out_contract_settle", new DynamicObject[]{outContractSettle}, option);
|
||||||
|
//
|
||||||
|
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||||
|
e.getFieldKeys().add("zcgj_ec_out_contractid"); //支出结算单id
|
||||||
|
e.getFieldKeys().add("zcgj_entryentity"); //发票分录
|
||||||
|
e.getFieldKeys().add("zcgj_entryentity.zcgj_invoice"); //发票
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void endOperationTransaction(EndOperationTransactionArgs e) {
|
||||||
|
String operationKey = e.getOperationKey();
|
||||||
|
DynamicObject[] dataEntities = e.getDataEntities();
|
||||||
|
switch (operationKey) {
|
||||||
|
case "delete"://删除
|
||||||
|
case "delback":
|
||||||
|
deleteInvoiceBind(dataEntities);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除支出财务确认单发票绑定关系
|
||||||
|
*/
|
||||||
|
public void deleteInvoiceBind(DynamicObject[] dataEntities){
|
||||||
|
for (DynamicObject dataEntity : dataEntities) {
|
||||||
|
long pkValue = dataEntity.getLong("id");//支出合同确认单id
|
||||||
|
|
||||||
|
List<Long> delInvoiceIds = new ArrayList<>();
|
||||||
|
DynamicObjectCollection invoiceCollection = dataEntity.getDynamicObjectCollection("zcgj_entryentity");
|
||||||
|
for (DynamicObject dynamicObject : invoiceCollection) {
|
||||||
|
DynamicObject zcgjInvoice = dynamicObject.getDynamicObject("zcgj_invoice");
|
||||||
|
if (zcgjInvoice!=null){
|
||||||
|
delInvoiceIds.add( zcgjInvoice.getLong("id"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicObject[] invoices = BusinessDataServiceHelper.load("ec_in_invoice", "isinvoiceclaim,isclaimed,contract,project,connecttype,serialno,zcgj_isbind",
|
||||||
|
new QFilter[]{new QFilter("id", "in", delInvoiceIds)});
|
||||||
|
List<String> invoiceserialno = new ArrayList<>();
|
||||||
|
for (DynamicObject invData : invoices) {
|
||||||
|
invData.set("isclaimed", false);
|
||||||
|
invData.set("contract", (Object)null);
|
||||||
|
invData.set("project", (Object)null);
|
||||||
|
invData.set("connecttype", "null");
|
||||||
|
invData.set("zcgj_isbind", false);
|
||||||
|
String serialno = invData.getString("serialno");
|
||||||
|
invoiceserialno.add(serialno);
|
||||||
|
|
||||||
|
}
|
||||||
|
if(!delInvoiceIds.isEmpty()){
|
||||||
|
SaveServiceHelper.save(invoices);
|
||||||
|
}
|
||||||
|
|
||||||
|
QFilter idFilter = new QFilter("expense_id", QCP.equals,pkValue);
|
||||||
|
QFilter serialnoFilter = new QFilter("serial_no", QCP.in,invoiceserialno);
|
||||||
|
//DynamicObject[] loadInvoiceData = BusinessDataServiceHelper.load("rim_expense_relation", "serial_no", new QFilter[]{idFilter,serialnoFilter});
|
||||||
|
DeleteServiceHelper.delete("rim_expense_relation", new QFilter[]{idFilter.and(serialnoFilter)});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue