From b1bc25c9e9d5df473650a2c5d392316701d53cfa Mon Sep 17 00:00:00 2001 From: pan-houxiang <2663608154@qq.com> Date: Fri, 19 Dec 2025 11:50:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B6=E4=BB=96=E5=85=A5=E5=BA=93=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E5=8D=95=E8=B0=83=E7=94=A8FW=5F=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E6=B5=81=E8=BD=AC=E6=95=B0=E6=8D=AE=EF=BC=88?= =?UTF-8?q?OtherInApplyWorkflowDataListPlugin=EF=BC=89=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OtherInApplyWorkflowDataListPlugin.java | 144 +++++++++++------- 1 file changed, 86 insertions(+), 58 deletions(-) diff --git a/lc123/cloud/app/plugin/form/result/OtherInApplyWorkflowDataListPlugin.java b/lc123/cloud/app/plugin/form/result/OtherInApplyWorkflowDataListPlugin.java index a69b6b5..4d25f3c 100644 --- a/lc123/cloud/app/plugin/form/result/OtherInApplyWorkflowDataListPlugin.java +++ b/lc123/cloud/app/plugin/form/result/OtherInApplyWorkflowDataListPlugin.java @@ -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 params = new HashMap<>(); -// HashMap headers = new HashMap<>(); -// params.put("requestid", tqq9_fwrequestid); -// Map 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 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; // }