资金计划定时任务
This commit is contained in:
parent
be5d81ec02
commit
d9fe22b56e
|
|
@ -1,17 +1,23 @@
|
||||||
package shjh.jhzj7.fi.fi.plugin.task;
|
package shjh.jhzj7.fi.fi.plugin.task;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.google.gson.Gson;
|
||||||
import kd.bos.context.RequestContext;
|
import kd.bos.context.RequestContext;
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
import kd.bos.exception.KDException;
|
import kd.bos.exception.KDException;
|
||||||
import kd.bos.logging.Log;
|
import kd.bos.logging.Log;
|
||||||
import kd.bos.logging.LogFactory;
|
import kd.bos.logging.LogFactory;
|
||||||
|
import kd.bos.login.actions.SerializationUtils;
|
||||||
import kd.bos.orm.query.QCP;
|
import kd.bos.orm.query.QCP;
|
||||||
import kd.bos.orm.query.QFilter;
|
import kd.bos.orm.query.QFilter;
|
||||||
import kd.bos.schedule.executor.AbstractTask;
|
import kd.bos.schedule.executor.AbstractTask;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
import kd.sdk.plugin.Plugin;
|
import kd.sdk.plugin.Plugin;
|
||||||
|
import kd.tmc.fpm.business.dataproc.save.ReportDataSDKService;
|
||||||
|
import kd.tmc.fpm.business.dataproc.save.domain.ReportDataBatchSaveParam;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -19,17 +25,63 @@ import java.util.Map;
|
||||||
* @author yuxueliang
|
* @author yuxueliang
|
||||||
*/
|
*/
|
||||||
public class FundPlanCollectionTask extends AbstractTask implements Plugin {
|
public class FundPlanCollectionTask extends AbstractTask implements Plugin {
|
||||||
private static final String entityName = "fpm_report_process";//资金计划
|
private static final String entityName = "fpm_report";//资金计划编制 t_fpm_report
|
||||||
|
|
||||||
private static final Log logger = LogFactory.getLog(FundPlanCollectionTask.class);
|
private static final Log logger = LogFactory.getLog(FundPlanCollectionTask.class);
|
||||||
|
private Gson gson = new Gson();//用于将json格式化为对象
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||||
//TODO 查询当月已审核收款类资金计划(收款不区分公司,当月应只有一个)
|
//TODO 查询当月已审核收款类资金计划(收款不区分公司,当月应只有一个)
|
||||||
QFilter qFilter = new QFilter("receredtype", QCP.equals, "0");
|
QFilter qFilter = new QFilter("billstatus", QCP.equals, "C");//单据状态
|
||||||
qFilter.and("creditamount", QCP.not_equals, BigDecimal.ZERO);
|
qFilter.and("name", QCP.equals, " 编制表");//报表名称
|
||||||
qFilter.and("claimnoticebillno", QCP.equals, "");
|
qFilter.and("enable", QCP.equals, "1");//是否可用
|
||||||
qFilter.and("billno", QCP.equals, "20250211-0000000094");
|
qFilter.and("reportplantype", QCP.equals, "reportplan");//报表类型-计划编制
|
||||||
DynamicObject[] collection = BusinessDataServiceHelper.load(entityName, "id", qFilter.toArray());
|
DynamicObject[] collection = BusinessDataServiceHelper.load(entityName, "id", qFilter.toArray());
|
||||||
|
if(collection.length > 0){
|
||||||
|
//调用SAP应收已清接口,按照公司、月份、计划科目汇总金额
|
||||||
|
ReportDataSDKService reportService = new ReportDataSDKService();//报表服务,用于写入或者查询报表数据
|
||||||
|
ReportDataBatchSaveParam pdsp;//报表批量保存的参数
|
||||||
|
JSONObject json_obj;//入参主对象
|
||||||
|
JSONArray items;//计划科目明细
|
||||||
|
String reportPeriodCode;//编报期间的编号
|
||||||
|
DynamicObject reportOrg;//编报主体对象
|
||||||
|
DynamicObjectCollection maindimentrys;
|
||||||
|
for(DynamicObject doinfo : collection){
|
||||||
|
doinfo = BusinessDataServiceHelper.loadSingle(doinfo.getPkValue(),entityName);
|
||||||
|
json_obj = new JSONObject();
|
||||||
|
//体系编号 非必填时,系统通过【编报主体 code】确定,需保证一个编报主体只关联一个体系
|
||||||
|
json_obj.put("systemCode",doinfo.getDynamicObject("bodysys").getString("number"));
|
||||||
|
reportPeriodCode = doinfo.getDynamicObject("reportperiod").getString("number");
|
||||||
|
json_obj.put("reportPeriodCode",reportPeriodCode);//编报期间 code
|
||||||
|
reportOrg = doinfo.getDynamicObject("reportorg");
|
||||||
|
json_obj.put("reportOrgCode",reportOrg.getString("number"));//编报主体 code
|
||||||
|
//组装计划科目
|
||||||
|
maindimentrys = doinfo.getDynamicObjectCollection("maindimentry");//主维度分录
|
||||||
|
items = new JSONArray(maindimentrys.size());
|
||||||
|
int i = 1;
|
||||||
|
for(DynamicObject entryinfo : maindimentrys){
|
||||||
|
JSONObject itemInfo = new JSONObject();
|
||||||
|
itemInfo.put("currencyCode",entryinfo.getDynamicObject("currencymem").getString("number"));//币别 code
|
||||||
|
itemInfo.put("subjectCode",entryinfo.getDynamicObject("subjectmem").getString("number"));//计划科目 code
|
||||||
|
itemInfo.put("entryPeriodCode",entryinfo.getDynamicObject("periodmem").getString("number"));//主维度数据分录期间 code
|
||||||
|
//组装度量值
|
||||||
|
JSONArray mms = new JSONArray(1);//科目的度量值明细,目前只写入计划参考数
|
||||||
|
JSONObject mmInfo = new JSONObject();
|
||||||
|
//PLANREFERENCEAMT 计划参考值 ACTMAT 已执行额度
|
||||||
|
mmInfo.put("templateMetricType","ACTMAT");//度量值预置类型
|
||||||
|
mmInfo.put("amount",i++);//TODO 写入金额-从SAP接口中获取
|
||||||
|
mmInfo.put("amountUnit","one");//金额单位 one元 thousand千元 ten_thousand 万元
|
||||||
|
mms.add(mmInfo);
|
||||||
|
itemInfo.put("metricMembers",mms);//度量值列表
|
||||||
|
items.add(itemInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
json_obj.put("batchSaveData",items);//报表批量写入数据
|
||||||
|
logger.info("收款计划实际数入参"+json_obj.toJSONString());
|
||||||
|
pdsp = gson.fromJson(json_obj.toJSONString(), ReportDataBatchSaveParam.class);
|
||||||
|
reportService.batchSaveReportData(SerializationUtils.serializeToBase64(pdsp));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import kd.bos.context.RequestContext;
|
import kd.bos.context.RequestContext;
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
import kd.bos.exception.KDException;
|
import kd.bos.exception.KDException;
|
||||||
import kd.bos.logging.Log;
|
import kd.bos.logging.Log;
|
||||||
import kd.bos.logging.LogFactory;
|
import kd.bos.logging.LogFactory;
|
||||||
|
|
@ -26,7 +27,7 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class FundPlanPaymentTask extends AbstractTask implements Plugin {
|
public class FundPlanPaymentTask extends AbstractTask implements Plugin {
|
||||||
|
|
||||||
private static final String entityName = "fpm_report_process";//资金计划
|
private static final String entityName = "fpm_report";//资金计划编制 t_fpm_report
|
||||||
|
|
||||||
private static final Log logger = LogFactory.getLog(FundPlanPaymentTask.class);
|
private static final Log logger = LogFactory.getLog(FundPlanPaymentTask.class);
|
||||||
|
|
||||||
|
|
@ -36,54 +37,55 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin {
|
||||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||||
//TODO 查询当月暂存付款类资金计划(付款区分公司,当月应只有一个)
|
//TODO 查询当月暂存付款类资金计划(付款区分公司,当月应只有一个)
|
||||||
QFilter qFilter = new QFilter("billstatus", QCP.equals, "A");//单据状态
|
QFilter qFilter = new QFilter("billstatus", QCP.equals, "A");//单据状态
|
||||||
qFilter.and("name", QCP.equals, "编制表");//报表名称
|
qFilter.and("name", QCP.equals, " 编制表");//报表名称
|
||||||
|
qFilter.and("enable", QCP.equals, "1");//是否可用
|
||||||
qFilter.and("reportplantype", QCP.equals, "reportplan");//报表类型-计划编制
|
qFilter.and("reportplantype", QCP.equals, "reportplan");//报表类型-计划编制
|
||||||
DynamicObject[] collection = BusinessDataServiceHelper.load("fpm_report", "id", qFilter.toArray());
|
DynamicObject[] collection = BusinessDataServiceHelper.load(entityName, "id", qFilter.toArray());
|
||||||
if(collection.length > 0){
|
if(collection.length > 0){
|
||||||
|
//调用SAP应付接口,按照公司、月份、计划科目汇总金额
|
||||||
|
ReportDataSDKService reportService = new ReportDataSDKService();//报表服务,用于写入或者查询报表数据
|
||||||
|
ReportDataBatchSaveParam pdsp;//报表批量保存的参数
|
||||||
|
JSONObject json_obj;//入参主对象
|
||||||
|
JSONArray items;//计划科目明细
|
||||||
|
String reportPeriodCode;//编报期间的编号
|
||||||
|
DynamicObject reportOrg;//编报主体对象
|
||||||
|
DynamicObjectCollection maindimentrys;
|
||||||
for(DynamicObject doinfo : collection){
|
for(DynamicObject doinfo : collection){
|
||||||
doinfo = BusinessDataServiceHelper.loadSingle(doinfo.getPkValue(),"fpm_report");
|
doinfo = BusinessDataServiceHelper.loadSingle(doinfo.getPkValue(),entityName);
|
||||||
|
json_obj = new JSONObject();
|
||||||
|
//体系编号 非必填时,系统通过【编报主体 code】确定,需保证一个编报主体只关联一个体系
|
||||||
|
json_obj.put("systemCode",doinfo.getDynamicObject("bodysys").getString("number"));
|
||||||
|
reportPeriodCode = doinfo.getDynamicObject("reportperiod").getString("number");
|
||||||
|
json_obj.put("reportPeriodCode",reportPeriodCode);//编报期间 code
|
||||||
|
reportOrg = doinfo.getDynamicObject("reportorg");
|
||||||
|
json_obj.put("reportOrgCode",reportOrg.getString("number"));//编报主体 code
|
||||||
|
//组装计划科目
|
||||||
|
maindimentrys = doinfo.getDynamicObjectCollection("maindimentry");//主维度分录
|
||||||
|
items = new JSONArray(maindimentrys.size());
|
||||||
|
int i = 1;
|
||||||
|
for(DynamicObject entryinfo : maindimentrys){
|
||||||
|
JSONObject itemInfo = new JSONObject();
|
||||||
|
itemInfo.put("currencyCode",entryinfo.getDynamicObject("currencymem").getString("number"));//币别 code
|
||||||
|
itemInfo.put("subjectCode",entryinfo.getDynamicObject("subjectmem").getString("number"));//计划科目 code
|
||||||
|
itemInfo.put("entryPeriodCode",entryinfo.getDynamicObject("periodmem").getString("number"));//主维度数据分录期间 code
|
||||||
|
//组装度量值
|
||||||
|
JSONArray mms = new JSONArray(1);//科目的度量值明细,目前只写入计划参考数
|
||||||
|
JSONObject mmInfo = new JSONObject();
|
||||||
|
//PLANREFERENCEAMT 计划参考值 ACTMAT 已执行额度
|
||||||
|
mmInfo.put("templateMetricType","PLANREFERENCEAMT");//度量值预置类型
|
||||||
|
mmInfo.put("amount",i++);//TODO 写入金额-从SAP接口中获取
|
||||||
|
mmInfo.put("amountUnit","one");//金额单位 one元 thousand千元 ten_thousand 万元
|
||||||
|
mms.add(mmInfo);
|
||||||
|
itemInfo.put("metricMembers",mms);//度量值列表
|
||||||
|
items.add(itemInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
json_obj.put("batchSaveData",items);//报表批量写入数据
|
||||||
|
logger.info("付款计划参考数入参"+json_obj.toJSONString());
|
||||||
|
pdsp = gson.fromJson(json_obj.toJSONString(), ReportDataBatchSaveParam.class);
|
||||||
|
reportService.batchSaveReportData(SerializationUtils.serializeToBase64(pdsp));
|
||||||
}
|
}
|
||||||
// ReportDataBatchSaveParam dataparam = new ReportDataBatchSaveParam();
|
|
||||||
// dataparam.setSystemCode();//非必填时,系统通过【编报主体 code】确定,需保证一个编报主体只关联一个体系
|
|
||||||
// dataparam.setReportPeriodCode();//编报期间 code
|
|
||||||
// dataparam.setReportOrgCode();//编报主体 code
|
|
||||||
// dataparam.setBatchSaveData();//报表批量写入数据
|
|
||||||
// List<ReportDataBatchSaveObject> savedatalist = new ArrayList<>();
|
|
||||||
// ReportDataBatchSaveObject savedata = new ReportDataBatchSaveObject();
|
|
||||||
// savedata.setCurrencyCode();//币别 code
|
|
||||||
// savedata.setSubjectCode();//计划科目 code
|
|
||||||
// savedata.setCompanyCode();//公司 code
|
|
||||||
// savedata.setEntryPeriodCode();//主维度数据分录期间 code
|
|
||||||
// savedata.setMetricMembers();//度量值列表
|
|
||||||
// List<ReportDataBatchSaveObject.MetricMember> metricMembers = new ArrayList<>(1);
|
|
||||||
// ReportDataBatchSaveObject.MetricMember mm = new ReportDataBatchSaveObject.MetricMember();
|
|
||||||
//PLANREFERENCEAMT 计划参考值 ACTMAT 已执行额度
|
|
||||||
// mm.setTemplateMetricType(TemplateMetricType.PLANREFERENCEAMT);//度量值预置类型
|
|
||||||
// mm.setAmount();//写入金额
|
|
||||||
// mm.setAmountUnit(AmountUnit.ONE);
|
|
||||||
}
|
}
|
||||||
JSONObject json_obj = new JSONObject();
|
|
||||||
json_obj.put("systemCode","SYS-004");//非必填时,系统通过【编报主体 code】确定,需保证一个编报主体只关联一个体系
|
|
||||||
json_obj.put("reportPeriodCode","M_FY2025.Q01.M02");//编报期间 code
|
|
||||||
json_obj.put("reportOrgCode","1002153");//编报主体 code
|
|
||||||
JSONArray items = new JSONArray();
|
|
||||||
JSONObject itemInfo = new JSONObject();
|
|
||||||
itemInfo.put("currencyCode","CNY");//币别 code
|
|
||||||
itemInfo.put("subjectCode","AC-SYS-004-115");//计划科目 code
|
|
||||||
itemInfo.put("entryPeriodCode","M_FY2025.Q01.M02");//主维度数据分录期间 code
|
|
||||||
JSONArray mms = new JSONArray();
|
|
||||||
JSONObject mmInfo = new JSONObject();
|
|
||||||
//PLANREFERENCEAMT 计划参考值 ACTMAT 已执行额度
|
|
||||||
mmInfo.put("templateMetricType","PLANREFERENCEAMT");//度量值预置类型
|
|
||||||
mmInfo.put("amount",688);//写入金额
|
|
||||||
mmInfo.put("amountUnit","one");//金额单位 one元 thousand千元 ten_thousand 万元
|
|
||||||
mms.add(mmInfo);
|
|
||||||
itemInfo.put("metricMembers",mms);//度量值列表
|
|
||||||
items.add(itemInfo);
|
|
||||||
json_obj.put("batchSaveData",items);//报表批量写入数据
|
|
||||||
logger.info("付款计划参考数入参"+json_obj.toJSONString());
|
|
||||||
ReportDataBatchSaveParam pdsp = gson.fromJson(json_obj.toJSONString(), ReportDataBatchSaveParam.class);
|
|
||||||
new ReportDataSDKService().batchSaveReportData(SerializationUtils.serializeToBase64(pdsp));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue