其他入库申请单调用FW_获取流程流转数据(OtherInApplyWorkflowDataListPlugin)
This commit is contained in:
parent
15bf6bbf46
commit
2fd01e15bf
|
|
@ -0,0 +1,139 @@
|
|||
package tqq9.lc123.cloud.app.plugin.form.result;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import kd.bos.bill.BillShowParameter;
|
||||
import kd.bos.context.RequestContext;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.datamodel.events.PackageDataEvent;
|
||||
import kd.bos.list.events.BeforeShowBillFormEvent;
|
||||
import kd.bos.list.plugin.AbstractListPlugin;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import tqq9.lc123.cloud.app.plugin.utils.FWRestfulUtils;
|
||||
|
||||
/**
|
||||
* 标准单据列表插件
|
||||
* 在列表点击打开的其他入库单时触发调用 FW_获取流程流转数据
|
||||
*/
|
||||
public class OtherInApplyWorkflowDataListPlugin extends AbstractListPlugin implements Plugin {
|
||||
// private static String FW_DataFlow_URL;
|
||||
//
|
||||
// static {
|
||||
// DynamicObject url = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name",
|
||||
// new QFilter[]{new QFilter("number", QCP.equals, "FW_DataFlow_URL")});
|
||||
// FW_DataFlow_URL = url != null ? url.getString("name") : null;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void beforeShowBill(BeforeShowBillFormEvent e) {
|
||||
super.beforeShowBill(e);
|
||||
// BillShowParameter parameter = e.getParameter();
|
||||
//
|
||||
// DynamicObject tqq9_otherinapply = BusinessDataServiceHelper.loadSingle(parameter.getPkId(), "tqq9_otherinapply");
|
||||
// String tqq9_fwrequestid = tqq9_otherinapply.getString("tqq9_fwrequestid");
|
||||
// if (StringUtils.isNotBlank(tqq9_fwrequestid)) {
|
||||
// LCLogService lcLogService = new LCLogServiceImpl();
|
||||
// HashMap<String, Object> params = new HashMap<>();
|
||||
// HashMap<String, String> headers = new HashMap<>();
|
||||
// params.put("requestid", tqq9_fwrequestid);
|
||||
// Map<String, Object> registMap = FWRestfulUtils.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 = FWRestfulUtils.getoken(spk, secrit);
|
||||
// if (StringUtils.isBlank(token)) {
|
||||
// lcLogService.savelog("FW_获取流程流转数据", FWRestfulUtils.getCurrentTime(), false, false, params.toString(), "获取token失败");
|
||||
// return;
|
||||
// }
|
||||
// if (StringUtils.isNotBlank(token)) {
|
||||
// headers.put("Authorization", token);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// Gson gson = new Gson();
|
||||
// try {
|
||||
// String bodyString = HttpRequestUtils.doGet(FW_DataFlow_URL, params, headers);
|
||||
// JSONObject map = gson.fromJson(bodyString, JSONObject.class);
|
||||
// String code = map.getString("code");
|
||||
// if ("SUCCESS".equals(code)) {
|
||||
// lcLogService.savelog("FW_获取流程流转数据", FW_DataFlow_URL, false, true, params.toString(), bodyString);
|
||||
// } else {
|
||||
// lcLogService.savelog("FW_获取流程流转数据", FW_DataFlow_URL, false, false, params.toString(), "接口调用失败,errMsg:" + bodyString);
|
||||
// }
|
||||
// } catch (IOException ex) {
|
||||
// lcLogService.savelog("FW_获取流程流转数据", FW_DataFlow_URL, false, false, params.toString(), "接口调用报错,errormessage:" + ex.getMessage());
|
||||
// throw new RuntimeException(ex);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packageData(PackageDataEvent e) {
|
||||
super.packageData(e);
|
||||
// DynamicObject tqq9_otherinapply = BusinessDataServiceHelper.loadSingle(e.getRowData().getPkValue(), "tqq9_otherinapply");
|
||||
// String billstatus = tqq9_otherinapply.getString("billstatus");
|
||||
// if ("B".equals(billstatus)) {//已提交
|
||||
// String tqq9_fwrequestid = e.getRowData().getString("tqq9_fwrequestid");//"69187"
|
||||
// String billno = e.getRowData().getString("billno");//"QTRKSH251218002"
|
||||
// String userid = null;
|
||||
// //获取当前用户id
|
||||
// Long id = RequestContext.get().getCurrUserId();
|
||||
// DynamicObject user = BusinessDataServiceHelper.loadSingle("bos_user",
|
||||
// new QFilter[]{new QFilter("id", QCP.equals, id)});
|
||||
// DynamicObjectCollection entryentity = (DynamicObjectCollection) user.get("entryentity");
|
||||
// if (entryentity != null && entryentity.size() > 0) {
|
||||
// for (DynamicObject entry : entryentity) {
|
||||
// userid = entry.getString("tqq9_fwuserid");
|
||||
// if (StringUtils.isNotBlank(userid)) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (userid == null) {
|
||||
// //获取泛微人员id失败
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// if (StringUtils.isNotBlank(tqq9_fwrequestid)) {
|
||||
// String requestName = "FW_获取流程流转数据";
|
||||
// String bodyString = FWRestfulUtils.getFwWorkFlowInfo(requestName, billno, tqq9_fwrequestid, userid);
|
||||
// JSONObject map = JSONObject.parseObject(bodyString);
|
||||
// JSONArray data = map.getJSONArray("data");//节点id
|
||||
// JSONObject data0 = null;
|
||||
// String nodeName = null;
|
||||
// String fwuserid = null;
|
||||
// if (data != null && data.size() > 0) {
|
||||
// for (int i = 0; i < data.size(); i++) {
|
||||
// data0 = (JSONObject) data.get(i);
|
||||
// Integer isremake = data0.getInteger("isremake");
|
||||
// nodeName = data0.getString("nodeName");
|
||||
// if (StringUtils.isNotBlank(nodeName)) {
|
||||
// if (isremake == 0 && !nodeName.contains("归档")) {
|
||||
// fwuserid = String.valueOf(data0.getInteger("userid"));
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (StringUtils.isNotBlank(nodeName)) {
|
||||
// if (!nodeName.contains("归档") && StringUtils.isNotBlank(fwuserid)) {
|
||||
// DynamicObject fwuser = BusinessDataServiceHelper.loadSingle("bos_user",
|
||||
// new QFilter[]{new QFilter("entryentity.tqq9_fwuserid", QCP.equals, fwuserid)});
|
||||
// if (fwuser != null) {
|
||||
// tqq9_otherinapply.set("tqq9_auditor", fwuser);//待审批人
|
||||
// tqq9_otherinapply.set("tqq9_auditornode", nodeName);//节点名称
|
||||
// SaveServiceHelper.save(new DynamicObject[]{tqq9_otherinapply});
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@ import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
|
|
@ -279,6 +280,84 @@ public class FWRestfulUtils {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 调用泛微流程接口
|
||||
* @param requestName
|
||||
* @param billno
|
||||
* @return
|
||||
*/
|
||||
public static String getFwWorkFlowInfo(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"));
|
||||
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<>();
|
||||
|
||||
//restful接口url
|
||||
// String url = FW_Main_URL + "api/workflow/paService/submitRequest";
|
||||
String url = FW_Main_URL + "api/workflow/paService/getRequestOperatorInfo";
|
||||
StringBuilder urlBuilder = new StringBuilder(url);
|
||||
urlBuilder.append("?requestId=").append(requestId); // 手动拼接参数
|
||||
// list.add(new BasicNameValuePair("requestId", requestId));
|
||||
|
||||
HttpGet httpGet = new HttpGet(urlBuilder.toString());
|
||||
// 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());
|
||||
httpGet.addHeader("appid",FW_appid);
|
||||
httpGet.addHeader("token",token);
|
||||
httpGet.addHeader("userid",encryptUserid);
|
||||
// httpPost.setEntity(new UrlEncodedFormEntity(list, "UTF-8"));
|
||||
response = httpClient.execute(httpGet);
|
||||
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 String getMD5Str(String plainText){
|
||||
//定义一个字节数组
|
||||
byte[] secretBytes = null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue