资金计划催报
This commit is contained in:
parent
7ccbc805f9
commit
b2d2e36635
|
|
@ -0,0 +1,64 @@
|
|||
package shjh.jhzj7.fi.fi.plugin.form;
|
||||
|
||||
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.form.control.Button;
|
||||
import kd.bos.form.control.Control;
|
||||
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
|
||||
import java.util.EventObject;
|
||||
|
||||
|
||||
/**
|
||||
* 催报通知 shjh_fpm_messageinfor_ext 表单插件
|
||||
* @author yuxueliang
|
||||
*/
|
||||
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=?;";//更新填报人
|
||||
|
||||
/**
|
||||
* 按钮监听注册
|
||||
*/
|
||||
@Override
|
||||
public void registerListener(EventObject e) {
|
||||
super.registerListener(e);
|
||||
//确认按钮
|
||||
// Button selectedButton = this.getView().getControl(OK_BUTTON_KEY);
|
||||
// selectedButton.addClickListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按钮点击实现方法
|
||||
*/
|
||||
@Override
|
||||
public void click(EventObject evt) {
|
||||
super.click(evt);
|
||||
try {
|
||||
Control source = (Control) evt.getSource();
|
||||
String key = source.getKey();
|
||||
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"),});
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("按钮处理异常:"+e.getMessage());
|
||||
this.getView().showMessage("按钮处理异常"+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package shjh.jhzj7.fi.fi.plugin.operate;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
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.sdk.plugin.Plugin;
|
||||
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
|
||||
|
||||
|
||||
/**
|
||||
* 编报进度管理 shjh_fpm_report_proce_ext-单据操作插件 处理催报发送OA待办
|
||||
* @author yuxueliang
|
||||
*/
|
||||
public class ReportMessageInfoOperation extends AbstractOperationServicePlugIn implements Plugin {
|
||||
|
||||
private static final String updateSendOA = "update t_fpm_report set fk_shjh_sendoa=1 where fid=?;";//更新已发送OA标记
|
||||
|
||||
@Override
|
||||
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||
super.afterExecuteOperationTransaction(e);
|
||||
String eok = e.getOperationKey();
|
||||
if("tblurge".equals(eok)){
|
||||
//催报:如果填报人不为空,则从此处推送OA待办
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = dos[i];
|
||||
if(prinfo.getDynamicObject("informant") != null){
|
||||
JhzjUtils.handleOAReport(prinfo, "0", "0",prinfo.getDynamicObject("informant"));
|
||||
DB.update(DBRoute.of("fi"), updateSendOA, new Object[]{prinfo.getPkValue()});
|
||||
}
|
||||
}
|
||||
}else if("submit".equals(eok)){
|
||||
//提交成功后,判断当前计划有没有发送OA待办,如果已发送,则将OA待办转为已办
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = dos[i];
|
||||
if(prinfo.getBoolean("shjh_sendoa")){
|
||||
JhzjUtils.handleOAReport(prinfo, "2", "0",prinfo.getDynamicObject("informant"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -5,27 +5,54 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import com.sap.db.jdbc.packet.ErrorLevel;
|
||||
import kd.bos.context.RequestContext;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.db.DB;
|
||||
import kd.bos.db.DBRoute;
|
||||
import kd.bos.entity.operate.result.OperateErrorInfo;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||
import kd.bos.entity.plugin.args.BeforeOperationArgs;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
|
||||
import shjh.jhzj7.fi.fi.utils.SapUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 预提记账处理-单据操作插件
|
||||
* 预提记账处理 shjh_cim_intbill_reve_ext-单据操作插件
|
||||
* @author yuxueliang
|
||||
*/
|
||||
public class RevenueBillOperation extends AbstractOperationServicePlugIn implements Plugin {
|
||||
|
||||
private static final String updateVoucherFlag = "update t_cim_revenue set fk_shjh_sendsap=1 where fid=?;";
|
||||
private static final String updateVoucherFlag = "update t_cim_revenue set fk_shjh_sendsap=1,shjh_sappzh=? where fid=?;";
|
||||
private static final String userName = "bos_user";//用户
|
||||
private static final String voucherName = "gl_voucher";//凭证
|
||||
|
||||
|
||||
@Override
|
||||
public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
|
||||
super.beforeExecuteOperationTransaction(e);
|
||||
String eok = e.getOperationKey();
|
||||
if("sendvoucher".equals(eok)){
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(), dos[i].getDataEntityType().getName());
|
||||
//判断预提记账处理单是否已生成金蝶凭证
|
||||
if(!prinfo.getBoolean("isvoucher")){
|
||||
e.setCancelMessage(prinfo.getString("billno") + "未生成金蝶凭证,无法推送SAP");
|
||||
e.setCancel(true);
|
||||
}else if(prinfo.getBoolean("shjh_sendsap")){
|
||||
e.setCancelMessage(prinfo.getString("billno") + "已推送SAP,无需再次推送");
|
||||
e.setCancel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||
|
|
@ -41,10 +68,9 @@ public class RevenueBillOperation extends AbstractOperationServicePlugIn impleme
|
|||
if(prinfo.getBoolean("shjh_needvoucher") && !prinfo.getBoolean("shjh_sendsap")){
|
||||
//如果预提记账处理单需要生成凭证且未推送sap的才推送sap
|
||||
sapReturnData = sendVoucher(prinfo);
|
||||
|
||||
if(sapReturnData != null && "0".equals(sapReturnData.getString("code"))){
|
||||
//推送sap成功后,反写已推送标记
|
||||
DB.update(DBRoute.of("fi"), updateVoucherFlag, new Object[]{prinfo.getPkValue()});
|
||||
// DB.update(DBRoute.of("fi"), updateVoucherFlag, new Object[]{sapReturnData.getString(""),prinfo.getPkValue()});
|
||||
this.operationResult.addSuccessPkId(prinfo.getPkValue());
|
||||
}else if(sapReturnData != null){
|
||||
addErrorInfo(prinfo,"推送SAP接口失败:"+sapReturnData.getString("msg"));
|
||||
|
|
@ -75,10 +101,40 @@ public class RevenueBillOperation extends AbstractOperationServicePlugIn impleme
|
|||
String oauser = userinfo.getString("shjh_oauser");
|
||||
IS_HEADER.put("USNAM",oauser);//用户名
|
||||
//----------------处理详细入参--TODO 获取对应凭证--------------------
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("HKONT","");//总账科目
|
||||
item.put("DMBTR",prinfo.getString("shjh_receamount"));//金额-传清账单收款金额
|
||||
IT_ITEM.add(item);
|
||||
DynamicObject gl_voucher = BusinessDataServiceHelper.loadSingle(voucherName,
|
||||
"id,sourcebill,entries,entries.account,entries.debitlocal,entries.creditlocal,entries.entrydc",
|
||||
new QFilter("sourcebill", QCP.equals, prinfo.getPkValue()).toArray());
|
||||
if (null != gl_voucher) {
|
||||
DynamicObjectCollection entries = gl_voucher.getDynamicObjectCollection("entries");
|
||||
if (!entries.isEmpty()) {
|
||||
JSONObject item;
|
||||
DynamicObject account;
|
||||
BigDecimal creditlocal;
|
||||
for (DynamicObject entry : entries) {
|
||||
item = new JSONObject();
|
||||
account = entry.getDynamicObject("account");//科目
|
||||
if (null != account) {
|
||||
item.put("HKONT", account.getString("number")); //总账科目_科目(凭证分录account)
|
||||
}
|
||||
//获取贷方金额
|
||||
creditlocal = entry.getBigDecimal("creditlocal");//贷方
|
||||
//获取分录借贷方向
|
||||
String entrydc = (String) entry.get("entrydc");//分录方向(1.借方,-1.贷方)
|
||||
if ("1".equals(entrydc)) {
|
||||
//设置sap凭证借方金额
|
||||
item.put("DMBTR", String.valueOf(entry.getBigDecimal("debitlocal")));
|
||||
} else if ("-1".equals(entrydc)) {
|
||||
//设置sap凭证贷方金额 sap通过负数体现贷方
|
||||
item.put("DMBTR", String.valueOf(creditlocal.negate()));
|
||||
}
|
||||
// item.put("RSTGR", "014");//原因代码_原因码
|
||||
// item.put("SGTXT", SGTXT);//行项目文本_SAP会计科目行项目号
|
||||
// item.put("KOSTL",KOSTL);//成本中心_成本中心
|
||||
// item.put("PRCTR",PRCTR);//利润中心_利润中心
|
||||
IT_ITEM.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
//组装参数调用推送sap凭证接口
|
||||
JSONObject sapReturnData = SapUtils.sapTransactionAPI(IS_HEADER,IT_ITEM,null,prinfo.getString("billno"));
|
||||
return sapReturnData;
|
||||
|
|
|
|||
|
|
@ -259,6 +259,44 @@ public class JhzjUtils {
|
|||
OAUtils.thirdParty(thirdPartyMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装入参,处理OA接口调用
|
||||
* @param prinfo 资金计划编制单
|
||||
* @param isRemark 流程处理状态
|
||||
* @param viewType 流程查看状态
|
||||
* @param informant 填报人
|
||||
*/
|
||||
public static void handleOAReport(DynamicObject prinfo, String isRemark, String viewType, DynamicObject informant){
|
||||
// 待办创建时间(格式:yyyy-MM-dd HH:mm:ss)
|
||||
Date currentDate = new Date();
|
||||
SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
SimpleDateFormat SDF1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
// 使用 SDF 格式化不用毫秒的时间
|
||||
String receiveDateStr = SDF.format(currentDate);
|
||||
// 使用 SDF1 格式化带毫秒的时间
|
||||
String rquestDateStr1 = SDF1.format(currentDate);
|
||||
|
||||
String billno = prinfo.getString("billno");
|
||||
String startNumber = informant.getString("number");
|
||||
String approversNumbers = informant.getString("number");
|
||||
Map<String, Object> thirdPartyMap = new HashMap<>();
|
||||
thirdPartyMap.put("flowid", prinfo.getLong("id"));// 流程任务ID,流程数据的标识,可自定义
|
||||
thirdPartyMap.put("requestname", "资金计划编制"+billno);//标题
|
||||
thirdPartyMap.put("nodename", "处理节点");// 步骤名称(节点名称)
|
||||
thirdPartyMap.put("pcurl", getBillPCURL(prinfo));// PC地址,第三方系统中流程处理界面的PC端地址
|
||||
thirdPartyMap.put("appurl", "");// APP地址,第三方系统中流程处理界面的移动端地址
|
||||
thirdPartyMap.put("isremark", isRemark);// 流程处理状态;0:待办 ,2:已办 ,4:办结。
|
||||
thirdPartyMap.put("viewtype", viewType);// 流程查看状态;0:未读,1:已读。
|
||||
thirdPartyMap.put("creator", startNumber);// 发起人
|
||||
thirdPartyMap.put("createDateStr", receiveDateStr);// 创建日期时间,格式:yyyy-MM-dd HH:mm:ss
|
||||
thirdPartyMap.put("createDateStr1", rquestDateStr1);//请求时间,格式:yyyy-MM-dd HH:mm:ss.SSS
|
||||
thirdPartyMap.put("receiver", approversNumbers);//接收人,工号 可以传多个,以英文逗号分隔
|
||||
thirdPartyMap.put("receivedatetime", receiveDateStr);//接收日期时间,格式:yyyy-MM-dd HH:mm:ss
|
||||
thirdPartyMap.put("billno", billno);// 单据编号
|
||||
//推送OA接口
|
||||
OAUtils.thirdParty(thirdPartyMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据指定的对象增加网络互斥,让其他人不可修改
|
||||
* @param prinfo 具体对象,可以是收付款单、清账单和明细单
|
||||
|
|
|
|||
Loading…
Reference in New Issue