parent
							
								
									3ae1e41926
								
							
						
					
					
						commit
						dcb862d3c7
					
				| 
						 | 
					@ -3,6 +3,7 @@ package shkd.sys.sys.plugin.report;
 | 
				
			||||||
import kd.bos.algo.DataSet;
 | 
					import kd.bos.algo.DataSet;
 | 
				
			||||||
import kd.bos.algo.JoinDataSet;
 | 
					import kd.bos.algo.JoinDataSet;
 | 
				
			||||||
import kd.bos.algo.JoinType;
 | 
					import kd.bos.algo.JoinType;
 | 
				
			||||||
 | 
					import kd.bos.dataentity.entity.DynamicObject;
 | 
				
			||||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
 | 
					import kd.bos.dataentity.entity.DynamicObjectCollection;
 | 
				
			||||||
import kd.bos.db.DB;
 | 
					import kd.bos.db.DB;
 | 
				
			||||||
import kd.bos.db.DBRoute;
 | 
					import kd.bos.db.DBRoute;
 | 
				
			||||||
| 
						 | 
					@ -20,6 +21,7 @@ import kd.bos.util.CollectionUtils;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.text.SimpleDateFormat;
 | 
					import java.text.SimpleDateFormat;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.Arrays;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class AccountbankReportPlugin extends AbstractReportListDataPlugin {
 | 
					public class AccountbankReportPlugin extends AbstractReportListDataPlugin {
 | 
				
			||||||
| 
						 | 
					@ -75,15 +77,7 @@ public class AccountbankReportPlugin extends AbstractReportListDataPlugin {
 | 
				
			||||||
                , null, null);
 | 
					                , null, null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        String[] fieldNames = accountbankDataSet.getRowMeta().getFieldNames();
 | 
					        String[] fieldNames = accountbankDataSet.getRowMeta().getFieldNames();
 | 
				
			||||||
        // 创建一个新的数组,长度是原数组长度 + 2(因为要添加两个字段)
 | 
					        String[] newFieldNames = ExpansionArray(fieldNames, Arrays.asList("fid", "fbasedataid as shkd_bz"));
 | 
				
			||||||
        String[] newFieldNames = new String[fieldNames.length + 2];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 将原来的字段名数组复制到新数组
 | 
					 | 
				
			||||||
        System.arraycopy(fieldNames, 0, newFieldNames, 0, fieldNames.length);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 添加两个新的字段到新数组的末尾
 | 
					 | 
				
			||||||
        newFieldNames[fieldNames.length] = "fid"; // 第一个新字段
 | 
					 | 
				
			||||||
        newFieldNames[fieldNames.length + 1] = "fbasedataid as shkd_bz"; // 第二个新字段
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 查询多选币别
 | 
					        // 查询多选币别
 | 
				
			||||||
        DataSet currencydata = DB.queryDataSet(this.getClass().getSimpleName(), DBRoute.of("sys"),
 | 
					        DataSet currencydata = DB.queryDataSet(this.getClass().getSimpleName(), DBRoute.of("sys"),
 | 
				
			||||||
| 
						 | 
					@ -94,30 +88,35 @@ public class AccountbankReportPlugin extends AbstractReportListDataPlugin {
 | 
				
			||||||
        DataSet finish = join.on("id", "fid").select(newFieldNames).finish();
 | 
					        DataSet finish = join.on("id", "fid").select(newFieldNames).finish();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        String[] fieldNames1 = finish.getRowMeta().getFieldNames();
 | 
					        String[] fieldNames1 = finish.getRowMeta().getFieldNames();
 | 
				
			||||||
        // 创建一个新的数组,长度是原数组长度 + 2(因为要添加两个字段)
 | 
					 | 
				
			||||||
        String[] newFieldNames1 = new String[fieldNames1.length + 3];
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 将原来的字段名数组复制到新数组
 | 
					        String[] newFieldNames1 = ExpansionArray(fieldNames1, Arrays.asList("shkd_zhyeyb", "shkd_zhyebb", "shkd_zhyesj"));
 | 
				
			||||||
        System.arraycopy(fieldNames1, 0, newFieldNames1, 0, fieldNames1.length);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 添加两个新的字段到新数组的末尾
 | 
					 | 
				
			||||||
        newFieldNames1[fieldNames1.length] = "shkd_zhyeyb"; // 第一个新字段
 | 
					 | 
				
			||||||
        newFieldNames1[fieldNames1.length + 1] = "shkd_zhyebb"; // 第二个新字段
 | 
					 | 
				
			||||||
        newFieldNames1[fieldNames1.length + 2] = "shkd_zhyesj"; // 第三个新字段
 | 
					 | 
				
			||||||
//        DynamicObjectCollection srcCollection = ORM.create().toPlainDynamicObjectCollection(finish.copy());
 | 
					 | 
				
			||||||
        //查询余额
 | 
					        //查询余额
 | 
				
			||||||
        StringBuilder sqlBuilder = new StringBuilder("/*dialect*/ \n");
 | 
					        StringBuilder sqlBuilder = new StringBuilder("/*dialect*/ \n");
 | 
				
			||||||
        sqlBuilder.append("SELECT fbankacctid ,SUM(FDebitAmount-FCreditAmount) as shkd_zhyeyb,SUM(FDebitAmount*fexchangerate-FCreditAmount*fexchangerate) as shkd_zhyebb,fcurrencyid,MAX(FBizDate) as shkd_zhyesj\n" +
 | 
					        sqlBuilder.append("SELECT fbankacctid ,SUM(FDebitAmount-FCreditAmount) as shkd_zhyeyb,SUM(FDebitAmount*fexchangerate-FCreditAmount*fexchangerate) as shkd_zhyebb,fcurrencyid,MAX(FBizDate) as shkd_zhyesj\n" +
 | 
				
			||||||
                "FROM t_cas_bankjournal \n" +
 | 
					                "FROM t_cas_bankjournal WHERE FBizDate<'"+dateList.get(0)+"' \n" +
 | 
				
			||||||
                "GROUP BY fbankacctid, fcurrencyid");
 | 
					                "GROUP BY fbankacctid, fcurrencyid");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        DataSet res = DB.queryDataSet(this.getClass().getSimpleName(), DBRoute.of("fi"), sqlBuilder.toString());//财务云
 | 
					        DataSet res = DB.queryDataSet(this.getClass().getSimpleName(), DBRoute.of("fi"), sqlBuilder.toString());//财务云
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        JoinDataSet join1 = finish.join(res, JoinType.LEFT);//左连接
 | 
					        JoinDataSet join1 = finish.join(res, JoinType.LEFT);//左连接
 | 
				
			||||||
        DataSet finish1 = join1.on("id", "fbankacctid").on("shkd_bz", "fcurrencyid").select(newFieldNames1).finish();
 | 
					        DataSet finish1 = join1.on("id", "fbankacctid").on("shkd_bz", "fcurrencyid").select(newFieldNames1).finish();
 | 
				
			||||||
        DynamicObjectCollection srcCollection = ORM.create().toPlainDynamicObjectCollection(finish1.copy());
 | 
					 | 
				
			||||||
        return finish1;
 | 
					        return finish1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    String[] ExpansionArray(String[] fieldNames,List<String> list){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 创建一个新的数组,长度是原数组长度 + 3(因为要添加两个字段)
 | 
				
			||||||
 | 
					        String[] newFieldNames = new String[fieldNames.length + list.size()];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 将原来的字段名数组复制到新数组
 | 
				
			||||||
 | 
					        System.arraycopy(fieldNames, 0, newFieldNames, 0, fieldNames.length);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = 0; i < list.size(); i++) {
 | 
				
			||||||
 | 
					            // 添加两个新的字段到新数组的末尾
 | 
				
			||||||
 | 
					            newFieldNames[fieldNames.length+i] = list.get(i); // 第i个新字段
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return newFieldNames;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue