支出合同财务确认单开发

This commit is contained in:
zhangzhiguo 2025-05-27 18:11:55 +08:00
parent fc28124fb1
commit 93cf520923
5 changed files with 221 additions and 6 deletions

View File

@ -16,12 +16,12 @@ import java.util.Map;
import java.util.Set;
/**
* 出合同结算凭证反写插件
* 出合同结算凭证反写插件
*/
public class EcContartVoucherPlugin extends AbstractDapWriteBackImpl {
public static final Log log = LogFactory.getLog(EcContartVoucherPlugin.class);
//采购申请单上要反写的凭证号字段名
//目标单据要反写的凭证号字段名
public static final String voucherNoFile="fk_zcgj_voucherbillno";
@Override
protected DBRoute getDBRoute() {

View File

@ -18,6 +18,8 @@ import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.mvc.list.ListView;
import kd.bos.openapi.common.result.OpenApiResult;
import kd.bos.openapi.common.util.OpenApiSdkUtil;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.report.ReportList;
@ -27,9 +29,7 @@ import kd.ec.contract.common.enums.PayDirectionEnum;
import kd.sdk.plugin.Plugin;
import java.math.BigDecimal;
import java.util.EventObject;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
/**
* 支出合同结算财务确认单
@ -63,6 +63,56 @@ public class OutContractFinaceConfirmeListPlugin extends AbstractListPlugin impl
getView().showForm(showParameter);
}
}
@Override
public void itemClick(ItemClickEvent evt) {
super.itemClick(evt);
String itemKey = evt.getItemKey();
/*if("zcgj_deletevoucher".equals(itemKey)){
BillList billList = this.getView().getControl(AbstractListPlugin.BILLLISTID);
//获取到选中行的数据
ListSelectedRowCollection selectedRows = billList.getSelectedRows();
if(selectedRows.isEmpty()){
this.getView().showTipNotification(String.format("请选择需要删除凭证的数据。"));
return;
}
List<Long> voucherIds = new ArrayList<>();
int errorCount =0;
int allCount =0;
int successCount =0;
for (ListSelectedRow selectedRow : selectedRows) {
Long pk = (Long) selectedRow.getPrimaryKeyValue();
log.info("OutContractFinaceConfirmeListPlugin-delete:billid:"+pk);
DynamicObject voucherObject = BusinessDataServiceHelper.loadSingle("gl_voucher", "id",
new QFilter[]{new QFilter("sourcebill", QCP.equals, pk)
.and(new QFilter("sourcebilltype.number", QCP.equals, "zcgj_ec_out_finaceconfirm"))
//.and(new QFilter("billno", QCP.equals, vouchernum))
});
long voucherId = voucherObject.getLong("id");
log.info("TaskListBuildVoucherPlugin-delete:voucherId:"+voucherId);
Map<String,Object> params = new HashMap<String,Object>();
Map<String,Long> idMap = new HashMap<>();
idMap.put("id", voucherId);
params.put("data",idMap);
OpenApiResult invoke = OpenApiSdkUtil.invoke("/v2/gl/gl_voucher/delete", params);
Map<String, Object> map = invoke.toMap();
if(map.get("status").toString().equals("true")){
successCount++;
}else{
errorCount++;
log.info("OutContractFinaceConfirmeListPlugin-delete:error:"+invoke.getMessage());
}
allCount++;
}
if(errorCount == 0){//没有失败的使用成功弹框提醒
this.getView().showSuccessNotification(String.format("删除凭证完成,一共%d条成功%d条失败%d条。",allCount,successCount,errorCount));
}else{//有失败的使用警告弹框提醒
this.getView().showTipNotification(String.format("删除凭证完成,一共%d条成功%d条失败%d条。",allCount,successCount,errorCount));
}
this.getView().invokeOperation("refresh");//调用表单的刷新操作
}*/
}
}

View File

