parent
18eeae3a06
commit
bd10bc0f4c
|
|
@ -0,0 +1,187 @@
|
|||
package shjh.jhzj7.fi.fi.plugin.report;
|
||||
|
||||
import kd.bos.algo.DataSet;
|
||||
import kd.bos.algo.GroupbyDataSet;
|
||||
import kd.bos.cache.database.DataType;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.report.AbstractReportListDataPlugin;
|
||||
import kd.bos.entity.report.FilterInfo;
|
||||
import kd.bos.entity.report.ReportQueryParam;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.QueryServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 强共享报表
|
||||
* shjh_strongsharing
|
||||
*/
|
||||
public class StrongSharingQueryPlugin extends AbstractReportListDataPlugin implements Plugin {
|
||||
|
||||
// 交易明细单据编码
|
||||
private static String BEI_INTELPAY = "bei_intelpay";
|
||||
//合作金融机构
|
||||
private static String BD_FINORGINFO = "bd_finorginfo";
|
||||
private static Log log = LogFactory.getLog(StrongSharingQueryPlugin.class);
|
||||
|
||||
@Override
|
||||
public DataSet query(ReportQueryParam reportQueryParam, Object o) throws Throwable {
|
||||
|
||||
FilterInfo filter = reportQueryParam.getFilter();
|
||||
Date shjh_jzdate = filter.getDate("shjh_jzdate");//基准日期
|
||||
QFilter q1 = new QFilter("bizdate", QCP.equals, shjh_jzdate);//交易日期
|
||||
|
||||
DataSet result1 = null;
|
||||
// 被动付款入账
|
||||
DataSet beiIntelpay1 = QueryServiceHelper.queryDataSet(this.getClass().getName(), BEI_INTELPAY,
|
||||
"id,billno as shjh_billno,company.number as shjh_orgnumber,company.name as shjh_orgname," +
|
||||
"bank.number as banknumber,biztime as shjh_biztime,transbalance as shjh_amountjz,accountbank.id as accountbankid",
|
||||
q1.toArray(), null);
|
||||
// 合作金融机构 bd_finorginfo
|
||||
DataSet bdAccountbanks1 = QueryServiceHelper.queryDataSet(this.getClass().getName(),
|
||||
BD_FINORGINFO, "id,number as finorginfonumber,bank_cate.name as shjh_bankname", null, null);
|
||||
|
||||
try {
|
||||
// 去重处理
|
||||
DataSet distinctBeiIntelpay = beiIntelpay1.distinct();
|
||||
DataSet distinctBdAccountbanks = bdAccountbanks1.distinct();
|
||||
|
||||
// 根据被动付款入账 开户银行 银行类别(查所有满足日期的交易明细)
|
||||
DataSet joinedDataSet = distinctBeiIntelpay.join(distinctBdAccountbanks)
|
||||
.on("banknumber", "finorginfonumber")
|
||||
.select(new String[]{"shjh_billno", "shjh_orgnumber", "shjh_orgname", "shjh_bankname", "banknumber",
|
||||
"shjh_biztime", "shjh_amountjz", "accountbankid"})
|
||||
.finish();
|
||||
|
||||
// 按银行账户id分组,取最大日期的集合
|
||||
DataSet maxBizdate = joinedDataSet.groupBy(new String[]{"accountbankid"})
|
||||
.max("shjh_biztime")
|
||||
.finish();
|
||||
|
||||
// 分组后和源集合联表:除账户id,日期的其他字段进行组合返回前台
|
||||
DataSet result = joinedDataSet.join(maxBizdate)
|
||||
.on("accountbankid", "accountbankid")
|
||||
.on("shjh_biztime", "shjh_biztime")
|
||||
.select(new String[]{"shjh_billno", "shjh_orgnumber", "shjh_orgname", "shjh_bankname", "banknumber",
|
||||
"shjh_biztime", "shjh_amountjz","accountbankid"})
|
||||
.finish();
|
||||
|
||||
// 再次根据银行编码分组 求和余额
|
||||
DataSet finish1 = result.groupBy(new String[]{"banknumber"}).sum("shjh_amountjz").finish();
|
||||
|
||||
// 分组后和源集合联表:除银行编码,余额的其他字段进行组合返回前台
|
||||
result1 = result.join(finish1)
|
||||
.on("banknumber","banknumber")
|
||||
.on("shjh_amountjz","shjh_amountjz")
|
||||
.select(new String[]{"shjh_billno", "shjh_orgnumber", "shjh_orgname", "shjh_bankname", "banknumber",
|
||||
"shjh_biztime", "shjh_amountjz","accountbankid"})
|
||||
.finish();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 确保在操作完成后关闭数据集
|
||||
if (beiIntelpay1 != null) {
|
||||
try {
|
||||
beiIntelpay1.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (bdAccountbanks1 != null) {
|
||||
try {
|
||||
bdAccountbanks1.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Date shjh_tnbjdate = filter.getDate("shjh_tnbjdate");//同年比较日期
|
||||
QFilter q2 = new QFilter("bizdate", QCP.equals, shjh_tnbjdate);//交易日期
|
||||
DataSet result2 = null;
|
||||
// 原始查询
|
||||
DataSet beiIntelpay2 = QueryServiceHelper.queryDataSet(this.getClass().getName(), BEI_INTELPAY,
|
||||
"id,billno as shjh_billno,company.number as shjh_orgnumber,company.name as shjh_orgname," +
|
||||
"bank.number as banknumber,biztime as shjh_biztime,transbalance as shjh_amounttn,accountbank.id as accountbankid",
|
||||
q2.toArray(), null);
|
||||
// 合作金融机构 bd_finorginfo
|
||||
DataSet bdAccountbanks2 = QueryServiceHelper.queryDataSet(this.getClass().getName(),
|
||||
BD_FINORGINFO, "id,number as finorginfonumber,bank_cate.name as shjh_bankname", null, null);
|
||||
|
||||
try {
|
||||
// 去重处理
|
||||
DataSet distinctBeiIntelpay = beiIntelpay2.distinct();
|
||||
DataSet distinctBdAccountbanks = bdAccountbanks2.distinct();
|
||||
|
||||
// 根据被动付款入账 开户银行 银行类别(查所有满足日期的交易明细)
|
||||
DataSet joinedDataSet = distinctBeiIntelpay.join(distinctBdAccountbanks)
|
||||
.on("banknumber", "finorginfonumber")
|
||||
.select(new String[]{"shjh_billno", "shjh_orgnumber", "shjh_orgname", "shjh_bankname", "banknumber",
|
||||
"shjh_biztime", "shjh_amounttn","accountbankid"})
|
||||
.finish();
|
||||
|
||||
// 按银行账户id分组,取最大日期的集合
|
||||
DataSet maxBizdate = joinedDataSet.groupBy(new String[]{"accountbankid"})
|
||||
.max("shjh_biztime")
|
||||
.finish();
|
||||
|
||||
// 分组后和源集合联表:除账户id,日期的其他字段进行组合返回前台
|
||||
DataSet result = joinedDataSet.join(maxBizdate)
|
||||
.on("accountbankid", "accountbankid")
|
||||
.on("shjh_biztime", "shjh_biztime")
|
||||
.select(new String[]{"shjh_billno", "shjh_orgnumber", "shjh_orgname", "shjh_bankname", "banknumber",
|
||||
"shjh_biztime", "shjh_amounttn","accountbankid"})
|
||||
.finish();
|
||||
|
||||
// 再次根据银行编码分组 求和余额
|
||||
DataSet finish1 = result.groupBy(new String[]{"banknumber"}).sum("shjh_amounttn").finish();
|
||||
|
||||
// 分组后和源集合联表:除银行编码,余额的其他字段进行组合返回前台
|
||||
result2 = result.join(finish1)
|
||||
.on("banknumber","banknumber")
|
||||
.on("shjh_amounttn","shjh_amounttn")
|
||||
.select(new String[]{"shjh_billno", "shjh_orgnumber", "shjh_orgname", "shjh_bankname", "banknumber",
|
||||
"shjh_biztime", "shjh_amounttn","accountbankid"})
|
||||
.finish();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 确保在操作完成后关闭数据集
|
||||
if (beiIntelpay2 != null) {
|
||||
try {
|
||||
beiIntelpay2.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (bdAccountbanks2 != null) {
|
||||
try {
|
||||
bdAccountbanks2.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
result1.print(true);
|
||||
result2.print(true);
|
||||
|
||||
// 根据资金组织编码名称,银行名称进行左连接
|
||||
DataSet finalResult = result1.leftJoin(result2)
|
||||
.on("shjh_orgname", "shjh_orgname")
|
||||
.on("shjh_bankname", "shjh_bankname")
|
||||
.on("shjh_orgnumber", "shjh_orgnumber")
|
||||
.select(new String[]{"shjh_billno", "shjh_orgnumber", "shjh_orgname", "shjh_bankname", "banknumber",
|
||||
"shjh_biztime", "shjh_amountjz", "shjh_amounttn"})
|
||||
.finish();
|
||||
finalResult.print(true);
|
||||
|
||||
return finalResult;
|
||||
}
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@ public class ApplyBillControler {
|
|||
handleError("同步失败,费控单据编号为空", fkBillNum, Apimenthod,jsonBodyString);
|
||||
return CustomApiResult.fail("400", "费控单据编号为空");
|
||||
}
|
||||
ap_payapply.set("shjh_fkdjbh", fkBillNum);
|
||||
ap_payapply.set("shjh_fkdjbh", fkBillNum);//外部系统单号
|
||||
|
||||
// 公司编号
|
||||
String companyNum = applybill.getCompanyNum();
|
||||
|
|
@ -302,20 +302,74 @@ public class ApplyBillControler {
|
|||
String remark = applybill.getRemark();//备注
|
||||
ap_payapply_entry.set("e_remark", remark);
|
||||
|
||||
//付款类型
|
||||
String paymenttype = applybill.getPaymenttype();
|
||||
if (paymenttype == null || paymenttype.isEmpty()) {
|
||||
handleError("同步失败,费控单据编号:" + fkBillNum + "的付款类型为空", fkBillNum, Apimenthod,jsonBodyString);
|
||||
return CustomApiResult.fail("400", "付款类型为空");
|
||||
/**
|
||||
* 员工借款单 A
|
||||
* 通用报销单 B
|
||||
* 差旅报销单 C
|
||||
* 劳务人员报销单 D
|
||||
* 预付款单 E
|
||||
* 请款单无订单 F
|
||||
* 服务付款单 G
|
||||
* 代扣款记账单 H
|
||||
* 其他付款单 I
|
||||
* SPA会员退卡申请单 J
|
||||
* 公司间划转单 K
|
||||
* 资金划款单 L
|
||||
*
|
||||
* JKY 对私 员工借款单
|
||||
* TYB 对私 通用报销单
|
||||
* CLB 对私 差旅报销单
|
||||
* LWB 对私 劳务人员报销单
|
||||
* YFK 对公 预付款单
|
||||
* JCW 对公 请款单无订单
|
||||
* FWK 对公 服务付款单
|
||||
* TFK 对公 其他付款单
|
||||
* SPA 对公 SPA会员退卡申请单
|
||||
* JCH 对公 TPM_请款单
|
||||
* TYH 对私 TPM_通用报销单
|
||||
*/
|
||||
QFilter qq1 = new QFilter("number", QCP.equals, "JH001");//对公
|
||||
QFilter qq2 = new QFilter("number", QCP.equals, "JH002");//对私
|
||||
DynamicObject paytype_g = BusinessDataServiceHelper.loadSingle(CAS_PAYMENTBILLTYPE, new QFilter[]{qq1});
|
||||
DynamicObject paytype_s = BusinessDataServiceHelper.loadSingle(CAS_PAYMENTBILLTYPE, new QFilter[]{qq2});
|
||||
//todo:付款类型 外部系统单据类型
|
||||
if (fkBillNum.contains("JKY")) {
|
||||
ap_payapply.set("shjh_externalsystemdocume","A");//员工借款单
|
||||
ap_payapply_entry.set("e_paymenttype", paytype_s);//对私
|
||||
}else if (fkBillNum.contains("TYB")) {
|
||||
ap_payapply.set("shjh_externalsystemdocume","B");//通用报销单
|
||||
ap_payapply_entry.set("e_paymenttype", paytype_s);//对私
|
||||
}else if (fkBillNum.contains("CLB")) {
|
||||
ap_payapply.set("shjh_externalsystemdocume","C");//差旅报销单
|
||||
ap_payapply_entry.set("e_paymenttype", paytype_s);//对私
|
||||
}else if (fkBillNum.contains("LWB")) {
|
||||
ap_payapply.set("shjh_externalsystemdocume","D");//劳务人员报销单
|
||||
ap_payapply_entry.set("e_paymenttype", paytype_s);//对私
|
||||
}else if (fkBillNum.contains("YFK")) {
|
||||
ap_payapply.set("shjh_externalsystemdocume","E");//预付款单
|
||||
ap_payapply_entry.set("e_paymenttype", paytype_g);//对公
|
||||
}else if (fkBillNum.contains("JCW")) {
|
||||
ap_payapply.set("shjh_externalsystemdocume","F");//请款单无订单
|
||||
ap_payapply_entry.set("e_paymenttype", paytype_g);//对公
|
||||
}else if (fkBillNum.contains("FWK")) { //服务付款单
|
||||
ap_payapply.set("shjh_externalsystemdocume","G");
|
||||
ap_payapply_entry.set("e_paymenttype", paytype_g);//对公
|
||||
}else if (fkBillNum.contains("TFK")) {
|
||||
ap_payapply.set("shjh_externalsystemdocume","I");//其他付款单
|
||||
ap_payapply_entry.set("e_paymenttype", paytype_g);//对公
|
||||
}else if (fkBillNum.contains("SPA")) {
|
||||
ap_payapply.set("shjh_externalsystemdocume","J");//SPA会员退卡申请单
|
||||
ap_payapply_entry.set("e_paymenttype", paytype_g);//对公
|
||||
}else if (fkBillNum.contains("JCH")) {
|
||||
// ap_payapply.set("shjh_externalsystemdocume","JC");//TPM_请款单
|
||||
ap_payapply_entry.set("e_paymenttype", paytype_g);//对公JKY0000001
|
||||
}else if (fkBillNum.contains("TYH")) { //TPM_通用报销单
|
||||
// ap_payapply.set("shjh_externalsystemdocume","TY");
|
||||
ap_payapply_entry.set("e_paymenttype", paytype_s);//对私
|
||||
}else {
|
||||
handleError("同步失败,费控单据编号:" + fkBillNum + "解析类型失败", fkBillNum, Apimenthod,jsonBodyString);
|
||||
return CustomApiResult.fail("400", "费控单据编号解析类型失败:"+fkBillNum);
|
||||
}
|
||||
QFilter Q9 = new QFilter("number", QCP.equals, paymenttype);
|
||||
DynamicObject paytype = BusinessDataServiceHelper.loadSingle(CAS_PAYMENTBILLTYPE, new QFilter[]{Q9});
|
||||
if (null == paytype) {
|
||||
handleError("同步失败,费控单据编号:" + fkBillNum + "的付款类型不存在", fkBillNum, Apimenthod,jsonBodyString);
|
||||
return CustomApiResult.fail("400", "付款类型不存在");
|
||||
}
|
||||
ap_payapply_entry.set("e_paymenttype", paytype);
|
||||
|
||||
/*
|
||||
---------------------------------------------------默认字段----------------------------------------------------
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class ApplyBillModel implements Serializable {
|
|||
private String fkBillID;
|
||||
@ApiParam(value="费控分录ID",required=true,position=24)
|
||||
private String fkEntryID;
|
||||
@ApiParam(value="付款类型",required=true,position=25)
|
||||
@ApiParam(value="付款类型",required=false,position=25)
|
||||
private String paymenttype;
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue