资金计划申请获取科目余额
This commit is contained in:
		
							parent
							
								
									ca41d06a43
								
							
						
					
					
						commit
						c670a6d56d
					
				| 
						 | 
				
			
			@ -0,0 +1,402 @@
 | 
			
		|||
package zcgj.zcdev.zcdev.pr.plugin.form;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.Gson;
 | 
			
		||||
import com.google.gson.reflect.TypeToken;
 | 
			
		||||
import kd.bos.bill.AbstractBillPlugIn;
 | 
			
		||||
import kd.bos.bill.BillShowParameter;
 | 
			
		||||
import kd.bos.bill.OperationStatus;
 | 
			
		||||
import kd.bos.dataentity.entity.DynamicObject;
 | 
			
		||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
 | 
			
		||||
import kd.bos.dataentity.entity.MulBasedataDynamicObjectCollection;
 | 
			
		||||
import kd.bos.entity.datamodel.events.ChangeData;
 | 
			
		||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
 | 
			
		||||
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.servicehelper.BusinessDataServiceHelper;
 | 
			
		||||
import kd.bos.servicehelper.user.UserServiceHelper;
 | 
			
		||||
import kd.bos.util.StringUtils;
 | 
			
		||||
import kd.fi.bcm.business.model.BalanceQueryParamApi;
 | 
			
		||||
import kd.sdk.plugin.Plugin;
 | 
			
		||||
import zcgj.zcdev.zcdev.pr.plugin.utils.AccountRecord;
 | 
			
		||||
 | 
			
		||||
import java.lang.reflect.Type;
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 资金计划申请科目余额取数插件
 | 
			
		||||
 */
 | 
			
		||||
public class FundingplanapplyAccountBalancePlugin extends AbstractBillPlugIn implements Plugin {
 | 
			