@ -10,12 +10,19 @@ import kd.bos.entity.datamodel.events.BizDataEventArgs;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.FormShowParameter;
import kd.bos.form.ShowType;
import kd.bos.form.control.Control;
import kd.bos.form.control.EntryGrid;
import kd.bos.form.events.HyperLinkClickEvent;
import kd.bos.form.events.HyperLinkClickListener;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.report.ReportList;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.ec.contract.common.enums.DirectionEnum;
import kd.sdk.plugin.Plugin;
import javax.swing.event.HyperlinkListener;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.EventObject;
@ -23,7 +30,7 @@ import java.util.EventObject;
/**
* 支出合同确认单插件
*/
public class OutContractFinaceConfirmePlugin extends AbstractBillPlugIn implements Plugin {
public class OutContractFinaceConfirmePlugin extends AbstractBillPlugIn implements Plugin, HyperLinkClickListener {
@Override
@ -50,6 +57,7 @@ public class OutContractFinaceConfirmePlugin extends AbstractBillPlugIn impleme
QFilter accountTableFilter = new QFilter("id", QCP.equals,(Long)contractSettleIdObj);
DynamicObject ecoutcontractsettle = BusinessDataServiceHelper.loadSingle("ec_out_contract_settle", new QFilter[]{accountTableFilter});
getModel().setValue("zcgj_ec_out_contract_sett",ecoutcontractsettle.getLong("id"));
getModel().setValue("zcgj_ec_out_contract_name",ecoutcontractsettle.getString("billname"));
getModel().setValue("zcgj_ec_out_contractid", ecoutcontractsettle.getLong("id")); //id文本冗余
getModel().setValue("zcgj_billname",ecoutcontractsettle.getString("billname"));
getModel().setValue("zcgj_contract",ecoutcontractsettle.getDynamicObject("contract"));
@ -67,6 +75,7 @@ public class OutContractFinaceConfirmePlugin extends AbstractBillPlugIn impleme
DynamicObjectCollection itementry = ecoutcontractsettle.getDynamicObjectCollection("itementry");
//DynamicObjectCollection entryEntity = this.getModel().getEntryEntity("zcgj_itementry");
DynamicObjectCollection entryEntity1 = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_itementry");
entryEntity1.clear();
for (DynamicObject dynamicObject : itementry) {
DynamicObject item = entryEntity1.addNew();
item.set("zcgj_payitem",dynamicObject.getDynamicObject("payitem"));
@ -118,4 +127,37 @@ public class OutContractFinaceConfirmePlugin extends AbstractBillPlugIn impleme
}
}
/**
* 发票分录超链接跳转到详情
*/
@Override
public void registerListener(EventObject e) {
super.registerListener(e);
EntryGrid control = this.getControl("zcgj_entryentity");
control.addHyperClickListener(this);
}
@Override
public void hyperLinkClick(HyperLinkClickEvent hyperLinkClickEvent) {
String fieldName = hyperLinkClickEvent.getFieldName();
EntryGrid entryGrid = getView().getControl("zcgj_entryentity");
int[] selectRows = entryGrid.getSelectRows();
if(selectRows != null && selectRows.length == 1){
DynamicObjectCollection dynamicObjectCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_entryentity");
DynamicObject dynamicObject = dynamicObjectCollection.get(selectRows[0]);
DynamicObject zcgjInvoice = dynamicObject.getDynamicObject("zcgj_invoice");
long invoiceId = zcgjInvoice.getLong("id");
if(invoiceId != 0){
//弹出发票详情
BillShowParameter showParameter = new BillShowParameter();
showParameter.setPkId(invoiceId);
showParameter.setFormId("ec_in_invoice");
showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage); //打开方式
getView().showForm(showParameter);
}
}else{
this.getView().showTipNotification("请选择一条发票数据。");
}
}
}

View File

