From 5c569c2fb4d9594d5b374177fe8f8a1518b59d4f Mon Sep 17 00:00:00 2001 From: huangdehua <2329023417@qq.com> Date: Mon, 29 Jun 2026 18:39:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A5=E4=BC=9A=E7=94=B3=E8=AF=B7=E4=B8=8E?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8=20=E5=88=97=E8=A1=A8=E5=8F=98=E6=9B=B4?= =?UTF-8?q?=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/MembershipApplyListFilterPlugin.java | 37 ++++ .../member/ViewHistoryBillOperationPlugin.java | 222 +++++++++++++++++++++ 2 files changed, 259 insertions(+) create mode 100644 common/common-association/src/main/java/apelet/association/plugin/member/MembershipApplyListFilterPlugin.java create mode 100644 common/common-association/src/main/java/apelet/association/plugin/member/ViewHistoryBillOperationPlugin.java diff --git a/common/common-association/src/main/java/apelet/association/plugin/member/MembershipApplyListFilterPlugin.java b/common/common-association/src/main/java/apelet/association/plugin/member/MembershipApplyListFilterPlugin.java new file mode 100644 index 0000000..e83f43a --- /dev/null +++ b/common/common-association/src/main/java/apelet/association/plugin/member/MembershipApplyListFilterPlugin.java @@ -0,0 +1,37 @@ +package apelet.association.plugin.member; + +import apelet.common.core.object.ObjectCollection; +import apelet.common.core.object.ObjectValue; +import apelet.common.generator.utils.OrmGenDataSourceUtil; +import apelet.common.online.abstractplugin.ListPlugin; +import apelet.common.orm.impl.Filter; +import apelet.common.orm.impl.FilterItem; +import apelet.common.online.plugin.BeforeExecuteOperationArgs; +import apelet.common.online.plugin.OperationResult; +import apelet.common.online.plugin.OperationServicePlugIn; + +/** + * @ClassName: MembershipApplyListFilterPlugin + * @Author: huangdehua + * @Date: 2026/5/9 + * @Description: 入会申请列表过滤插件 + * 在列表加载前添加过滤条件,只显示最新单据(is_history=0) + */ +public class MembershipApplyListFilterPlugin extends ListPlugin { + /** + * 是否历史字段 + */ + private static final String FIELD_IS_HISTORY = "is_history"; + + /** + * 非历史记录 + */ + private static final Integer IS_HISTORY_NO = 0; + + @Override + protected Filter getFilter() { + Filter filter = new Filter(); + filter.add(new FilterItem(FIELD_IS_HISTORY, "=", IS_HISTORY_NO)); + return filter; + } +} \ No newline at end of file diff --git a/common/common-association/src/main/java/apelet/association/plugin/member/ViewHistoryBillOperationPlugin.java b/common/common-association/src/main/java/apelet/association/plugin/member/ViewHistoryBillOperationPlugin.java new file mode 100644 index 0000000..b6e78d9 --- /dev/null +++ b/common/common-association/src/main/java/apelet/association/plugin/member/ViewHistoryBillOperationPlugin.java @@ -0,0 +1,222 @@ +package apelet.association.plugin.member; + +import apelet.common.core.object.ObjectCollection; +import apelet.common.core.object.ObjectValue; +import apelet.common.generator.utils.OrmGenDataSourceUtil; +import apelet.common.orm.impl.Filter; +import apelet.common.orm.impl.FilterItem; +import apelet.common.online.abstractplugin.ExecutePluginParent; +import apelet.common.online.model.ShowParameter; +import apelet.common.online.model.constant.ShowTypeEnum; +import apelet.common.online.model.constant.ViewStatus; + +import java.util.HashMap; +import java.util.Map; + +/** + * @ClassName: ViewHistoryBillOperationPlugin + * @Author: huangdehua + * @Date: 2026/5/9 + * @Description: 查看历史单据操作插件 + * 点击"查看历史"按钮时,弹出一个显示当前选中单据所有历史变更记录的列表 + */ +public class ViewHistoryBillOperationPlugin extends ExecutePluginParent { + + /** + * 触发按钮的标识 - 对应表单上按钮的 key/标识 + */ + private static final String BUTTON_KEY = "查看历史"; + + /** + * 列表页面中表格控件的变量名/key + */ + private static final String TABLE_WIDGET_KEY = "membership_apply_list"; + + /** + * 历史单据列表表单ID + * 需要在平台配置中创建历史单据列表表单并配置此ID + */ + private static final String HISTORY_LIST_FORM_ID = "membership_apply_history_list"; + + /** + * 传递到历史列表的参数key - 单据编号 + */ + private static final String PARAM_BILL_NUMBER = "billNumber"; + + /** + * 主表名 + */ + private static final String TABLE_NAME = "membership_apply"; + + /** + * 字段:单据编号 + */ + private static final String FIELD_NUMBER = "number"; + + /** + * 字段:是否历史 + */ + private static final String FIELD_IS_HISTORY = "is_history"; + + /** + * 字段:单据状态 + */ + private static final String FIELD_BILL_STATUS = "billstatus"; + + /** + * 字段:版本号 + */ + private static final String FIELD_VERSION_NUMBER = "version_number"; + + /** + * 字段:单位名称 + */ + private static final String FIELD_UNIT_NAME = "unit_name"; + + /** + * 字段:变更时间 + */ + private static final String FIELD_UPDATE_TIME = "update_time"; + + /** + * 按钮点击事件(列表按钮) + * 点击"查看历史"按钮时,通过 getSelectData 获取列表中选中行的单据编号, + * 查询该编号的所有历史记录并打开历史单据列表 + * + * @param buttonKey 按钮标识 + * @param objectValue 列表按钮事件数据对象 + */ + @Override + public void buttonTriggered(String buttonKey, ObjectValue objectValue) { + // 仅响应"查看历史"按钮的点击事件 + if (!BUTTON_KEY.equals(buttonKey)) { + return; + } + + // 【列表场景】通过 getSelectData 获取选中/点击行的数据 + Map selectedRow = getSelectData(objectValue, TABLE_WIDGET_KEY); + if (selectedRow == null) { + showWarningMessage("请先在列表中选中一条单据"); + return; + } + + // 从选中行中获取单据编号 + Object numberObj = selectedRow.get(FIELD_NUMBER); + String billNumber = (numberObj != null) ? numberObj.toString() : ""; + if (billNumber.isEmpty()) { + showWarningMessage("选中的单据缺少编号信息,请重新选择"); + return; + } + + // 查询该单据的所有历史记录 + ObjectCollection historyList = queryHistoryBills(billNumber); + if (historyList == null || historyList.isEmpty()) { + showWarnMessage("该单据暂无历史变更记录"); + return; + } + + // 打开历史单据列表弹窗 + openHistoryListPopup(billNumber, historyList); + } + + /** + * 查询单据的历史记录 + * + * @param billNumber 单据编号 + * @return 历史单据集合 + */ + private ObjectCollection queryHistoryBills(String billNumber) { + try { + OrmGenDataSourceUtil ormUtil = (OrmGenDataSourceUtil) ormGenDataSourceUtil(); + if (ormUtil == null) { + return null; + } + + // 查询条件:相同单据编号的所有记录(按版本号降序) + Filter filter = new Filter(); + filter.add(new FilterItem(FIELD_NUMBER, "=", billNumber)); + // 排序:版本号降序,最新在前 + String orderBy = FIELD_VERSION_NUMBER + " desc"; + + ObjectCollection result = ormUtil.query(TABLE_NAME, filter, null); + return result; + + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 打开历史单据列表弹窗 + * + * @param billNumber 单据编号 + * @param historyList 历史单据列表 + */ + private void openHistoryListPopup(String billNumber, ObjectCollection historyList) { + ShowParameter showParameter = new ShowParameter(); + showParameter.setFormId(HISTORY_LIST_FORM_ID); + showParameter.setHowType(ShowTypeEnum.OPEN_ONLINE_MODAL); + showParameter.setStatus(ViewStatus.VIEW); + + // 设置自定义参数 + Map customParam = new HashMap<>(); + customParam.put(PARAM_BILL_NUMBER, billNumber); + // 将历史数据也传递过去 + customParam.put("historyList", historyList); + showParameter.setCustomParam(customParam); + + super.showForm(showParameter); + } + + /** + * 显示警告消息 + * + * @param message 警告消息内容 + */ + private void showWarnMessage(String message) { + try { + // 尝试通过OperationResult显示消息 + apelet.common.online.plugin.OperationResult result = + new apelet.common.online.plugin.OperationResult(); + result.setSuccess(true); + result.setShowMessage(true); + result.setMessage(message); + //setOperationResult(result); + } catch (Exception e) { + // 如果框架不支持OperationResult,则打印到控制台 + System.out.println("[ViewHistoryBillOperationPlugin] " + message); + } + } + + /** + * 辅助方法:格式化历史单据信息用于显示 + * + * @param historyBill 历史单据对象 + * @return 格式化的字符串 + */ + public String formatHistoryBillInfo(ObjectValue historyBill) { + if (historyBill == null) { + return ""; + } + + StringBuilder sb = new StringBuilder(); + sb.append("版本号:").append(historyBill.get(FIELD_VERSION_NUMBER)); + sb.append(",单位名称:").append(historyBill.get(FIELD_UNIT_NAME)); + sb.append(",状态:").append(historyBill.get(FIELD_BILL_STATUS)); + sb.append(",变更时间:").append(historyBill.get(FIELD_UPDATE_TIME)); + + return sb.toString(); + } + + /** + * 获取当前单据的历史记录数量 + * + * @param billNumber 单据编号 + * @return 历史记录数量 + */ + public int getHistoryCount(String billNumber) { + ObjectCollection historyList = queryHistoryBills(billNumber); + return historyList != null ? historyList.size() : 0; + } +}