		||||
    String[] selectorsArray = new String[]{"beginlocal", "endlocal", "yeardebitfor", "yearcreditfor", "debitlocal", "creditlocal"};
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void afterBindData(EventObject e) {
 | 
			
		||||
        super.afterBindData(e);
 | 
			
		||||
        BillShowParameter bsp=(BillShowParameter)this.getView().getFormShowParameter();
 | 
			
		||||
        if(bsp.getStatus()== OperationStatus.ADDNEW ){
 | 
			
		||||
            fundplyentry();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void propertyChanged(PropertyChangedArgs e) {
 | 
			
		||||
        super.propertyChanged(e);
 | 
			
		||||
        String name = e.getProperty().getName();
 | 
			
		||||
        ChangeData changeData = e.getChangeSet()[0];
 | 
			
		||||
        if(name.equals("zcgj_in_custom") ){
 | 
			
		||||
            int rowIndex = changeData.getRowIndex();
 | 
			
		||||
            MulBasedataDynamicObjectCollection  customs = (MulBasedataDynamicObjectCollection ) changeData.getNewValue();
 | 
			
		||||
            if(customs!=null && !customs.isEmpty()){
 | 
			
		||||
                customerBalance(rowIndex,customs);
 | 
			
		||||
            }
 | 
			
		||||
        }else if(name.equals("zcgj_out_supplier") ){
 | 
			
		||||
            int rowIndex = changeData.getRowIndex();
 | 
			
		||||
            MulBasedataDynamicObjectCollection  suppliers = (MulBasedataDynamicObjectCollection ) changeData.getNewValue();
 | 
			
		||||
            if(suppliers!=null && !suppliers.isEmpty()){
 | 
			
		||||
                supplierBalance(rowIndex,suppliers);
 | 
			
		||||
            }
 | 
			
		||||
        }else if(name.equals("zcgj_period") ){
 | 
			
		||||
 | 
			
		||||
            DynamicObjectCollection infundproject = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_infundproject_entry");
 | 
			
		||||
            for (int i = 0; i < infundproject.size(); i++) {
 | 
			
		||||
                MulBasedataDynamicObjectCollection dynamicObjectCollection =  (MulBasedataDynamicObjectCollection)infundproject.get(i).getDynamicObjectCollection("zcgj_in_custom");
 | 
			
		||||
                if(dynamicObjectCollection!=null && !dynamicObjectCollection.isEmpty()){
 | 
			
		||||
                    customerBalance(i,dynamicObjectCollection);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            DynamicObjectCollection outfundproject = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_outfundproject_entry");
 | 
			
		||||
            for (int i = 0; i < outfundproject.size(); i++) {
 | 
			
		||||
                MulBasedataDynamicObjectCollection dynamicObjectCollection = (MulBasedataDynamicObjectCollection)outfundproject.get(i).getDynamicObjectCollection("zcgj_out_supplier");
 | 
			
		||||
                if(dynamicObjectCollection!=null && !dynamicObjectCollection.isEmpty()){
 | 
			
		||||
                    supplierBalance(i,dynamicObjectCollection);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void customerBalance(int rowIndex, MulBasedataDynamicObjectCollection customs){
 | 
			
		||||
        if(customs!=null){
 | 
			
		||||
            DynamicObject org = (DynamicObject)this.getModel().getValue("zcgj_org");
 | 
			
		||||
            if(org == null){
 | 
			
		||||
                this.getView().showErrorNotification("请选择所属组织!");
 | 
			
		||||
            }
 | 
			
		||||
            BalanceQueryParamApi balanceQueryParamApi = new BalanceQueryParamApi();
 | 
			
		||||
            balanceQueryParamApi.setSelectors(Arrays.asList(selectorsArray));
 | 
			
		||||
            balanceQueryParamApi.setOrgNumber(org.getString("number"));
 | 
			
		||||
            balanceQueryParamApi.setBookTypeNumber("100002"); //账簿类型
 | 
			
		||||
            balanceQueryParamApi.setAccountTableNumber("0003");//科目表
 | 
			
		||||
 | 
			
		||||
            DynamicObject period = (DynamicObject)this.getModel().getValue("zcgj_period");
 | 
			
		||||
            if(period == null){
 | 
			
		||||
                //this.getView().showErrMessage("请选择期间!");
 | 
			
		||||
                this.getView().showErrorNotification("请选择期间!");
 | 
			
		||||
            }
 | 
			
		||||
            balanceQueryParamApi.setPeriodNumber(period.getString("number")); //
 | 
			
		||||
            List<String> groupBy = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
            Map<String, List<Map<String, String>>> accountAssgrp = new HashMap<>();
 | 
			
		||||
            List<Map<String, String>> li = new ArrayList<>();
 | 
			
		||||
            for (DynamicObject custom : customs) {
 | 
			
		||||
                Map<String, String> map1 = new HashMap<>();
 | 
			
		||||
                DynamicObject basedataObj = custom.getDynamicObject("fbasedataid");
 | 
			
		||||
                DynamicObject customer = BusinessDataServiceHelper.loadSingle( basedataObj.getPkValue(), "bd_customer");
 | 
			
		||||
                map1.put("0001", customer.getString("number"));
 | 
			
		||||
                li.add(map1);
 | 
			
		||||
            }
 | 
			
		||||
            accountAssgrp.put("1122", li);
 | 
			
		||||
            balanceQueryParamApi.setAccountAssgrp(accountAssgrp);
 | 
			
		||||
            groupBy.add("0001");
 | 
			
		||||
            groupBy.add("account");
 | 
			
		||||
            Gson gson = new Gson();
 | 
			
		||||
            String json = gson.toJson(balanceQueryParamApi);
 | 
			
		||||
            Map<String, Object> params = gson.fromJson(json,
 | 
			
		||||
                    new TypeToken<Map<String, Object>>() {
 | 
			
		||||
                    }.getType());
 | 
			
		||||
            OpenApiResult balanceData = OpenApiSdkUtil.invoke("/v2/gl/getBalanceApi", params);
 | 
			
		||||
 | 
			
		||||
            if (balanceData.isStatus()) {
 | 
			
		||||
                String data = (String) balanceData.getData();
 | 
			
		||||
                Type listType = new TypeToken<List<AccountRecord>>() {
 | 
			
		||||
                }.getType();
 | 
			
		||||
                List<AccountRecord> records = gson.fromJson(data, listType);
 | 
			
		||||
 | 
			
		||||
                BigDecimal totalbeginlocal = BigDecimal.ZERO;
 | 
			
		||||
                BigDecimal totayeardebitfor = BigDecimal.ZERO;
 | 
			
		||||
                BigDecimal totalyearcreditfor = BigDecimal.ZERO;
 | 
			
		||||
                for (AccountRecord record : records) {
 | 
			
		||||
                    totalbeginlocal = totalbeginlocal.add(record.getBeginlocal());//期初本位币金额
 | 
			
		||||
                    totayeardebitfor = totayeardebitfor.add(record.getYeardebitfor());//yeardebitfor
 | 
			
		||||
                    totalyearcreditfor = totalyearcreditfor.add(record.getYearcreditfor());//yearcreditfor
 | 
			
		||||
                }
 | 
			
		||||
                DynamicObjectCollection zcgjFinApprovedAmount = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_infundproject_entry");
 | 
			
		||||
                DynamicObject dynamicObject = zcgjFinApprovedAmount.get(rowIndex);
 | 
			
		||||
                dynamicObject.set("zcgj_iinitialreceivable",totalbeginlocal);//年初余额取科目余额表年初数
 | 
			
		||||
                dynamicObject.set("zcgj_ytdoutputvalue",totayeardebitfor);//本年累计结算-借方
 | 
			
		||||
                dynamicObject.set("zcgj_ytdpaymentreceived",totalyearcreditfor);//本年累计回款-贷方
 | 
			
		||||
                this.getView().updateView("zcgj_infundproject_entry");
 | 
			
		||||
            }
 | 
			
		||||
        }else{
 | 
			
		||||
            DynamicObjectCollection zcgjFinApprovedAmount = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_infundproject_entry");
 | 
			
		||||
            DynamicObject dynamicObject = zcgjFinApprovedAmount.get(rowIndex);
 | 
			
		||||
            dynamicObject.set("zcgj_iinitialreceivable",BigDecimal.ZERO);//年初余额取科目余额表年初数
 | 
			
		||||
            dynamicObject.set("zcgj_ytdoutputvalue",BigDecimal.ZERO);//本年累计结算-借方
 | 
			
		||||
            dynamicObject.set("zcgj_ytdpaymentreceived",BigDecimal.ZERO);//本年累计回款-贷方
 | 
			
		||||
            this.getView().updateView("zcgj_infundproject_entry");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void supplierBalance(int rowIndex, MulBasedataDynamicObjectCollection  suppliers){
 | 
			
		||||
        if(suppliers!=null){
 | 
			
		||||
            DynamicObject org = (DynamicObject)this.getModel().getValue("zcgj_org");
 | 
			
		||||
            if(org == null){
 | 
			
		||||
                this.getView().showErrorNotification("请选择所属组织!");
 | 
			
		||||
            }
 | 
			
		||||
            BalanceQueryParamApi balanceQueryParamApi = new BalanceQueryParamApi();
 | 
			
		||||
            balanceQueryParamApi.setSelectors(Arrays.asList(selectorsArray));
 | 
			
		||||
            balanceQueryParamApi.setOrgNumber(org.getString("number"));
 | 
			
		||||
            balanceQueryParamApi.setBookTypeNumber("100002"); //账簿类型
 | 
			
		||||
            balanceQueryParamApi.setAccountTableNumber("0003");//科目表
 | 
			
		||||
 | 
			
		||||
            DynamicObject period = (DynamicObject)this.getModel().getValue("zcgj_period");
 | 
			
		||||
            if(period == null){
 | 
			
		||||
                //this.getView().showErrMessage("请选择期间!");
 | 
			
		||||
                this.getView().showErrorNotification("请选择期间!");
 | 
			
		||||
            }
 | 
			
		||||
            balanceQueryParamApi.setPeriodNumber(period.getString("number")); //
 | 
			
		||||
            List<String> groupBy = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
            Map<String, List<Map<String, String>>> accountAssgrp = new HashMap<>();
 | 
			
		||||
            List<Map<String, String>> li = new ArrayList<>();
 | 
			
		||||
            for (DynamicObject supplier : suppliers) {
 | 
			
		||||
                Map<String, String> map1 = new HashMap<>();
 | 
			
		||||
                DynamicObject basedataObj = supplier.getDynamicObject("fbasedataid");
 | 
			
		||||
                DynamicObject customer = BusinessDataServiceHelper.loadSingle( basedataObj.getPkValue(), "bd_supplier");
 | 
			
		||||
                map1.put("0005", customer.getString("number"));
 | 
			
		||||
                li.add(map1);
 | 
			
		||||
            }
 | 
			
		||||
            accountAssgrp.put("2202", li);
 | 
			
		||||
            balanceQueryParamApi.setAccountAssgrp(accountAssgrp);
 | 
			
		||||
            groupBy.add("0005");
 | 
			
		||||
            groupBy.add("account");
 | 
			
		||||
            Gson gson = new Gson();
 | 
			
		||||
            String json = gson.toJson(balanceQueryParamApi);
 | 
			
		||||
            Map<String, Object> params = gson.fromJson(json,
 | 
			
		||||
                    new TypeToken<Map<String, Object>>() {
 | 
			
		||||
                    }.getType());
 | 
			
		||||
            OpenApiResult balanceData = OpenApiSdkUtil.invoke("/v2/gl/getBalanceApi", params);
 | 
			
		||||
 | 
			
		||||
            if (balanceData.isStatus()) {
 | 
			
		||||
                String data = (String) balanceData.getData();
 | 
			
		||||
                Type listType = new TypeToken<List<AccountRecord>>() {
 | 
			
		||||
                }.getType();
 | 
			
		||||
                List<AccountRecord> records = gson.fromJson(data, listType);
 | 
			
		||||
 | 
			
		||||
                BigDecimal totalbeginlocal = BigDecimal.ZERO;
 | 
			
		||||
                BigDecimal totayeardebitfor = BigDecimal.ZERO;
 | 
			
		||||
                BigDecimal totalyearcreditfor = BigDecimal.ZERO;
 | 
			
		||||
                for (AccountRecord record : records) {
 | 
			
		||||
                    totalbeginlocal = totalbeginlocal.add(record.getBeginlocal());//期初本位币金额
 | 
			
		||||
                    totayeardebitfor = totayeardebitfor.add(record.getYeardebitfor());//yeardebitfor
 | 
			
		||||
                    totalyearcreditfor = totalyearcreditfor.add(record.getYearcreditfor());//yearcreditfor
 | 
			
		||||
                }
 | 
			
		||||
                DynamicObjectCollection zcgjFinApprovedAmount = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_outfundproject_entry");
 | 
			
		||||
                DynamicObject dynamicObject = zcgjFinApprovedAmount.get(rowIndex);
 | 
			
		||||
                dynamicObject.set("zcgj_openingpayable",totalbeginlocal);//年初余额取科目余额表年初数
 | 
			
		||||
                dynamicObject.set("zcgj_ytdnetsettlement",totayeardebitfor);//本年累计结算-借方
 | 
			
		||||
                dynamicObject.set("zcgj_ytdtotalpayment",totalyearcreditfor);//本年累计付款-贷方
 | 
			
		||||
                this.getView().updateView("zcgj_outfundproject_entry");
 | 
			
		||||
            }
 | 
			
		||||
        }else{
 | 
			
		||||
            DynamicObjectCollection zcgjFinApprovedAmount = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_outfundproject_entry");
 | 
			
		||||
            DynamicObject dynamicObject = zcgjFinApprovedAmount.get(rowIndex);
 | 
			
		||||
            dynamicObject.set("zcgj_openingpayable",BigDecimal.ZERO);//年初余额取科目余额表年初数
 | 
			
		||||
            dynamicObject.set("zcgj_ytdnetsettlement",BigDecimal.ZERO);//本年累计结算-借方
 | 
			
		||||
            dynamicObject.set("zcgj_ytdtotalpayment",BigDecimal.ZERO);//本年累计付款-贷方
 | 
			
		||||
            this.getView().updateView("zcgj_outfundproject_entry");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //公司资金往来
 | 
			
		||||
    public void fundplyentry(){
 | 
			
		||||
        fundplyentryXJ();//现金
 | 
			
		||||
        fundplyentryYHCD();//银行承兑
 | 
			
		||||
        fundplyentryGYL();//供应链
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void fundplyentryXJ(){
 | 
			
		||||
        DynamicObject org = (DynamicObject)this.getModel().getValue("zcgj_org");
 | 
			
		||||
        if(org == null){
 | 
			
		||||
            this.getView().showErrorNotification("请选择所属组织!");
 | 
			
		||||
        }
 | 
			
		||||
        BalanceQueryParamApi balanceQueryParamApi = new BalanceQueryParamApi();
 | 
			
		||||
        balanceQueryParamApi.setSelectors(Arrays.asList(selectorsArray));
 | 
			
		||||
        balanceQueryParamApi.setOrgNumber(org.getString("number"));
 | 
			
		||||
        balanceQueryParamApi.setBookTypeNumber("100002"); //账簿类型
 | 
			
		||||
        balanceQueryParamApi.setAccountTableNumber("0003");//科目表
 | 
			
		||||
 | 
			
		||||
        DynamicObject period = (DynamicObject)this.getModel().getValue("zcgj_period");
 | 
			
		||||
        if(period == null){
 | 
			
		||||
            //this.getView().showErrMessage("请选择期间!");
 | 
			
		||||
            this.getView().showErrorNotification("请选择期间!");
 | 
			
		||||
        }
 | 
			
		||||
        balanceQueryParamApi.setPeriodNumber(period.getString("number")); //
 | 
			
		||||
        List<String> groupBy = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
        Map<String, List<Map<String, String>>> accountAssgrp = new HashMap<>();
 | 
			
		||||
        List<Map<String, String>> li = new ArrayList<>();
 | 
			
		||||
        accountAssgrp.put("1001", li); //现金
 | 
			
		||||
        accountAssgrp.put("1002", li); //现金
 | 
			
		||||
       // accountAssgrp.put("11260101", li); //银行承兑
 | 
			
		||||
        //accountAssgrp.put("11260301", li); //供应链
 | 
			
		||||
        balanceQueryParamApi.setAccountAssgrp(accountAssgrp);
 | 
			
		||||
        //groupBy.add("0005");
 | 
			
		||||
        groupBy.add("account");
 | 
			
		||||
        Gson gson = new Gson();
 | 
			
		||||
        String json = gson.toJson(balanceQueryParamApi);
 | 
			
		||||
        Map<String, Object> params = gson.fromJson(json,
 | 
			
		||||
                new TypeToken<Map<String, Object>>() {
 | 
			
		||||
                }.getType());
 | 
			
		||||
        OpenApiResult balanceData = OpenApiSdkUtil.invoke("/v2/gl/getBalanceApi", params);
 | 
			
		||||
 | 
			
		||||
        if (balanceData.isStatus()) {
 | 
			
		||||
            String data = (String) balanceData.getData();
 | 
			
		||||
            Type listType = new TypeToken<List<AccountRecord>>() {
 | 
			
		||||
            }.getType();
 | 
			
		||||
            List<AccountRecord> records = gson.fromJson(data, listType);
 | 
			
		||||
 | 
			
		||||
            BigDecimal totalbeginlocal = BigDecimal.ZERO;
 | 
			
		||||
            for (AccountRecord record : records) {
 | 
			
		||||
                totalbeginlocal = totalbeginlocal.add(record.getBeginlocal());//期初本位币金额
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            DynamicObjectCollection fundplyentry = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_fundplyentry");
 | 
			
		||||
            DynamicObject dynamicObject = fundplyentry.get(0);
 | 
			
		||||
            dynamicObject.set("zcgj_cashamt",totalbeginlocal);//现金
 | 
			
		||||
            this.getView().updateView("zcgj_fundplyentry");
 | 
			
		||||
        }else{
 | 
			
		||||
            DynamicObjectCollection fundplyentry = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_fundplyentry");
 | 
			
		||||
            DynamicObject dynamicObject = fundplyentry.get(0);
 | 
			
		||||
            dynamicObject.set("zcgj_cashamt",BigDecimal.ZERO);//现金
 | 
			
		||||
            this.getView().updateView("zcgj_fundplyentry");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void fundplyentryYHCD(){
 | 
			
		||||
        DynamicObject org = (DynamicObject)this.getModel().getValue("zcgj_org");
 | 
			
		||||
        if(org == null){
 | 
			
		||||
            this.getView().showErrorNotification("请选择所属组织!");
 | 
			
		||||
        }
 | 
			
		||||
        BalanceQueryParamApi balanceQueryParamApi = new BalanceQueryParamApi();
 | 
			
		||||
        balanceQueryParamApi.setSelectors(Arrays.asList(selectorsArray));
 | 
			
		||||
        balanceQueryParamApi.setOrgNumber(org.getString("number"));
 | 
			
		||||
        balanceQueryParamApi.setBookTypeNumber("100002"); //账簿类型
 | 
			
		||||
        balanceQueryParamApi.setAccountTableNumber("0003");//科目表
 | 
			
		||||
 | 
			
		||||
        DynamicObject period = (DynamicObject)this.getModel().getValue("zcgj_period");
 | 
			
		||||
        if(period == null){
 | 
			
		||||
            //this.getView().showErrMessage("请选择期间!");
 | 
			
		||||
            this.getView().showErrorNotification("请选择期间!");
 | 
			
		||||
        }
 | 
			
		||||
        balanceQueryParamApi.setPeriodNumber(period.getString("number")); //
 | 
			
		||||
        List<String> groupBy = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
        Map<String, List<Map<String, String>>> accountAssgrp = new HashMap<>();
 | 
			
		||||
        List<Map<String, String>> li = new ArrayList<>();
 | 
			
		||||
        //accountAssgrp.put("1001", li); //现金
 | 
			
		||||
        //accountAssgrp.put("1002", li); //现金
 | 
			
		||||
         accountAssgrp.put("11260101", li); //银行承兑
 | 
			
		||||
        //accountAssgrp.put("11260301", li); //供应链
 | 
			
		||||
        balanceQueryParamApi.setAccountAssgrp(accountAssgrp);
 | 
			
		||||
        //groupBy.add("0005");
 | 
			
		||||
        groupBy.add("account");
 | 
			
		||||
        Gson gson = new Gson();
 | 
			
		||||
        String json = gson.toJson(balanceQueryParamApi);
 | 
			
		||||
        Map<String, Object> params = gson.fromJson(json,
 | 
			
		||||
                new TypeToken<Map<String, Object>>() {
 | 
			
		||||
                }.getType());
 | 
			
		||||
        OpenApiResult balanceData = OpenApiSdkUtil.invoke("/v2/gl/getBalanceApi", params);
 | 
			
		||||
 | 
			
		||||
        if (balanceData.isStatus()) {
 | 
			
		||||
            String data = (String) balanceData.getData();
 | 
			
		||||
            Type listType = new TypeToken<List<AccountRecord>>() {
 | 
			
		||||
            }.getType();
 | 
			
		||||
            List<AccountRecord> records = gson.fromJson(data, listType);
 | 
			
		||||
 | 
			
		||||
            BigDecimal totalbeginlocal = BigDecimal.ZERO;
 | 
			
		||||
            for (AccountRecord record : records) {
 | 
			
		||||
                totalbeginlocal = totalbeginlocal.add(record.getBeginlocal());//期初本位币金额
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            DynamicObjectCollection fundplyentry = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_fundplyentry");
 | 
			
		||||
            DynamicObject dynamicObject = fundplyentry.get(0);
 | 
			
		||||
            dynamicObject.set("zcgj_bankamt",totalbeginlocal);//银行承兑
 | 
			
		||||
        }else{
 | 
			
		||||
            DynamicObjectCollection fundplyentry = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_fundplyentry");
 | 
			
		||||
            DynamicObject dynamicObject = fundplyentry.get(0);
 | 
			
		||||
            dynamicObject.set("zcgj_bankamt",BigDecimal.ZERO);//银行承兑
 | 
			
		||||
            this.getView().updateView("zcgj_fundplyentry");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void fundplyentryGYL(){
 | 
			
		||||
        DynamicObject org = (DynamicObject)this.getModel().getValue("zcgj_org");
 | 
			
		||||
        if(org == null){
 | 
			
		||||
            this.getView().showErrorNotification("请选择所属组织!");
 | 
			
		||||
        }
 | 
			
		||||
        BalanceQueryParamApi balanceQueryParamApi = new BalanceQueryParamApi();
 | 
			
		||||
        balanceQueryParamApi.setSelectors(Arrays.asList(selectorsArray));
 | 
			
		||||
        balanceQueryParamApi.setOrgNumber(org.getString("number"));
 | 
			
		||||
        balanceQueryParamApi.setBookTypeNumber("100002"); //账簿类型
 | 
			
		||||
        balanceQueryParamApi.setAccountTableNumber("0003");//科目表
 | 
			
		||||
 | 
			
		||||
        DynamicObject period = (DynamicObject)this.getModel().getValue("zcgj_period");
 | 
			
		||||
        if(period == null){
 | 
			
		||||
            //this.getView().showErrMessage("请选择期间!");
 | 
			
		||||
            this.getView().showErrorNotification("请选择期间!");
 | 
			
		||||
        }
 | 
			
		||||
        balanceQueryParamApi.setPeriodNumber(period.getString("number")); //
 | 
			
		||||
        List<String> groupBy = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
        Map<String, List<Map<String, String>>> accountAssgrp = new HashMap<>();
 | 
			
		||||
        List<Map<String, String>> li = new ArrayList<>();
 | 
			
		||||
        //accountAssgrp.put("1001", li); //现金
 | 
			
		||||
        //accountAssgrp.put("1002", li); //现金
 | 
			
		||||
        //accountAssgrp.put("11260101", li); //银行承兑
 | 
			
		||||
        accountAssgrp.put("11260301", li); //供应链
 | 
			
		||||
        balanceQueryParamApi.setAccountAssgrp(accountAssgrp);
 | 
			
		||||
        //groupBy.add("0005");
 | 
			
		||||
        groupBy.add("account");
 | 
			
		||||
        Gson gson = new Gson();
 | 
			
		||||
        String json = gson.toJson(balanceQueryParamApi);
 | 
			
		||||
        Map<String, Object> params = gson.fromJson(json,
 | 
			
		||||
                new TypeToken<Map<String, Object>>() {
 | 
			
		||||
                }.getType());
 | 
			
		||||
        OpenApiResult balanceData = OpenApiSdkUtil.invoke("/v2/gl/getBalanceApi", params);
 | 
			
		||||
 | 
			
		||||
        if (balanceData.isStatus()) {
 | 
			
		||||
            String data = (String) balanceData.getData();
 | 
			
		||||
            Type listType = new TypeToken<List<AccountRecord>>() {
 | 
			
		||||
            }.getType();
 | 
			
		||||
            List<AccountRecord> records = gson.fromJson(data, listType);
 | 
			
		||||
 | 
			
		||||
            BigDecimal totalbeginlocal = BigDecimal.ZERO;
 | 
			
		||||
            for (AccountRecord record : records) {
 | 
			
		||||
                totalbeginlocal = totalbeginlocal.add(record.getBeginlocal());//期初本位币金额
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            DynamicObjectCollection fundplyentry = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_fundplyentry");
 | 
			
		||||
            DynamicObject dynamicObject = fundplyentry.get(0);
 | 
			
		||||
            dynamicObject.set("zcgj_supplyamt",totalbeginlocal);//供应链
 | 
			
		||||
        }else{
 | 
			
		||||
            DynamicObjectCollection fundplyentry = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_fundplyentry");
 | 
			
		||||
            DynamicObject dynamicObject = fundplyentry.get(0);
 | 
			
		||||
            dynamicObject.set("zcgj_supplyamt",BigDecimal.ZERO);//供应链
 | 
			
		||||
            this.getView().updateView("zcgj_fundplyentry");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,57 @@
 | 
			
		|||
package zcgj.zcdev.zcdev.pr.plugin.other;
 | 
			
		||||
 | 
			
		||||
import kd.bos.dataentity.entity.DynamicObject;
 | 
			
		||||
import kd.bos.dataentity.utils.OrmUtils;
 | 
			
		||||
import kd.bos.entity.ExtendedDataEntity;
 | 
			
		||||
import kd.bos.entity.botp.plugin.AbstractConvertPlugIn;
 | 
			
		||||
import kd.bos.entity.botp.plugin.args.AfterConvertEventArgs;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 入库单下推支出合同结算单botp插件
 | 
			
		||||
 */
 | 
			
		||||
public class MaterialinbillToOutContractSettleBotpPlugin  extends AbstractConvertPlugIn {
 | 
			
		||||
 | 
			
		||||
    private final static String FAREALCARD_ENTITYNAME = "fa_card_real";
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void afterConvert(AfterConvertEventArgs e) {
 | 
			
		||||
        super.afterConvert(e);
 | 
			
		||||
        // 获取已生成的资产卡片
 | 
			
		||||
        ExtendedDataEntity[] billDataEntitys = e.getTargetExtDataEntitySet().FindByEntityKey(FAREALCARD_ENTITYNAME);
 | 
			
		||||
 | 
			
		||||
        // 构造 ExtendedDataEntity 时需要的索引值
 | 
			
		||||
        int dataIndex = billDataEntitys.length;
 | 
			
		||||
 | 
			
		||||
        List<ExtendedDataEntity> copyDataEntitys = new ArrayList<>();
 | 
			
		||||
        for(ExtendedDataEntity billDataEntity : billDataEntitys){
 | 
			
		||||
 | 
			
		||||
            // 如下代码演示如何取本次下推关联的源单行数据包(本示例无需用到关联的源单行,代码注释掉)
 | 
			
		||||
            //List<DynamicObject> sourceRows = (List<DynamicObject>)billDataEntity.getValue(ConvertConst.ConvExtDataKey_SourceRows);
 | 
			
		||||
            //boolean isNewEntity = (boolean)billDataEntity.getValue(ConvertConst.ConvExtDataKey_IsNewEntity);
 | 
			
		||||
 | 
			
		||||
            // 原始的资产数量
 | 
			
		||||
            int qty = (int) billDataEntity.getValue("assetamount");
 | 
			
		||||
 | 
			
		||||
            // 将资产数量改为1
 | 
			
		||||
            billDataEntity.setValue("assetamount", 1);
 | 
			
		||||
 | 
			
		||||
            // 来源分录拆分序号 从1开始
 | 
			
		||||
            int splitSeq = 1;
 | 
			
		||||
            billDataEntity.setValue("sourceentrysplitseq", splitSeq++);
 | 
			
		||||
 | 
			
		||||
            // 复制 (原始的资产数量 - 1)个卡片对象
 | 
			
		||||
            for(int i = 1; i < qty; i++){
 | 
			
		||||
                DynamicObject copyObj = (DynamicObject) OrmUtils.clone(billDataEntity.getDataEntity(), false, true);
 | 
			
		||||
                copyObj.set("sourceentrysplitseq", splitSeq++);
 | 
			
		||||
 | 
			
		||||
                copyDataEntitys.add(new ExtendedDataEntity(copyObj, dataIndex++, 0));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 将复制出的单据,放入 targetExtDataEntitySet ,最终就会生成那么多的卡片
 | 
			
		||||
        e.getTargetExtDataEntitySet().AddExtendedDataEntities(FAREALCARD_ENTITYNAME, copyDataEntitys);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,102 @@
 | 
			
		|||
package zcgj.zcdev.zcdev.pr.plugin.utils;
 | 
			
		||||
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
public class AccountRecord {
 | 
			
		||||
    private Map<String, AssGrpItem> assgrp;
 | 
			
		||||
    private BigDecimal debitlocal;//本期借方本位币金额
 | 
			
		||||
    private BigDecimal creditlocal;//本期贷方本位币金额
 | 
			
		||||
    private BigDecimal yeardebitfor;//本年借方原币金额
 | 
			
		||||
    private BigDecimal yearcreditfor;//本年贷方原币金额
 | 
			
		||||
    private BigDecimal beginlocal;//期初本位币金额
 | 
			
		||||
    private BigDecimal endlocal;//期末本位币金额
 | 
			
		||||
    private long account;
 | 
			
		||||
 | 
			
		||||
    // getters and setters
 | 
			
		||||
    public BigDecimal getCreditlocal() {
 | 
			
		||||
        return creditlocal;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setCreditlocal(BigDecimal creditlocal) {
 | 
			
		||||
        this.creditlocal = creditlocal;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Map<String, AssGrpItem> getAssgrp() {
 | 
			
		||||
        return assgrp;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAssgrp(Map<String, AssGrpItem> assgrp) {
 | 
			
		||||
        this.assgrp = assgrp;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public BigDecimal getYearcreditfor() {
 | 
			
		||||
        return yearcreditfor;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setYearcreditfor(BigDecimal yearcreditfor) {
 | 
			
		||||
        this.yearcreditfor = yearcreditfor;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public BigDecimal getDebitlocal() {
 | 
			
		||||
        return debitlocal;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setDebitlocal(BigDecimal debitlocal) {
 | 
			
		||||
        this.debitlocal = debitlocal;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public BigDecimal getYeardebitfor() {
 | 
			
		||||
        return yeardebitfor;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setYeardebitfor(BigDecimal yeardebitfor) {
 | 
			
		||||
        this.yeardebitfor = yeardebitfor;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public BigDecimal getBeginlocal() {
 | 
			
		||||
        return beginlocal;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setBeginlocal(BigDecimal beginlocal) {
 | 
			
		||||
        this.beginlocal = beginlocal;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public long getAccount() {
 | 
			
		||||
        return account;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAccount(long account) {
 | 
			
		||||
        this.account = account;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public BigDecimal getEndlocal() {
 | 
			
		||||
        return endlocal;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setEndlocal(BigDecimal endlocal) {
 | 
			
		||||
        this.endlocal = endlocal;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // 嵌套类
 | 
			
		||||
    public static class AssGrpItem {
 | 
			
		||||
        private String number;
 | 
			
		||||
        private String name;
 | 
			
		||||
 | 
			
		||||
        public String getNumber() {
 | 
			
		||||
            return number;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void setNumber(String number) {
 | 
			
		||||
            this.number = number;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public String getName() {
 | 
			
		||||
            return name;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void setName(String name) {
 | 
			
		||||
            this.name = name;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue