2025-12-12 03:16:21 +00:00
|
|
|
|
package tqq9.lc123.cloud.app.plugin.operate.sys;
|
|
|
|
|
|
|
2025-12-22 02:37:20 +00:00
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
2025-12-12 03:16:21 +00:00
|
|
|
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
|
|
|
|
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
2025-12-22 02:37:20 +00:00
|
|
|
|
import kd.bos.logging.Log;
|
|
|
|
|
|
import kd.bos.logging.LogFactory;
|
|
|
|
|
|
import kd.bos.orm.query.QFilter;
|
|
|
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
|
|
|
import kd.bos.servicehelper.QueryServiceHelper;
|
2025-12-12 03:16:21 +00:00
|
|
|
|
import kd.sdk.plugin.Plugin;
|
2025-12-22 02:37:20 +00:00
|
|
|
|
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;
|
2025-12-12 03:16:21 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 单据操作插件
|
|
|
|
|
|
* 物料撤销 调用流程撤回 接口
|
2025-12-22 02:37:20 +00:00
|
|
|
|
* 获取上一个审批人的 fwuserid (添加上一个审批人字段)
|
2025-12-12 03:16:21 +00:00
|
|
|
|
*/
|
|
|
|
|
|
public class MaterialUnsubmitOp extends AbstractOperationServicePlugIn implements Plugin {
|
2025-12-22 02:37:20 +00:00
|
|
|
|
|
|
|
|
|
|
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";
|
2025-12-12 03:16:21 +00:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
|
|
|
|
|
super.afterExecuteOperationTransaction(e);
|
2025-12-22 02:37:20 +00:00
|
|
|
|
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 + "流程撤回失败");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-12-12 03:16:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|