其他入库申请单调用FW_获取流程流转数据(OtherInApplyWorkflowDataListPlugin)修改

This commit is contained in:
pan-houxiang 2025-12-19 11:50:46 +08:00
parent a0d2825ca8
commit b1bc25c9e9
1 changed files with 86 additions and 58 deletions

View File

@ -2,12 +2,13 @@ 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.ListSelectedRow;
import kd.bos.entity.datamodel.ListSelectedRowCollection;
import kd.bos.entity.datamodel.events.PackageDataEvent;
import kd.bos.list.events.BeforeShowBillFormEvent;
import kd.bos.list.BillList;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
@ -17,72 +18,99 @@ import kd.sdk.plugin.Plugin;
import org.apache.commons.lang3.StringUtils;
import tqq9.lc123.cloud.app.plugin.utils.FWRestfulUtils;
import java.util.EventObject;
import java.util.HashSet;
import java.util.Set;
/**
* 标准单据列表插件
* 在列表点击打开的其他入库单时触发调用 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);
// }
//
// }
public void afterBindData(EventObject e) {
super.afterBindData(e);
BillList b = this.getView().getControl("billlistap");
ListSelectedRowCollection currentListAllRowCollection = b.getCurrentListAllRowCollection();
Set<Long> idSet = new HashSet<>();
for (ListSelectedRow row : currentListAllRowCollection) {
Long primaryKeyValue = (Long) row.getPrimaryKeyValue();
idSet.add(primaryKeyValue);
}
QFilter f = new QFilter("id", "in", idSet);
DynamicObject[] billArr = BusinessDataServiceHelper.load("tqq9_otherinapply",
"id,billno,tqq9_fwrequestid,tqq9_fwstate,tqq9_auditor,tqq9_auditornode", new QFilter[]{f});
for (DynamicObject tqq9_otherinapply : billArr) {
String billno = tqq9_otherinapply.getString("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)){
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;
}
}
String requestName = "FW_获取流程流转数据";
String bodyString = FWRestfulUtils.getFwWorkFlowInfo(requestName, billno, tqq9_fwrequestid, userid);
JSONObject map = JSONObject.parseObject(bodyString);
JSONArray data = map.getJSONArray("data");//节点id
if (data != null && data.size() > 0) {
String nodeName = null;
String fwuserid = null;
for (int i = 0; i < data.size(); i++) {
JSONObject data0 = (JSONObject) data.get(i);
Integer isremark = data0.getInteger("isremark");
nodeName = data0.getString("nodeName");
if (StringUtils.isNotBlank(nodeName) && isremark != null) {
if (isremark == 0 && !nodeName.contains("归档")) {
fwuserid = String.valueOf(data0.getInteger("userid"));
break;
}
}
}
if (StringUtils.isNotBlank(fwuserid)) {
DynamicObject[] fwuserArr = BusinessDataServiceHelper.load("bos_user", "id,name,number",
new QFilter[]{new QFilter("entryentity.tqq9_fwuserid", QCP.equals, fwuserid)});
if (fwuserArr != null && fwuserArr.length > 0) {
tqq9_otherinapply.set("tqq9_auditor", fwuserArr[0]);//待审批人
tqq9_otherinapply.set("tqq9_auditornode", nodeName);//节点名称
SaveServiceHelper.save(new DynamicObject[]{tqq9_otherinapply});
}
}
}
}
}
}
@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_fwstate = tqq9_otherinapply.getString("tqq9_fwstate");
// if ("B".equals(tqq9_fwstate)) {//已提交
// String tqq9_fwrequestid = e.getRowData().getString("tqq9_fwrequestid");//"69187"
// String billno = e.getRowData().getString("billno");//"QTRKSH251218002"
// String billno = e.getRowData().getString("billno");//"QTRKSH251218002" , QTRKSH251218002
// String userid = null;
// //获取当前用户id
// Long id = RequestContext.get().getCurrUserId();
@ -112,10 +140,10 @@ public class OtherInApplyWorkflowDataListPlugin extends AbstractListPlugin imple
// if (data != null && data.size() > 0) {
// for (int i = 0; i < data.size(); i++) {
// data0 = (JSONObject) data.get(i);
// Integer isremake = data0.getInteger("isremake");
// Integer isremark = data0.getInteger("isremark");
// nodeName = data0.getString("nodeName");
// if (StringUtils.isNotBlank(nodeName)) {
// if (isremake == 0 && !nodeName.contains("归档")) {
// if (StringUtils.isNotBlank(nodeName) && isremark != null) {
// if (isremark == 0 && !nodeName.contains("归档")) {
// fwuserid = String.valueOf(data0.getInteger("userid"));
// break;
// }