其他入库申请单调FW_获取流程流转数据(OtherInApplyWorkflowDataListPlugin)
物料变更单撤回流程(MaterialUnsubmitOp)
This commit is contained in:
parent
6896d25770
commit
3012744a04
|
|
@ -53,11 +53,11 @@ public class OtherInApplyWorkflowDataListPlugin extends AbstractListPlugin imple
|
|||
"id,billno,tqq9_fwrequestid,tqq9_fwstate,tqq9_auditor,tqq9_auditornode", new QFilter[]{f});
|
||||
for (DynamicObject tqq9_otherinapply : billArr) {
|
||||
String billno = tqq9_otherinapply.getString("billno");
|
||||
log.info("billno:"+billno);
|
||||
log.info("billno:" + billno);
|
||||
String tqq9_fwrequestid = tqq9_otherinapply.getString("tqq9_fwrequestid");
|
||||
String tqq9_fwstate = tqq9_otherinapply.getString("tqq9_fwstate");
|
||||
if(StringUtils.isNotBlank(tqq9_fwrequestid) && "B".equals(tqq9_fwstate)){
|
||||
if(StringUtils.isBlank(userid)){
|
||||
if (StringUtils.isNotBlank(tqq9_fwrequestid) && "B".equals(tqq9_fwstate)) {
|
||||
if (StringUtils.isBlank(userid)) {
|
||||
//获取当前用户id对应的泛微用户ID
|
||||
Long id = RequestContext.get().getCurrUserId();
|
||||
QFilter f1 = new QFilter("id", "=", id);
|
||||
|
|
@ -67,15 +67,15 @@ public class OtherInApplyWorkflowDataListPlugin extends AbstractListPlugin imple
|
|||
userid = bos_user.getString("entryentity.tqq9_fwuserid");
|
||||
}
|
||||
if (StringUtils.isBlank(userid)) {
|
||||
log.info("没有获取到泛微用户ID,当前用户ID:"+id);
|
||||
log.info("没有获取到泛微用户ID,当前用户ID:" + id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String requestName = "FW_获取流程流转数据";
|
||||
//调用泛微接口获取下一步处理人
|
||||
String bodyString = FWRestfulUtils.getFwWorkFlowInfo(requestName, billno, tqq9_fwrequestid, userid);
|
||||
log.info("billno:"+billno+",bodyString:"+bodyString);
|
||||
String bodyString = FWRestfulUtils.getRequest(requestName, billno, tqq9_fwrequestid, userid);
|
||||
log.info("billno:" + billno + ",bodyString:" + bodyString);
|
||||
JSONObject map = JSONObject.parseObject(bodyString);
|
||||
if (map != null) {
|
||||
JSONArray data = map.getJSONArray("data");//节点id
|
||||
|
|
@ -102,11 +102,9 @@ public class OtherInApplyWorkflowDataListPlugin extends AbstractListPlugin imple
|
|||
SaveServiceHelper.save(new DynamicObject[]{tqq9_otherinapply});
|
||||
}
|
||||
}
|
||||
} }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,66 +1,98 @@
|
|||
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 String WL_UnSubmit_URL;
|
||||
//
|
||||
// static {
|
||||
// DynamicObject url = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name",
|
||||
// new QFilter[]{new QFilter("number", QCP.equals, "WL_UnSubmit_URL")});
|
||||
// WL_UnSubmit_URL = url != null ? url.getString("name") : null;
|
||||
// }
|
||||
|
||||
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)) {
|
||||
// //获取选中的物料单据数据
|
||||
// DynamicObject[] dataEntities = e.getDataEntities();
|
||||
// for (DynamicObject material : dataEntities) {
|
||||
// String id = String.valueOf(material.getLong("id"));
|
||||
// // 创建HttpClient实例
|
||||
// try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
|
||||
// // 创建PUT请求
|
||||
// HttpPut httpPut = new HttpPut(WL_UnSubmit_URL);
|
||||
// // 设置请求体
|
||||
// StringEntity entity1 = new StringEntity("0", ContentType.APPLICATION_JSON);
|
||||
// StringEntity entity2 = new StringEntity(id, ContentType.APPLICATION_JSON);
|
||||
// httpPut.setEntity(entity1);
|
||||
// httpPut.setEntity(entity2);
|
||||
// // 执行请求并处理响应
|
||||
// try (CloseableHttpResponse response = httpClient.execute(httpPut)) {
|
||||
// int statusCode = response.getStatusLine().getStatusCode();
|
||||
// HttpEntity responseEntity = response.getEntity();
|
||||
//
|
||||
// if (responseEntity == null) {
|
||||
// throw new IOException("Empty response entity");
|
||||
// }
|
||||
//
|
||||
// String responseBody = EntityUtils.toString(responseEntity, StandardCharsets.UTF_8);
|
||||
// logger.debug("Response status: {}, Body: {}", statusCode, responseBody);
|
||||
//
|
||||
// if (statusCode < 200 || statusCode >= 300) {
|
||||
// throw new IOException("HTTP request failed with status code: " + statusCode + "\n" + "HTTP request failed responseBody: " + responseBody);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } catch (IOException ex) {
|
||||
// lcLogService.savelog("FW_流程实例:流程撤回", WL_UnSubmit_URL, false, false, id.toString(), "接口调用报错,errormessage:" + ex.getMessage());
|
||||
// throw new RuntimeException(ex + "FW_流程实例:流程撤回失败" );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
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 + "流程撤回失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -287,7 +287,7 @@ public class FWRestfulUtils {
|
|||
* @param billno
|
||||
* @return
|
||||
*/
|
||||
public static String getFwWorkFlowInfo(String requestName,String billno, String requestId, String userId){
|
||||
public static String getRequest(String requestName,String billno, String requestId, String userId){
|
||||
Map<String, Object> registMap = regist();
|
||||
if(registMap != null && registMap.size() > 0){
|
||||
String spk = StrUtil.nullToEmpty((String) registMap.get("spk"));
|
||||
|
|
@ -308,7 +308,7 @@ public class FWRestfulUtils {
|
|||
urlBuilder.append("?requestId=").append(requestId); // 手动拼接参数
|
||||
// list.add(new BasicNameValuePair("requestId", requestId));
|
||||
|
||||
HttpGet httpGet = new HttpGet(urlBuilder.toString());
|
||||
HttpGet httpRequest = new HttpGet(urlBuilder.toString());
|
||||
// HttpPost httpPost = new HttpPost(url);
|
||||
|
||||
|
||||
|
|
@ -332,11 +332,85 @@ public class FWRestfulUtils {
|
|||
|
||||
try{
|
||||
// httpGet.addHeader("requestId", list.toString());
|
||||
httpGet.addHeader("appid",FW_appid);
|
||||
httpGet.addHeader("token",token);
|
||||
httpGet.addHeader("userid",encryptUserid);
|
||||
httpRequest.addHeader("appid",FW_appid);
|
||||
httpRequest.addHeader("token",token);
|
||||
httpRequest.addHeader("userid",encryptUserid);
|
||||
// httpPost.setEntity(new UrlEncodedFormEntity(list, "UTF-8"));
|
||||
response = httpClient.execute(httpGet);
|
||||
response = httpClient.execute(httpRequest);
|
||||
if (response != null && response.getEntity() != null) {
|
||||
//返回信息
|
||||
String resulString = EntityUtils.toString(response.getEntity());
|
||||
pushlog.set("tqq9_returnstring_tag", resulString);
|
||||
System.out.println("成功"+ resulString);
|
||||
OperationServiceHelper.executeOperate("save", "tqq9_fwpushlog", new DynamicObject[]{pushlog}, OperateOption.create());
|
||||
return resulString;
|
||||
}else{
|
||||
pushlog.set("tqq9_returnstring_tag", response.toString());
|
||||
OperationServiceHelper.executeOperate("save", "tqq9_fwpushlog", new DynamicObject[]{pushlog}, OperateOption.create());
|
||||
System.out.println("获取数据失败,请查看日志"+currentDate+" "+currentTime);
|
||||
}
|
||||
}catch (Exception e){
|
||||
System.out.println("请求失败"+currentDate+" "+currentTime+"====errormsg:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static String postRequest(String requestName,String billno,String isremind , String requestId, String userId, String URL){
|
||||
Map<String, Object> registMap = regist();
|
||||
if(registMap != null && registMap.size() > 0){
|
||||
String spk = StrUtil.nullToEmpty((String) registMap.get("spk"));
|
||||
String secrit = StrUtil.nullToEmpty((String) registMap.get("secrit"));
|
||||
if(StringUtils.isNotBlank(spk) && StringUtils.isNotBlank(secrit)){
|
||||
String token = getoken(spk, secrit);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
CloseableHttpResponse response;// 响应类,
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
|
||||
//装填参数
|
||||
List<BasicNameValuePair> list = new ArrayList<>();
|
||||
list.add(new BasicNameValuePair("requestId", requestId));
|
||||
list.add(new BasicNameValuePair("isremind", isremind));
|
||||
|
||||
//restful接口url
|
||||
// String url = FW_Main_URL + "api/workflow/paService/submitRequest";
|
||||
String url = FW_Main_URL + URL;
|
||||
// StringBuilder urlBuilder = new StringBuilder(url);
|
||||
// urlBuilder.append("?requestId=").append(requestId); // 手动拼接参数
|
||||
// list.add(new BasicNameValuePair("requestId", requestId));
|
||||
|
||||
HttpPost httpRequest = new HttpPost(url);
|
||||
// HttpPost httpPost = new HttpPost(url);
|
||||
|
||||
|
||||
//当前日期
|
||||
String currentDate = getCurrentDate();
|
||||
//当前时间
|
||||
String currentTime = getCurrentTime();
|
||||
//封装请求头参数
|
||||
RSA rsa = new RSA(null,spk);
|
||||
//对用户信息进行加密传输,暂仅支持传输OA用户ID
|
||||
String encryptUserid = rsa.encryptBase64(userId, CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey);
|
||||
|
||||
DynamicObject pushlog = BusinessDataServiceHelper.newDynamicObject("tqq9_fwpushlog");
|
||||
pushlog.set("name", requestName);
|
||||
pushlog.set("tqq9_billno", billno);
|
||||
pushlog.set("tqq9_url", url);
|
||||
pushlog.set("tqq9_header_tag", "appid:"+FW_appid+";token:"+token+";userid:"+encryptUserid);
|
||||
pushlog.set("tqq9_body_tag", JSON.toJSONString(list));
|
||||
pushlog.set("enable", "1");
|
||||
pushlog.set("status", "C");
|
||||
|
||||
try{
|
||||
// httpGet.addHeader("requestId", list.toString());
|
||||
httpRequest.addHeader("appid",FW_appid);
|
||||
httpRequest.addHeader("token",token);
|
||||
httpRequest.addHeader("userid",encryptUserid);
|
||||
httpRequest.setEntity(new UrlEncodedFormEntity(list, "UTF-8"));
|
||||
response = httpClient.execute(httpRequest);
|
||||
if (response != null && response.getEntity() != null) {
|
||||
//返回信息
|
||||
String resulString = EntityUtils.toString(response.getEntity());
|
||||
|
|
|
|||
Loading…
Reference in New Issue