@ -0,0 +1,118 @@
package zcgj.zcdev.zcdev.pr.plugin.form;
import kd.bos.db.DB;
import kd.bos.db.DBRoute;
import kd.bos.entity.EntityMetadataCache;
import kd.bos.entity.MainEntityType;
import kd.bos.ext.fi.ai.AbstractDapWriteBackImpl;
import kd.bos.ext.fi.ai.Voucher;
import kd.bos.ext.fi.ai.VoucherOperation;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 支出合同财务确认凭证反写插件
*/
public class OutContractFinaceConfirmeVoucherPlugin extends AbstractDapWriteBackImpl {
public static final Log log = LogFactory.getLog(OutContractFinaceConfirmeVoucherPlugin.class);
//目标单据需要反写的凭证号字段名
public static final String voucherNoFile="fk_zcgj_voucherbillno";
@Override
protected DBRoute getDBRoute() {
// 扩展开发库的分库标识实际值可以查看mc分库标识
DBRoute DBR = DBRoute.of("scm");
return DBR;
}
// 删除凭证写入的值这里是复选框- 布尔false
@Override
protected Object getVchDisableStatus() {
Boolean disRchValue = false;
return disRchValue;
}
// 生成凭证时写入的值这里是复选框- 布尔 true
@Override
protected Object getVchEnableStatus() {
Boolean rchValue = true;
return rchValue;
}
// 要反写的字段,反写的是常量值反写凭证的一些其他信息回单据只能重写writeBack方法
@Override
protected String getVchStatusField() {
String vchField = "fk_zcgj_isvoucher";
return vchField;
}
@Override
public void writeBack(VoucherOperation operation, String billEntityNumber, Map<Long, Voucher> billToVch) {
MainEntityType mt = EntityMetadataCache.getDataEntityType(billEntityNumber);
Set<Long> keySet = billToVch.keySet();
log.info("AbstractDapWriteBackImpl#keySet:" + keySet);
if (VoucherOperation.Create.equals(operation)) {
log.info("AbstractDapWriteBackImpl#开始执行生成凭证反写:" + operation);
Object vchStatusField = getVchEnableStatus();
List<Object[]> params = new ArrayList<>();
for (Long me : keySet) {
log.info("AbstractDapWriteBackImpl#生成凭证的单据ID" + me);
Voucher voucher=billToVch.get(me);//凭证
String voucherNo = voucher.getVoucherNo();
//这里处理的是一个单据只有一个凭证的时候如果是多个凭证可以先获取已经生成的凭证号再拼接上字符串
Object[] param = new Object[] { vchStatusField,voucherNo, me };//
params.add(param);
if (params.size() >= 10000) {
log.info("AbstractDapWriteBackImpl#开始执行生成凭证反写SQL");
log.info("AbstractDapWriteBackImpl#mt.getAlias()" + mt.getAlias());
log.info("AbstractDapWriteBackImpl#mt.getVchStatusField()" + getVchStatusField());
DB.executeBatch(getDBRoute(),
"update " + mt.getAlias() + " set " + getVchStatusField() + " = ? , "+voucherNoFile+" = ? where fid = ?", params);
log.info("AbstractDapWriteBackImpl#结束执行生成凭证反写SQL");
params.clear();
}
}
log.info("AbstractDapWriteBackImpl#最后#开始执行生成凭证反写SQL");
log.info("AbstractDapWriteBackImpl#最后#mt.getAlias()" + mt.getAlias());
log.info("AbstractDapWriteBackImpl#最后#mt.getVchStatusField()" + getVchStatusField());
if (params.size() > 0) {
DB.executeBatch(getDBRoute(),
"update " + mt.getAlias() + " set " + getVchStatusField() + " = ? , "+voucherNoFile+" = ? where fid = ?", params);
}
log.info("AbstractDapWriteBackImpl#最后#结束执行生成凭证反写SQL");
} else if (VoucherOperation.Delete.equals(operation)) {
log.info("AbstractDapWriteBackImpl#开始执行删除凭证反写:" + operation);
Object vchDisableStatus = getVchDisableStatus();
List<Object[]> params = new ArrayList<>();
for (Long me : keySet) {
log.info("AbstractDapWriteBackImpl#删除凭证的单据ID" + me);
//这里处理的是一个单据只有一个凭证的时候如果是多个凭证可以先获取已经生成的凭证号再去掉本凭证之后的凭证号
Object[] param = new Object[] {vchDisableStatus, "",me };// getVchDisableStatus
params.add(param);
if (params.size() >= 10000) {
log.info("AbstractDapWriteBackImpl#开始执行删除凭证反写SQL");
log.info("AbstractDapWriteBackImpl#mt.getAlias()" + mt.getAlias());
log.info("AbstractDapWriteBackImpl#mt.getVchStatusField()" + getVchStatusField());
DB.executeBatch(getDBRoute(),
"update " + mt.getAlias() + " set " + getVchStatusField() + " = ? , "+voucherNoFile+" = ? where fid = ?", params);
params.clear();
log.info("AbstractDapWriteBackImpl#结束执行删除凭证反写SQL");
}
}
log.info("AbstractDapWriteBackImpl#最后#开始执行删除凭证反写SQL");
log.info("AbstractDapWriteBackImpl#最后#mt.getAlias()" + mt.getAlias());
log.info("AbstractDapWriteBackImpl#最后#mt.getVchStatusField()" + getVchStatusField());
if (params.size() > 0) {
DB.executeBatch(getDBRoute(),
"update " + mt.getAlias() + " set " + getVchStatusField() + " = ? , "+voucherNoFile+" = ? where fid = ?", params);
}
log.info("AbstractDapWriteBackImpl#最后#结束执行删除凭证反写SQL");
}
}
}

View File

@ -5,7 +5,10 @@ import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.ListSelectedRow;
import kd.bos.entity.datamodel.ListSelectedRowCollection;
import kd.bos.form.FormShowParameter;
import kd.bos.form.IFormView;
import kd.bos.form.IPageCache;
import kd.bos.form.ShowType;
import kd.bos.form.container.Tab;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.form.events.HyperLinkClickArgs;
import kd.bos.list.BillList;
@ -19,6 +22,7 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -65,6 +69,7 @@ public class OutContractSettleFiConfirmeListPlugin extends AbstractListPlugin im
showParameter.setFormId("zcgj_ec_out_finaceconfirm");
showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage); //打开方式
getView().showForm(showParameter);
}else{
this.getView().showTipNotification(String.format("只有已审核通过的数据才可进行财务确认操作。"));
return;