资金计划催报和定时任务

This commit is contained in:
yuxueliang0813 2025-03-24 18:27:23 +08:00
parent 18f734e36b
commit 815073e4d2
4 changed files with 117 additions and 13 deletions

View File

@ -4,12 +4,16 @@ import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.db.DB;
import kd.bos.db.DBRoute;
import kd.bos.form.FormShowParameter;
import kd.bos.entity.datamodel.ListSelectedRowCollection;
import kd.bos.form.IFormView;
import kd.bos.form.control.Button;
import kd.bos.form.control.Control;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.list.BillList;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
import java.util.EventObject;
@ -23,7 +27,9 @@ public class ReportMessageInFormPlugin extends AbstractFormPlugin {
private static final String OK_BUTTON_KEY = "btnok";//确认按钮
private final static Log logger = LogFactory.getLog(ReportMessageInFormPlugin.class);
private static final String updateInformant = "update t_fpm_report set finformant=? where fid=?;";//更新填报人
private static final String entityName = "fpm_report_process";//资金计划进度实体
//更新已发送OA标记和填报人
private static final String updateSendOAInfoUser = "update t_fpm_report set fk_shjh_sendoa=1,finformant=? where fid=?;";
/**
* 按钮监听注册
@ -32,8 +38,8 @@ public class ReportMessageInFormPlugin extends AbstractFormPlugin {
public void registerListener(EventObject e) {
super.registerListener(e);
//确认按钮
// Button selectedButton = this.getView().getControl(OK_BUTTON_KEY);
// selectedButton.addClickListener(this);
Button selectedButton = this.getView().getControl(OK_BUTTON_KEY);
selectedButton.addClickListener(this);
}
/**
@ -48,11 +54,17 @@ public class ReportMessageInFormPlugin extends AbstractFormPlugin {
if (StringUtils.equals(OK_BUTTON_KEY, key)) {
DynamicObject userinfo = (DynamicObject)this.getModel().getValue("user");
if(userinfo != null){
FormShowParameter showParameter = this.getView().getFormShowParameter();
//从界面参数上获取父界面传过来的单据id
//将被通知人更新到填报人上
// DB.update(DBRoute.of("fi"), updateInformant, new Object[]{userinfo.getLong("id"),});
IFormView pview = this.getView().getParentView();
BillList list = pview.getControl("billlistap");
ListSelectedRowCollection selectedRows = list.getSelectedRows();
Object[] ids = selectedRows.getPrimaryKeyValues();
DynamicObject prinfo;
for (int i = 0; i < ids.length; i++) {
prinfo = BusinessDataServiceHelper.loadSingle(ids[i], entityName);
JhzjUtils.handleOAReport(prinfo, "0", "0", userinfo);
DB.update(DBRoute.of("fi"), updateSendOAInfoUser, new Object[]{userinfo.getLong("id"),prinfo.getPkValue()});
}
}
}
} catch (Exception e) {

View File

@ -5,6 +5,7 @@ import kd.bos.db.DB;
import kd.bos.db.DBRoute;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.args.AfterOperationArgs;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
@ -17,6 +18,8 @@ public class ReportMessageInfoOperation extends AbstractOperationServicePlugIn i
private static final String updateSendOA = "update t_fpm_report set fk_shjh_sendoa=1 where fid=?;";//更新已发送OA标记
private static final String entityName = "fpm_report_process";//资金计划进度实体
@Override
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
super.afterExecuteOperationTransaction(e);
@ -26,7 +29,7 @@ public class ReportMessageInfoOperation extends AbstractOperationServicePlugIn i
DynamicObject[] dos = e.getDataEntities();
DynamicObject prinfo;
for (int i = 0; i < dos.length; i++) {
prinfo = dos[i];
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(), entityName);
if(prinfo.getDynamicObject("informant") != null){
JhzjUtils.handleOAReport(prinfo, "0", "0",prinfo.getDynamicObject("informant"));
DB.update(DBRoute.of("fi"), updateSendOA, new Object[]{prinfo.getPkValue()});
@ -37,8 +40,8 @@ public class ReportMessageInfoOperation extends AbstractOperationServicePlugIn i
DynamicObject[] dos = e.getDataEntities();
DynamicObject prinfo;
for (int i = 0; i < dos.length; i++) {
prinfo = dos[i];
if(prinfo.getBoolean("shjh_sendoa")){
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getString("reportid"), entityName);
if(prinfo.getBoolean("shjh_sendoa") && prinfo.getDynamicObject("informant") != null){
JhzjUtils.handleOAReport(prinfo, "2", "0",prinfo.getDynamicObject("informant"));
}
}

View File

@ -15,11 +15,11 @@ import java.math.BigDecimal;
import java.util.Map;
/**
* 定时任务更新资金计划收款实际数
* 定时任务更新收款资金计划收款实际数
* @author yuxueliang
*/
public class FundPlanCollectionTask extends AbstractTask implements Plugin {
private static final String entityName = "bd_accountview";//资金计划
private static final String entityName = "fpm_report_process";//资金计划
private static final Log logger = LogFactory.getLog(FundPlanCollectionTask.class);

View File

@ -0,0 +1,89 @@
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.dataentity.entity.DynamicObject;
import kd.bos.exception.KDException;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.login.actions.SerializationUtils;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.schedule.executor.AbstractTask;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
import kd.tmc.fpm.business.dataproc.save.ReportDataSDKService;
import kd.tmc.fpm.business.dataproc.save.domain.ReportDataBatchSaveParam;
import java.util.Map;
/**
* 定时任务更新付款资金计划的计划参考数
* @author yuxueliang
*/
public class FundPlanPaymentTask extends AbstractTask implements Plugin {
private static final String entityName = "fpm_report_process";//资金计划
private static final Log logger = LogFactory.getLog(FundPlanPaymentTask.class);
private Gson gson = new Gson();//用于将json格式化为对象
@Override
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
//TODO 查询当月暂存付款类资金计划付款区分公司当月应只有一个
QFilter qFilter = new QFilter("billstatus", QCP.equals, "A");//单据状态
qFilter.and("name", QCP.equals, "编制表");//报表名称
qFilter.and("reportplantype", QCP.equals, "reportplan");//报表类型-计划编制
DynamicObject[] collection = BusinessDataServiceHelper.load("fpm_report", "id", qFilter.toArray());
if(collection.length > 0){
for(DynamicObject doinfo : collection){
doinfo = BusinessDataServiceHelper.loadSingle(doinfo.getPkValue(),"fpm_report");
}
// 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));
}
}