清账单和明细单操作插件
This commit is contained in:
parent
c446c04f89
commit
6a762e81a5
|
|
@ -0,0 +1,253 @@
|
|||
package shjh.jhzj7.fi.fi.plugin.operate;
|
||||
|
||||
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.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.print.service.dataprovider.QueryDataProvider;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.QueryServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 清账单单据操作插件
|
||||
*/
|
||||
public class ClearAccountBillOperation extends AbstractOperationServicePlugIn implements Plugin {
|
||||
|
||||
private static final String updateClearStatus = "update tk_shjh_clear_account set fbillstatus='D' where fid=?;";
|
||||
private static final String updateDetailStatusByBill = "update tk_shjh_clear_acctdetail set fbillstatus='D' where fk_shjh_clearbillid=?;";
|
||||
private static final String updateDetailStatusByID = "update tk_shjh_clear_acctdetail set fbillstatus='D' where fid=?;";
|
||||
private static final String updateDetailClearStatus = "update tk_shjh_clear_acctdetail set fk_shjh_clearstatus='C' where fk_shjh_clearbillid=?;";
|
||||
|
||||
private static final String entityName = "shjh_clear_acctdetail";//清账明细单
|
||||
private static final String pzbName = "shjh_jgqzcust";//结构性清账客户映射表
|
||||
|
||||
/**
|
||||
* 操作校验通过之后,开启事务之前,触发此事件;
|
||||
* 插件可以在此事件,对通过校验的数据,进行整理
|
||||
*/
|
||||
@Override
|
||||
public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
|
||||
super.beforeExecuteOperationTransaction(e);
|
||||
//反清账、作废、复制增加校验。
|
||||
String eok = e.getOperationKey();
|
||||
if("unclearacctount".equals(eok) || "invalid".equals(eok) || "copy".equals(eok)){
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;
|
||||
String billno;
|
||||
String billstatus;
|
||||
String clearstatus;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
//反审核操作之前系统未把info对象所有属性加载出来,尤其是二开的字段,需要在此处重新load一下
|
||||
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(),dos[i].getDataEntityType().getName(),
|
||||
"id,billno,billstatus,shjh_clearstatus,shjh_pzh,shjh_recebillno,shjh_unclearway,shjh_iscopy");
|
||||
billno = prinfo.getString("billno");
|
||||
billstatus = prinfo.getString("billstatus");
|
||||
clearstatus = prinfo.getString("shjh_clearstatus");
|
||||
if("unclearacctount".equals(eok)){
|
||||
//清账单【单据状态】=已审核 and【清账状态】=已清账 and【SAP凭证号】不为空 and 收款单编号不为多个,才允许点击反清账按钮。
|
||||
if(!"C".equals(billstatus) || !"A".equals(clearstatus) || JhzjUtils.isEmpty(prinfo.getString("shjh_pzh"))
|
||||
|| isReceBillNums(prinfo.getString("shjh_recebillno"))){
|
||||
e.setCancelMessage(billno+"【单据状态】=已审核 and【清账状态】=已清账 and【清账凭证号】不为空 and 收款单编号不为多个,才允许反清账");
|
||||
e.setCancel(true);
|
||||
}
|
||||
}else if("invalid".equals(eok)){
|
||||
//清账单【单据状态】=暂存 and【清账状态】=待清账,才允许点作废按钮。
|
||||
if(!"A".equals(billstatus) || !"B".equals(clearstatus)){
|
||||
e.setCancelMessage(billno+"【单据状态】=暂存 and【清账状态】=待清账,才允许作废");
|
||||
e.setCancel(true);
|
||||
}
|
||||
}else if("copy".equals(eok)){
|
||||
//清账单【单据状态】=作废 and【清账状态】=反清账 and【反清后处理方式】=收款信息变更 and【是否被复制】=否,才允许复制按钮。
|
||||
if(!"D".equals(billstatus) || !"C".equals(clearstatus)
|
||||
|| !"B".equals(prinfo.getString("shjh_unclearway")) || prinfo.getBoolean("shjh_iscopy")){
|
||||
e.setCancelMessage(billno+"【单据状态】=作废 and【清账状态】=反清账 and【反清后处理方式】=收款信息变更 and【是否被复制】=否,才允许复制");
|
||||
e.setCancel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isReceBillNums(String recebillnum){
|
||||
//收款单编号为多个
|
||||
if(JhzjUtils.isEmpty(recebillnum)){
|
||||
return false;
|
||||
}else if(recebillnum.indexOf(",") > 1){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作执行完毕,事务提交之后,触发此事件;
|
||||
* 插件可以在此事件,处理操作后续事情,与操作事务无关
|
||||
*/
|
||||
@Override
|
||||
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||
super.afterExecuteOperationTransaction(e);
|
||||
String eok = e.getOperationKey();
|
||||
switch (eok){
|
||||
case "clearacctount": handleClear(e);//清账-下推清账明细单
|
||||
case "unclearacctount": handleUnClear(e);//反清账
|
||||
case "audit": handleAudit(e);//审核
|
||||
case "notice": handleNotice(e);//清账实时通知
|
||||
case "invalid": handleInvalid(e);//作废
|
||||
}
|
||||
}
|
||||
|
||||
private void handleClear(AfterOperationArgs e){
|
||||
//清账具体实现
|
||||
//根据被通知人(结构性清账客户映射表)挨个生成清账明细单,并发送OA待办
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;//清账单
|
||||
String billno;
|
||||
DynamicObject detailinfo;//清账明细单
|
||||
QFilter qFilter;
|
||||
DynamicObject[] pzbs;
|
||||
DynamicObject pzbinfo;//配置表
|
||||
DynamicObjectCollection users;//配置表中的被通知人集合
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = dos[i];
|
||||
billno = prinfo.getString("billno");
|
||||
//根据客户、公司、是否可用找到对应的被通知人员(可能多个)
|
||||
qFilter = new QFilter("enable", QCP.equals, "1");
|
||||
qFilter.and("shjh_customer", QCP.equals, prinfo.getDynamicObject("shjh_customer").getLong("id"));
|
||||
qFilter.and("shjh_org", QCP.equals, prinfo.getDynamicObject("org").getLong("id"));
|
||||
pzbs = BusinessDataServiceHelper.load(pzbName, "id", qFilter.toArray(), "desc");
|
||||
if(pzbs.length == 0){
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage(billno+"根据结构性清账客户映射表未找到对应通知人,无法下推清账明细单");//前端界面提示内容
|
||||
this.operationResult.setShowMessage(true);//前端界面 是否显示提示消息
|
||||
continue;
|
||||
}
|
||||
pzbinfo = BusinessDataServiceHelper.loadSingleFromCache(pzbs[0].getLong("id"),pzbName);
|
||||
users = pzbinfo.getDynamicObjectCollection("shjh_users");
|
||||
for (int j = 0; j < users.size(); j++) {
|
||||
users.get(j);
|
||||
//根据清账单id和创建人id判断清账明细单是否已生成
|
||||
qFilter = new QFilter("shjh_clearbillid", QCP.equals, prinfo.getString("id"));
|
||||
qFilter.and("creator", QCP.equals, users.get(j).getLong("id"));
|
||||
if(!QueryServiceHelper.exists(entityName,qFilter.toArray())){
|
||||
//新增一个清账明细单
|
||||
detailinfo = newDetailBill(prinfo,users.get(j));
|
||||
//发送清账明细单的OA待办
|
||||
JhzjUtils.handleOA(detailinfo,"0", "0");
|
||||
JhzjUtils.sendEmail(users.get(j).getString("email"),"请登录资金系统操作清账明细单",
|
||||
detailinfo.getString("billno")+"\n 详情页面"+JhzjUtils.getBillPCURL(detailinfo),"清账明细单新增");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private DynamicObject newDetailBill(DynamicObject prinfo,DynamicObject userinfo){
|
||||
//根据清账单和被通知人创建清账明细单
|
||||
DynamicObject detailinfo = BusinessDataServiceHelper.newDynamicObject(entityName);
|
||||
detailinfo.set("org",prinfo.getDynamicObject("org"));//公司
|
||||
detailinfo.set("shjh_currency",prinfo.getDynamicObject("shjh_currency"));//币别
|
||||
detailinfo.set("shjh_bizdate",prinfo.getDate("shjh_bizdate"));//业务日期
|
||||
detailinfo.set("shjh_clearbillno",prinfo.getString("billno"));//清账单编号
|
||||
detailinfo.set("shjh_clearbillid",prinfo.getString("id"));//清账单ID
|
||||
detailinfo.set("shjh_customer",prinfo.getDynamicObject("shjh_customer"));//客户
|
||||
detailinfo.set("shjh_recebillno",prinfo.getString("shjh_recebillno"));//收款单编号
|
||||
detailinfo.set("shjh_recepzh",prinfo.getString("shjh_recepzh"));//收款单凭证号
|
||||
detailinfo.set("shjh_receamount",prinfo.getBigDecimal("shjh_receamount"));//收款金额
|
||||
detailinfo.set("billstatus","A");//单据状态-暂存
|
||||
detailinfo.set("shjh_clearstatus","B");//清账状态-待清账
|
||||
detailinfo.set("creator",userinfo);//创建人
|
||||
detailinfo.set("createtime",new Date());//创建时间
|
||||
detailinfo.set("modifier",userinfo);//修改人
|
||||
detailinfo.set("modifytime",new Date());//修改时间
|
||||
Object[] result = SaveServiceHelper.save(new DynamicObject[]{detailinfo});
|
||||
return (DynamicObject) result[0];
|
||||
}
|
||||
|
||||
private void handleUnClear(AfterOperationArgs e){
|
||||
//反清账具体实现
|
||||
//TODO 调用SAP反清账接口,更新清账单中反清状态和反清凭证号。
|
||||
//撤销原有清账信息。更新清账单【清账状态】=反清账,清账明细单【清账状态】=反清账。
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = dos[i];
|
||||
DB.update(DBRoute.of("fi"), updateDetailClearStatus, new Object[]{prinfo.getString("id")});
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAudit(AfterOperationArgs e){
|
||||
//审核具体实现
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;//清账单
|
||||
DynamicObject detailinfo;//清账明细单
|
||||
DynamicObject[] ddos;
|
||||
String billstatus;
|
||||
List<DynamicObject> detailList = new ArrayList<>();
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = dos[i];
|
||||
//TODO 调用SAP清账接口,生成清账凭证。
|
||||
|
||||
//若存在(暂存、驳回)的清账明细单,则系统自动处理:清账明细单【单据状态】全标记为作废,并消除被作废明细单的OA待办。
|
||||
ddos = BusinessDataServiceHelper.load(entityName,"id,billno,billstatus,shjh_clearbillid,shjh_clearbillno,createtime,creator,modifier",
|
||||
new QFilter[]{new QFilter("shjh_clearbillid","=",prinfo.getString("id"))});
|
||||
for (int j = 0; j < ddos.length; j++) {
|
||||
detailinfo = ddos[j];
|
||||
billstatus = detailinfo.getString("billstatus");
|
||||
if("A".equals(billstatus) || "E".equals(billstatus)){
|
||||
DB.update(DBRoute.of("fi"), updateDetailStatusByID, new Object[]{detailinfo.getLong("id")});
|
||||
//消除OA待办
|
||||
JhzjUtils.handleOA(detailinfo,"2", "0");
|
||||
}else if("C".equals(billstatus)){
|
||||
detailList.add(detailinfo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//TODO 如果清账明细单【单据状态】=已审核,发送审核通过的邮件通知,企微通知。
|
||||
if(!detailList.isEmpty()){
|
||||
Map<String, String> userBill = new HashMap<>();
|
||||
String billno;
|
||||
String useremail;
|
||||
for (int i = 0; i < detailList.size(); i++) {
|
||||
detailinfo = detailList.get(i);
|
||||
useremail = detailinfo.getDynamicObject("modifier").getString("email");
|
||||
if(userBill.containsKey(useremail)){
|
||||
billno = userBill.get(useremail);
|
||||
userBill.put(useremail,billno+","+detailinfo.getString("billno"));
|
||||
}else{
|
||||
userBill.put(useremail,detailinfo.getString("billno"));
|
||||
}
|
||||
}
|
||||
//遍历map,给每个人发邮件
|
||||
for (Map.Entry<String, String> entry : userBill.entrySet()) {
|
||||
JhzjUtils.sendEmail(entry.getKey(),"清账完成通知",entry.getValue()+"已清账完成","清账单审核");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleInvalid(AfterOperationArgs e){
|
||||
//作废具体实现
|
||||
//更新清账单【单据状态】=作废,及下游所有清账明细单【单据状态】=作废
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = dos[i];
|
||||
DB.update(DBRoute.of("fi"), updateClearStatus, new Object[]{prinfo.getLong("id")});
|
||||
DB.update(DBRoute.of("fi"), updateDetailStatusByBill, new Object[]{prinfo.getString("id")});
|
||||
}
|
||||
}
|
||||
|
||||
private void handleNotice(AfterOperationArgs e){
|
||||
//通知具体实现
|
||||
//清账单的下游所有清账明细单实时通知被通知人进行清账。发送邮件通知、OA待办。
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
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.bos.entity.plugin.args.BeforeOperationArgs;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
|
||||
|
||||
/**
|
||||
* 清账明细单据操作插件
|
||||
*/
|
||||
public class ClearDetailBillOperation extends AbstractOperationServicePlugIn implements Plugin {
|
||||
|
||||
private static final String updateDetailByID = "update tk_shjh_clear_acctdetail set fbillstatus='A' where fid=?;";
|
||||
|
||||
/**
|
||||
* 操作校验通过之后,开启事务之前,触发此事件;
|
||||
* 插件可以在此事件,对通过校验的数据,进行整理
|
||||
*/
|
||||
@Override
|
||||
public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
|
||||
super.beforeExecuteOperationTransaction(e);
|
||||
//提交、撤销、驳回增加校验。
|
||||
String eok = e.getOperationKey();
|
||||
if("submit".equals(eok) || "revoke".equals(eok) || "reject".equals(eok)){
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;
|
||||
String billno;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
//反审核操作之前系统未把info对象所有属性加载出来,尤其是二开的字段,需要在此处重新load一下
|
||||
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(),dos[i].getDataEntityType().getName());
|
||||
billno = prinfo.getString("billno");
|
||||
if("submit".equals(eok)){
|
||||
if("B".equals(prinfo.getString("billstatus"))){
|
||||
e.setCancelMessage(prinfo.getString("billno")+"单据已提交,不允许重复提交");
|
||||
e.setCancel(true);
|
||||
}
|
||||
//清账明细单【未清金额】+【账扣金额】+【尾差金额】≥【本次核销金额合计】
|
||||
if(!checkAmount(prinfo)){
|
||||
e.setCancelMessage(billno+"【未清金额】+【账扣金额】+【尾差金额】≥【本次核销金额合计】,才允许提交");
|
||||
e.setCancel(true);
|
||||
}
|
||||
}else if("revoke".equals(eok) && !"B".equals(prinfo.getString("billstatus"))){
|
||||
//清账明细单【单据状态】=已提交,才允许撤销
|
||||
e.setCancelMessage(billno+"【单据状态】=已提交,才允许撤销");
|
||||
e.setCancel(true);
|
||||
//若对应的清账单【单据状态】=已提交,则不允许清账明细单撤销,可联系财务驳回
|
||||
}else if("reject".equals(eok) && !"B".equals(prinfo.getString("billstatus"))){
|
||||
//清账明细单【单据状态】=已提交,才允许点击驳回按钮
|
||||
e.setCancelMessage(billno+"【单据状态】=已提交,才允许驳回");
|
||||
e.setCancel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkAmount(DynamicObject prinfo){
|
||||
|
||||
//校验通过返回true
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作执行完毕,事务提交之后,触发此事件;
|
||||
* 插件可以在此事件,处理操作后续事情,与操作事务无关
|
||||
*/
|
||||
@Override
|
||||
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||
super.afterExecuteOperationTransaction(e);
|
||||
String eok = e.getOperationKey();
|
||||
switch (eok){
|
||||
case "submit": handleSubmit(e);//提交
|
||||
case "revoke": handleRevoke(e);//撤销
|
||||
case "reject": handleReject(e);//驳回
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSubmit(AfterOperationArgs e){
|
||||
//提交具体实现
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = dos[i];
|
||||
//清账明细单的OA待办转成已办
|
||||
JhzjUtils.handleOA(prinfo,"2", "0");
|
||||
}
|
||||
//将清账明细反写清账单,清账单【收款金额】+【账扣】+【尾差】≥【本次核销金额合计】
|
||||
}
|
||||
|
||||
private void handleRevoke(AfterOperationArgs e){
|
||||
//撤销具体实现
|
||||
//清账明细单,单据状态变成暂存
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = dos[i];
|
||||
DB.update(DBRoute.of("fi"), updateDetailByID, new Object[]{prinfo.getLong("id")});
|
||||
}
|
||||
}
|
||||
|
||||
private void handleReject(AfterOperationArgs e){
|
||||
//驳回具体实现
|
||||
//清账明细单【单据状态】=驳回
|
||||
//若清账单【单据状态】=提交,则需调用清账单撤销,清账单【单据状态】=暂存。
|
||||
//业务员可修改后,再次提交。驳回时,对清账明细单创建人发送邮件通知,OA待办
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,9 +2,35 @@ package shjh.jhzj7.fi.fi.utils;
|
|||
|
||||
import kd.bos.context.RequestContext;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.message.api.EmailInfo;
|
||||
import kd.bos.message.service.handler.EmailHandler;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import kd.bos.data.BusinessDataReader;
|
||||
import kd.bos.dataentity.OperateOption;
|
||||
import kd.bos.dataentity.metadata.IDataEntityType;
|
||||
import kd.bos.entity.EntityMetadataCache;
|
||||
import kd.bos.entity.MainEntityType;
|
||||
import kd.bos.entity.botp.runtime.ConvertOperationResult;
|
||||
import kd.bos.entity.botp.runtime.PushArgs;
|
||||
import kd.bos.entity.botp.runtime.SourceBillReport;
|
||||
import kd.bos.entity.datamodel.IRefrencedataProvider;
|
||||
import kd.bos.entity.datamodel.ListSelectedRow;
|
||||
import kd.bos.entity.operate.OperateOptionConst;
|
||||
import kd.bos.entity.operate.result.IOperateInfo;
|
||||
import kd.bos.entity.operate.result.OperationResult;
|
||||
import kd.bos.exception.KDBizException;
|
||||
import kd.bos.servicehelper.botp.ConvertServiceHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class JhzjUtils {
|
||||
private static final String jklogEntityName = "shjh_jklog";
|
||||
public static final Long GROUPID = 100000l;//组织根节点ID
|
||||
|
|
@ -29,4 +55,128 @@ public class JhzjUtils {
|
|||
billinfo.set("creator",currUserId);
|
||||
SaveServiceHelper.save(new DynamicObject[]{billinfo});
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装入参,给指定人员发邮件
|
||||
* @param email 邮箱地址
|
||||
* @param title 邮件主题
|
||||
* @param content 邮件内容
|
||||
* @param operation 上游操作触发
|
||||
*/
|
||||
public static void sendEmail(String email, String title, String content,String operation){
|
||||
EmailInfo emailInfo = new EmailInfo();
|
||||
emailInfo.setTitle(title);
|
||||
emailInfo.setContent(content);
|
||||
List receivers = new ArrayList<>();
|
||||
receivers.add(email);//接收人1
|
||||
Map<String, Object> sendResult = EmailHandler.sendEmail(emailInfo);
|
||||
//保存邮件发送日志
|
||||
saveLog(email,"邮件",content,(String)sendResult.get("description"),(Boolean)sendResult.get("result"),operation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装入参,处理OA接口调用
|
||||
* @param prinfo 清账明细单
|
||||
* @param isRemark 流程处理状态
|
||||
* @param viewType 流程查看状态
|
||||
*/
|
||||
public static void handleOA(DynamicObject prinfo, String isRemark, String viewType){
|
||||
// 待办创建时间(格式: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 = prinfo.getDynamicObject("creator").getString("number");
|
||||
String approversNumbers = prinfo.getDynamicObject("modifier").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", SDF.format(prinfo.getDate("createtime")));// 创建日期时间,格式: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);
|
||||
}
|
||||
|
||||
public static String getBillPCURL(DynamicObject prinfo){
|
||||
//获得单据的pc详情url
|
||||
//https://ip:port/ierp/index.html?formId=er_tripreqbill&pkId=721810009540800512
|
||||
String contextUrl = System.getProperty("domain.contextUrl");
|
||||
String formId = prinfo.getDataEntityType().getName();
|
||||
return contextUrl+"?formId="+formId+"&pkId="+prinfo.getLong("id");
|
||||
}
|
||||
|
||||
/**
|
||||
* 收款单下推清账单-默认下推
|
||||
**/
|
||||
public static OperationResult push(String oribill, String tobill, String oribillid) {
|
||||
// 生成下推参数PushArgs
|
||||
PushArgs pushArgs = new PushArgs();
|
||||
pushArgs.setSourceEntityNumber(oribill); // 必选,源单标识
|
||||
pushArgs.setTargetEntityNumber(tobill); // 必选,目标单标识
|
||||
pushArgs.setHasRight(true); // 可选,传入true,不检查目标单新增权
|
||||
pushArgs.setAppId(""); // 可选,传入目标单验权使用的应用编码
|
||||
pushArgs.setDefOrgId(0L); // 可选,传入目标单主组织默认值
|
||||
pushArgs.setRuleId(""); // 可选,传入本次下推使用的转换规则id;传入空值,由系统自动寻找合适的转换规则
|
||||
pushArgs.setBuildConvReport(true); // 是否输出详细错误报告
|
||||
|
||||
List<ListSelectedRow> selectedRows = new ArrayList<>();
|
||||
ListSelectedRow selectedRow = new ListSelectedRow(Long.valueOf(oribillid));
|
||||
selectedRows.add(selectedRow);
|
||||
pushArgs.setSelectedRows(selectedRows);
|
||||
// 调用下推引擎,下推目标单
|
||||
ConvertOperationResult pushResult = ConvertServiceHelper.push(pushArgs);
|
||||
// 判断下推是否成功,如果失败,提炼失败消息输出
|
||||
if (!pushResult.isSuccess()) {
|
||||
String errMessage = pushResult.getMessage(); // 错误摘要
|
||||
String billMessage = "";
|
||||
for (SourceBillReport billReport : pushResult.getBillReports()) {
|
||||
if (!billReport.isSuccess()) {
|
||||
billMessage = billReport.getFailMessage();
|
||||
}
|
||||
}
|
||||
throw new KDBizException("下推失败:" + billMessage);
|
||||
}
|
||||
// 获取生成的目标单数据包
|
||||
MainEntityType targetMainType = EntityMetadataCache.getDataEntityType(tobill);
|
||||
List<DynamicObject> targetBillObjs = pushResult.loadTargetDataObjects(new IRefrencedataProvider() {
|
||||
@Override
|
||||
public void fillReferenceData(Object[] objs, IDataEntityType dType) {
|
||||
BusinessDataReader.loadRefence(objs, dType);
|
||||
}
|
||||
}, targetMainType);
|
||||
// 设置保存参数,调用目标单保存服务,保存目标单(保存时自动反写源单)
|
||||
OperateOption saveOption = OperateOption.create();
|
||||
|
||||
saveOption.setVariableValue(OperateOptionConst.IGNOREWARN, String.valueOf(true)); // 不执行警告级别校验器
|
||||
saveOption.setVariableValue(OperateOptionConst.IGNOREINTERACTION, String.valueOf(true)); // 不显示交互提示,自动执行到底
|
||||
saveOption.setVariableValue(OperateOptionConst.STRICTVALIDATION, String.valueOf(true)); // 全部校验通过才保存
|
||||
OperationResult saveResult = SaveServiceHelper.saveOperate(tobill,
|
||||
targetBillObjs.toArray(new DynamicObject[0]), saveOption);
|
||||
//判断保存结果
|
||||
if (!saveResult.isSuccess()) {
|
||||
String errMessage = saveResult.getMessage(); // 错误摘要
|
||||
// 演示提取保存详细错误
|
||||
String detailMessage = "";
|
||||
for (IOperateInfo errInfo : saveResult.getAllErrorOrValidateInfo()) {
|
||||
detailMessage = errInfo.getMessage();
|
||||
}
|
||||
throw new KDBizException("保存失败:" + detailMessage+errMessage);
|
||||
}
|
||||
return saveResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class AspAccountControler {
|
|||
private static final Map<String, DynamicObject> mapObject = new HashMap<>();//公司对象集合
|
||||
private static final Map<String, DynamicObject> hsxmMaps = new HashMap<>();//核算维度对象集合
|
||||
|
||||
private String insertSql = "insert into T_BD_Account_U (fdataid,fuseorgid) values (?,?);";
|
||||
private static final String insertSql = "insert into T_BD_Account_U (fdataid,fuseorgid) values (?,?);";
|
||||
|
||||
/**
|
||||
* @param bizParam 入参json格式数据
|
||||
|
|
|
|||
Loading…
Reference in New Issue