98 lines
4.8 KiB
Java
98 lines
4.8 KiB
Java
package tqq9.lc123.cloud.app.plugin.operate.sys;
|
||
|
||
import cn.hutool.core.util.CharsetUtil;
|
||
import cn.hutool.core.util.StrUtil;
|
||
import cn.hutool.crypto.asymmetric.KeyType;
|
||
import cn.hutool.crypto.asymmetric.RSA;
|
||
import com.alibaba.fastjson.JSONObject;
|
||
import kd.bos.context.RequestContext;
|
||
import kd.bos.dataentity.entity.DynamicObject;
|
||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||
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 oadd.com.google.gson.Gson;
|
||
import oadd.com.google.gson.JsonObject;
|
||
import oadd.org.apache.commons.lang3.StringUtils;
|
||
import tqq9.lc123.cloud.app.eip.iscb.LCLogService;
|
||
import tqq9.lc123.cloud.app.eip.iscb.impl.LCLogServiceImpl;
|
||
import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils;
|
||
import tqq9.lc123.cloud.app.plugin.utils.FWRestfulUtils;
|
||
import tqq9.lc123.cloud.app.plugin.utils.HttpRequestUtils;
|
||
|
||
import java.io.IOException;
|
||
import java.util.HashMap;
|
||
import java.util.Map;
|
||
|
||
/**
|
||
* 单据操作插件
|
||
* 物料撤销 调用流程撤回 接口
|
||
* 获取上一个审批人的 fwuserid (添加上一个审批人字段)
|
||
*/
|
||
public class MaterialUnsubmitOp extends AbstractOperationServicePlugIn implements Plugin {
|
||
|
||
private static final Log logger = LogFactory.getLog(MaterialUnsubmitOp.class);
|
||
final static String KEY_OPKEY = "unsubmit";
|
||
private static final String FW_appid = ConfigUtils.getThirdConfigByNumber("FW_appid");//FW_appid
|
||
private static final String WL_UnSubmit_URL = "api/workflow/paService/withdrawRequest";
|
||
|
||
@Override
|
||
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||
super.afterExecuteOperationTransaction(e);
|
||
LCLogService lcLogService = new LCLogServiceImpl();
|
||
String operationKey = e.getOperationKey();
|
||
if (StringUtils.equals(operationKey, KEY_OPKEY)) {
|
||
String isremind = "0";//0:不提醒
|
||
DynamicObject[] dataEntities = e.getDataEntities();
|
||
for (DynamicObject material : dataEntities) {
|
||
material = BusinessDataServiceHelper.loadSingle(material.getPkValue(), material.getDynamicObjectType().getName());
|
||
String number = material.getString("number");
|
||
String requestId = null;
|
||
String tqq9_fwstate = material.getString("tqq9_fwstate");
|
||
String tqq9_fwupdid = material.getString("tqq9_fwupdid");//泛微修改流程ID
|
||
if (StringUtils.isNotBlank(tqq9_fwupdid)) {
|
||
requestId = tqq9_fwupdid;
|
||
} else {
|
||
requestId = material.getString("tqq9_fwrequestid");//泛微流程ID
|
||
}
|
||
if (StringUtils.isNotBlank(requestId) && "待审核".equals(tqq9_fwstate)) {
|
||
String userid = null;
|
||
String requestName = "FW—流程撤回";
|
||
//获取当前用户id对应的泛微用户ID
|
||
//Long id = RequestContext.get().getCurrUserId();
|
||
//获取创建人id对应的泛微用户ID
|
||
DynamicObject creator = material.getDynamicObject("creator");
|
||
Long id = creator.getLong("id");
|
||
QFilter f1 = new QFilter("id", "=", id);
|
||
QFilter f2 = new QFilter("entryentity.ispartjob", "=", false);
|
||
DynamicObject bos_user = QueryServiceHelper.queryOne("bos_user", "id,entryentity.tqq9_fwuserid", new QFilter[]{f1, f2});
|
||
if (bos_user != null) {
|
||
userid = bos_user.getString("entryentity.tqq9_fwuserid");
|
||
}
|
||
if (org.apache.commons.lang3.StringUtils.isBlank(userid)) {
|
||
logger.info("没有获取到泛微用户ID,当前用户ID:" + id);
|
||
return;
|
||
}
|
||
String bodyString = FWRestfulUtils.postRequest(requestName, number, isremind, requestId, userid, WL_UnSubmit_URL);
|
||
logger.info("number:" + number + ",bodyString:" + bodyString);
|
||
JSONObject map = JSONObject.parseObject(bodyString);
|
||
if (map != null && map.size() > 0) {
|
||
String code = map.getString("code");
|
||
if ("SUCCESS".equals(code)) {
|
||
logger.info("number:" + number + "流程撤回成功");
|
||
} else {
|
||
logger.info("number:" + number + "流程撤回失败");
|
||
}
|
||
}else{
|
||
logger.info("number:" + number + "流程撤回失败");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} |