Compare commits
18 Commits
master
...
dev_featur
| Author | SHA1 | Date |
|---|---|---|
|
|
3700a1e821 | 6 days ago |
|
|
8ea96c7116 | 1 week ago |
|
|
7935d60668 | 2 weeks ago |
|
|
829196f7f4 | 2 weeks ago |
|
|
a2a02a35f5 | 2 weeks ago |
|
|
5ddf2b6b46 | 2 weeks ago |
|
|
63fb628033 | 2 weeks ago |
|
|
a3664d011b | 2 weeks ago |
|
|
465703d38b | 2 weeks ago |
|
|
4636ddd78a | 2 weeks ago |
|
|
7ee8fa9597 | 2 weeks ago |
|
|
810152443b | 2 weeks ago |
|
|
c975221ea9 | 2 weeks ago |
|
|
7b87d80120 | 2 weeks ago |
|
|
e5b7b698a9 | 2 weeks ago |
|
|
61164e395b | 3 weeks ago |
|
|
fd8ff44d15 | 3 weeks ago |
|
|
b26509b119 | 3 weeks ago |
13 changed files with 878 additions and 16 deletions
@ -0,0 +1,76 @@ |
|||||||
|
package apelet.tenantadmin.tenant.plugin; |
||||||
|
|
||||||
|
import apelet.common.core.object.ObjectCollection; |
||||||
|
import apelet.common.core.object.ObjectValue; |
||||||
|
import apelet.common.core.object.TokenData; |
||||||
|
import apelet.common.core.util.ApplicationContextHolder; |
||||||
|
import apelet.common.generator.utils.OrmGenDataSourceUtil; |
||||||
|
import apelet.common.online.abstractplugin.ExecutePluginParent; |
||||||
|
import apelet.common.online.model.constant.AttributeEnum; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
/* |
||||||
|
报价单插件 |
||||||
|
*/ |
||||||
|
public class QuotationPlugin extends ExecutePluginParent { |
||||||
|
private static final OrmGenDataSourceUtil ORM_GEN_DATA_SOURCE_UTIL = ApplicationContextHolder.getBean(OrmGenDataSourceUtil.class); |
||||||
|
@Override |
||||||
|
public void formCreated(String widgetVariableName, ObjectValue objectValue){ |
||||||
|
super.formCreated(widgetVariableName, objectValue); |
||||||
|
//获取当前登录的用户ID
|
||||||
|
TokenData tokenData = TokenData.takeFromRequest(); |
||||||
|
Long userId = tokenData.getUserId(); |
||||||
|
//查询当前用户信息
|
||||||
|
ObjectValue sysUserInfo = ORM_GEN_DATA_SOURCE_UTIL.queryOne("xy_sys_user", userId); |
||||||
|
//赋值
|
||||||
|
if (sysUserInfo != null){ |
||||||
|
this.setWidgetAttribute("managerperson", AttributeEnum.VALUE_CHANGE, sysUserInfo); |
||||||
|
} |
||||||
|
|
||||||
|
//隐藏拒绝理由
|
||||||
|
this.setWidgetAttribute("canaelreason",AttributeEnum.SHOW,false); |
||||||
|
//设置报价单状态
|
||||||
|
this.setWidgetAttribute("status",AttributeEnum.VALUE_CHANGE,"1"); |
||||||
|
//设置总价初始值为0
|
||||||
|
this.setWidgetAttribute("qty",AttributeEnum.VALUE_CHANGE,0); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void change(String widgetVariableName, ObjectValue objectValue){ |
||||||
|
super.change(widgetVariableName, objectValue); |
||||||
|
//获取报价单状态
|
||||||
|
String status = objectValue.getString("status"); |
||||||
|
//若status为"4"
|
||||||
|
if(status.equals("4")){ |
||||||
|
this.setWidgetAttribute("canaelreason",AttributeEnum.SHOW,true); |
||||||
|
}else { |
||||||
|
this.setWidgetAttribute("canaelreason",AttributeEnum.SHOW,false); |
||||||
|
} |
||||||
|
|
||||||
|
//获取单据体
|
||||||
|
ObjectCollection quotationE = objectValue.getObjectCollection("quotation_e"); |
||||||
|
// 总金额
|
||||||
|
BigDecimal allTotalAmount = BigDecimal.ZERO; |
||||||
|
//判断是否有数据
|
||||||
|
if (quotationE != null && !quotationE.isEmpty()){ |
||||||
|
for (int i = 0; i < quotationE.size(); i++ ){ |
||||||
|
// 获取行数据
|
||||||
|
ObjectValue row = quotationE.getObject(i); |
||||||
|
//获取指导折扣价
|
||||||
|
BigDecimal discount = row.getBigDecimal("discount"); |
||||||
|
// 判空处理
|
||||||
|
if (discount == null) { |
||||||
|
discount = BigDecimal.ZERO; |
||||||
|
} |
||||||
|
//获取数量
|
||||||
|
int num = row.getInt("num"); |
||||||
|
|
||||||
|
// 计算总价 = 折扣价 * 数量
|
||||||
|
BigDecimal totalAmount = discount.multiply(BigDecimal.valueOf(num)); |
||||||
|
allTotalAmount = allTotalAmount.add(totalAmount); |
||||||
|
} |
||||||
|
this.setWidgetAttribute("qty",AttributeEnum.VALUE_CHANGE,allTotalAmount); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,25 @@ |
|||||||
|
package apelet.tenantadmin.tenant.plugin; |
||||||
|
|
||||||
|
import apelet.common.core.object.ObjectCollection; |
||||||
|
import apelet.common.core.object.ObjectValue; |
||||||
|
import apelet.common.online.plugin.BeforeExecuteOperationArgs; |
||||||
|
import apelet.common.online.plugin.OperationServicePlugIn; |
||||||
|
|
||||||
|
//提交后修改状态
|
||||||
|
public class StatusChangePlugin extends OperationServicePlugIn { |
||||||
|
@Override |
||||||
|
public void beforeExecuteOperationTransaction(BeforeExecuteOperationArgs e){ |
||||||
|
super.beforeExecuteOperationTransaction(e); |
||||||
|
ObjectCollection modelCollcetion = e.getModelCollcetion(); |
||||||
|
|
||||||
|
if(modelCollcetion != null && !modelCollcetion.isEmpty()){ |
||||||
|
for (int i = 0; i < modelCollcetion.size(); i++) { |
||||||
|
// 获取单据对象
|
||||||
|
ObjectValue bill = modelCollcetion.getObject(i); |
||||||
|
bill.setString("status","2"); |
||||||
|
//保存入库
|
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,17 @@ |
|||||||
|
package apelet.association.controller.plugin.formPlugin; |
||||||
|
|
||||||
|
import apelet.association.utils.CreatNumberUtils; |
||||||
|
import apelet.common.core.object.ObjectValue; |
||||||
|
import apelet.common.online.abstractplugin.ExecutePluginParent; |
||||||
|
import apelet.common.online.model.constant.AttributeEnum; |
||||||
|
public class ClueManageFormPlugin extends ExecutePluginParent { |
||||||
|
@Override |
||||||
|
public void formCreated(String widgetVariableName, ObjectValue objectValue) { |
||||||
|
super.formCreated(widgetVariableName, objectValue); |
||||||
|
// this.setAttribute("seekInfo","11");
|
||||||
|
// this.setWidgetAttribute("number", AttributeEnum.VALUE_CHANGE, "123");
|
||||||
|
CreatNumberUtils creatNumberUtils = new CreatNumberUtils(); |
||||||
|
this.setWidgetAttribute("billstatus", AttributeEnum.VALUE_CHANGE,"1"); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,56 @@ |
|||||||
|
package apelet.association.plugin.member; |
||||||
|
|
||||||
|
import apelet.common.core.object.ObjectValue; |
||||||
|
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: MembershipPayPopupPlugin |
||||||
|
* @Author: huangdehua |
||||||
|
* @Date: 2026/4/30 09:37 |
||||||
|
* @Description: |
||||||
|
*/ |
||||||
|
public class MembershipPayPopupPlugin extends ExecutePluginParent { |
||||||
|
|
||||||
|
/** |
||||||
|
* 目标表单ID - membershipFeePay 表单在平台中的表单ID |
||||||
|
*/ |
||||||
|
private static final Object FORM_ID = "2049040032123064320"; |
||||||
|
|
||||||
|
/** |
||||||
|
* 触发按钮的标识 - 对应表单上按钮的 key/标识 |
||||||
|
* 点击此按钮时触发弹窗 |
||||||
|
*/ |
||||||
|
private static final String BUTTON_KEY = "会费缴纳"; |
||||||
|
|
||||||
|
/** |
||||||
|
* 按钮点击事件 |
||||||
|
* 点击按钮时,以弹窗方式打开 membershipFeePay 表单 |
||||||
|
* |
||||||
|
* @param buttonKey 按钮标识 |
||||||
|
* @param objectValue 当前表单数据对象 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void buttonTriggered(String buttonKey, ObjectValue objectValue) { |
||||||
|
// 仅响应指定按钮的点击事件
|
||||||
|
if (!BUTTON_KEY.equals(buttonKey)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// 调用 showForm 打开 membershipFeePay 表单
|
||||||
|
ShowParameter showParameter = new ShowParameter(); |
||||||
|
showParameter.setFormId(FORM_ID.toString()); |
||||||
|
showParameter.setHowType(ShowTypeEnum.OPEN_ONLINE_MODAL); |
||||||
|
showParameter.setStatus(ViewStatus.EDIT); |
||||||
|
Map<String, Object> customParam = new HashMap<>(); |
||||||
|
customParam.put("id"," "); |
||||||
|
showParameter.setCustomParam(customParam); |
||||||
|
super.showForm(showParameter); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
@ -0,0 +1,40 @@ |
|||||||
|
package apelet.association.plugin.member; |
||||||
|
|
||||||
|
import apelet.common.core.object.ObjectValue; |
||||||
|
import apelet.common.online.abstractplugin.ExecutePluginParent; |
||||||
|
import apelet.common.online.model.constant.AttributeEnum; |
||||||
|
|
||||||
|
import java.util.Objects; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @ClassName: MembershipPayShowHidePlugin |
||||||
|
* @Author: huangdehua |
||||||
|
* @Date: 2026/5/7 15:00 |
||||||
|
* @Description: 会费缴纳界面会员类别为非会员时显示银行收款凭证号字段,其他情况隐藏 |
||||||
|
*/ |
||||||
|
public class MembershipPayShowHidePlugin extends ExecutePluginParent { |
||||||
|
@Override |
||||||
|
public void formCreated(String widgetVariableName, ObjectValue objectValue) { |
||||||
|
super.formCreated(widgetVariableName, objectValue); |
||||||
|
String membershipType = objectValue.getString("membershipType"); |
||||||
|
if (Objects.equals(membershipType, "E")){ |
||||||
|
super.setWidgetAttribute("bankReceiptV", AttributeEnum.SHOW, true); |
||||||
|
}else { |
||||||
|
super.setWidgetAttribute("bankReceiptV", AttributeEnum.SHOW, false); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void change(String widgetVariableName, ObjectValue objectValue) { |
||||||
|
super.change(widgetVariableName, objectValue); |
||||||
|
String membershipType = objectValue.getString("membership_type"); |
||||||
|
if (Objects.equals(widgetVariableName, "membershipType")){ |
||||||
|
if (Objects.equals(membershipType, "E")){ |
||||||
|
super.setWidgetAttribute("bankReceiptV", AttributeEnum.SHOW, true); |
||||||
|
}else { |
||||||
|
super.setWidgetAttribute("bankReceiptV", AttributeEnum.SHOW, false); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,211 @@ |
|||||||
|
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.ExecutePluginParent; |
||||||
|
import apelet.common.online.model.constant.AttributeEnum; |
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
|
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @ClassName: UnitNameChangeFormInitPlugin |
||||||
|
* @Author: huangdehua |
||||||
|
* @Date: 2026/5/9 |
||||||
|
* @Description: 入会申请与审核表单初始化插件(变更模式) |
||||||
|
* 如果是从"变更"按钮弹出的表单,则设置其他字段为只读,只有单位名称可编辑 |
||||||
|
*/ |
||||||
|
public class UnitNameChangeFormInitPlugin extends ExecutePluginParent { |
||||||
|
|
||||||
|
/** |
||||||
|
* 来源参数key - 单据ID |
||||||
|
*/ |
||||||
|
private static final String PARAM_BILL_ID = "sourceBillId"; |
||||||
|
|
||||||
|
/** |
||||||
|
* 来源参数key - 单据编号 |
||||||
|
*/ |
||||||
|
private static final String PARAM_BILL_NUMBER = "sourceBillNumber"; |
||||||
|
|
||||||
|
/** |
||||||
|
* 需要设置为只读的字段列表(除单位名称外) |
||||||
|
*/ |
||||||
|
private static final String[] READONLY_FIELDS = { |
||||||
|
"id", // 主键
|
||||||
|
"number", // 单据编号
|
||||||
|
"billstatus", // 单据状态
|
||||||
|
"membershipMangerId",// 会员负责人
|
||||||
|
"unitName", // 单位名称
|
||||||
|
"natureUnit", // 单位性质
|
||||||
|
"menbershipAttributes",// 会员属性
|
||||||
|
"scopeBusiness", // 业务经营范围
|
||||||
|
"membershipType", // 会员类型
|
||||||
|
"businessRegistNumber",// 工商注册号
|
||||||
|
"registCapital", // 注册资金
|
||||||
|
"registTime", // 注册时间
|
||||||
|
"bankReceiptV", // 银行收款凭证号
|
||||||
|
"companyAddress", // 企业地址
|
||||||
|
"history", // 是否历史
|
||||||
|
"versionNumber", // 版本号
|
||||||
|
"membership_apply_entry", |
||||||
|
"table1777360622546" |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* 允许在变更模式下编辑的字段列表(单位名称相关) |
||||||
|
*/ |
||||||
|
private static final String[] EDITABLE_UNIT_NAME_FIELDS = { |
||||||
|
"unitName", |
||||||
|
"unitname" |
||||||
|
}; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void formCreated(String widgetVariableName, ObjectValue objectValue) { |
||||||
|
super.formCreated(widgetVariableName, objectValue); |
||||||
|
|
||||||
|
// 获取源单据ID
|
||||||
|
String sourceBillId = getSourceBillId(objectValue); |
||||||
|
String sourceBillNumber = getSourceBillNumber(objectValue); |
||||||
|
|
||||||
|
// 如果没有源单据ID,说明不是变更操作,正常返回
|
||||||
|
if (sourceBillId == null || sourceBillId.isEmpty()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// 这是从"变更"按钮弹出的表单
|
||||||
|
// 1. 查询源单据数据并填充到当前表单
|
||||||
|
fillSourceBillData(objectValue, sourceBillId, sourceBillNumber); |
||||||
|
|
||||||
|
// 2. 设置其他字段为只读,只有单位名称可编辑
|
||||||
|
setFieldsReadonly(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 从ObjectValue中获取源单据ID |
||||||
|
* 从 eventparams 中获取 |
||||||
|
*/ |
||||||
|
private String getSourceBillId(ObjectValue objectValue) { |
||||||
|
Object eventparams = objectValue.get("eventparams"); |
||||||
|
if (eventparams instanceof JSONObject){ |
||||||
|
return ((JSONObject) eventparams).getString(PARAM_BILL_ID); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 从ObjectValue中获取源单据编号 |
||||||
|
* 从 eventparams 中获取 |
||||||
|
*/ |
||||||
|
private String getSourceBillNumber(ObjectValue objectValue) { |
||||||
|
Object eventparams = objectValue.get("eventparams"); |
||||||
|
if (eventparams instanceof JSONObject){ |
||||||
|
return ((JSONObject) eventparams).getString(PARAM_BILL_NUMBER); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置字段为只读 |
||||||
|
* 只有单位名称字段可编辑,其他字段全部只读 |
||||||
|
*/ |
||||||
|
private void setFieldsReadonly() { |
||||||
|
// 设置所有需要只读的字段为禁用(不可编辑)
|
||||||
|
for (String field : READONLY_FIELDS) { |
||||||
|
try { |
||||||
|
this.setWidgetAttribute(field, AttributeEnum.DISABLED, true); |
||||||
|
} catch (Exception e) { |
||||||
|
// 字段可能不存在,忽略异常
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// 确保单位名称字段可编辑
|
||||||
|
for (String field : EDITABLE_UNIT_NAME_FIELDS) { |
||||||
|
try { |
||||||
|
this.setWidgetAttribute(field, AttributeEnum.DISABLED, false); |
||||||
|
this.setWidgetAttribute(field, AttributeEnum.SHOW, true); |
||||||
|
} catch (Exception e) { |
||||||
|
// 字段可能不存在,忽略异常
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// 禁用子表
|
||||||
|
try { |
||||||
|
this.setWidgetAttribute("membership_apply_entry", AttributeEnum.DISABLED, true); |
||||||
|
this.setWidgetAttribute("membershipApplyEntry", AttributeEnum.DISABLED, true); |
||||||
|
this.setWidgetAttribute("table1777360622546", AttributeEnum.DISABLED, true); |
||||||
|
} catch (Exception e) { |
||||||
|
// 子表可能不存在,忽略异常
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取源单据数据并填充到当前表单 |
||||||
|
* |
||||||
|
* @param objectValue 当前表单数据对象 |
||||||
|
* @param sourceBillId 源单据ID |
||||||
|
* @param sourceBillNumber 源单据编号 |
||||||
|
*/ |
||||||
|
private void fillSourceBillData(ObjectValue objectValue, String sourceBillId, String sourceBillNumber) { |
||||||
|
try { |
||||||
|
// 从数据库查询源单据数据
|
||||||
|
apelet.common.generator.utils.OrmGenDataSourceUtil ormUtil = (OrmGenDataSourceUtil) ormGenDataSourceUtil(); |
||||||
|
if (ormUtil == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// 构建查询条件
|
||||||
|
apelet.common.orm.impl.Filter filter = new apelet.common.orm.impl.Filter(); |
||||||
|
if (sourceBillId != null && !sourceBillId.isEmpty()) { |
||||||
|
filter.add(new apelet.common.orm.impl.FilterItem("id", "=", sourceBillId)); |
||||||
|
} else if (sourceBillNumber != null && !sourceBillNumber.isEmpty()) { |
||||||
|
filter.add(new apelet.common.orm.impl.FilterItem("number", "=", sourceBillNumber)); |
||||||
|
} else { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
ObjectCollection sourceCollection = ormUtil.query("membership_apply", filter, null); |
||||||
|
if (sourceCollection == null || sourceCollection.isEmpty()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
ObjectValue sourceBill = sourceCollection.getObject(0); |
||||||
|
if (sourceBill == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// 将源单据的数据填充到当前表单(除了ID和状态字段)
|
||||||
|
Map<String, Object> values = sourceBill.getValues(); |
||||||
|
for (Map.Entry<String, Object> entry : values.entrySet()) { |
||||||
|
String key = entry.getKey(); |
||||||
|
Object value = entry.getValue(); |
||||||
|
|
||||||
|
// 跳过ID和状态字段,这些字段由系统处理
|
||||||
|
if ("id".equals(key) || "billstatus".equals(key) || |
||||||
|
"is_history".equals(key) || "version_number".equals(key) || |
||||||
|
"isHistory".equals(key) || "versionNumber".equals(key)) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
|
||||||
|
// 设置字段值到ObjectValue
|
||||||
|
if (value != null) { |
||||||
|
objectValue.put(key, value); |
||||||
|
} |
||||||
|
|
||||||
|
// 设置字段值到表单控件
|
||||||
|
try { |
||||||
|
this.setWidgetAttribute(key, AttributeEnum.VALUE_CHANGE, value); |
||||||
|
} catch (Exception e) { |
||||||
|
// 字段可能不存在,忽略异常
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// 保存源单据ID作为标识(用于后续业务逻辑)
|
||||||
|
objectValue.put(PARAM_BILL_ID, sourceBillId); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
e.printStackTrace(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,25 @@ |
|||||||
|
package apelet.association.plugin.member; |
||||||
|
|
||||||
|
import apelet.common.core.object.ObjectValue; |
||||||
|
import apelet.common.online.abstractplugin.ExecutePluginParent; |
||||||
|
import apelet.common.online.model.constant.AttributeEnum; |
||||||
|
|
||||||
|
/** |
||||||
|
* @ClassName: UnitNameChangeFormPlugin |
||||||
|
* @Author: huangdehua |
||||||
|
* @Date: 2026/4/30 10:40 |
||||||
|
* @Description: 入会申请与审核界面初始化 |
||||||
|
*/ |
||||||
|
public class UnitNameChangeFormPlugin extends ExecutePluginParent { |
||||||
|
|
||||||
|
/** |
||||||
|
* 界面初始化事件 |
||||||
|
* 将单据状态 billStatus 赋值为 "A" |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void formCreated(String str, ObjectValue objectValue) { |
||||||
|
super.formCreated(str, objectValue); |
||||||
|
//objectValue.setString("billStatus", "A");
|
||||||
|
//this.setWidgetAttribute("billstatus", AttributeEnum.VALUE_CHANGE, "A");
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,295 @@ |
|||||||
|
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.plugin.BeginOperationTransactionArgs; |
||||||
|
import apelet.common.online.plugin.OperationResult; |
||||||
|
import apelet.common.online.plugin.OperationServicePlugIn; |
||||||
|
import apelet.common.orm.impl.Filter; |
||||||
|
import apelet.common.orm.impl.FilterItem; |
||||||
|
|
||||||
|
import java.util.Iterator; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* @ClassName: UnitNameChangeOperationPlugin |
||||||
|
* @Author: huangdehua |
||||||
|
* @Date: 2026/4/30 11:02 |
||||||
|
* @Description: 入会申请与审核 变更单位名称 |
||||||
|
*/ |
||||||
|
public class UnitNameChangeOperationPlugin extends OperationServicePlugIn { |
||||||
|
|
||||||
|
// 主表与子表数据源变量名,需与在线表单配置保持一致。
|
||||||
|
private static final String TABLE_NAME = "membership_apply"; |
||||||
|
private static final String CHILD_TABLE_NAME = "membership_apply_entry"; |
||||||
|
private static final String FIELD_ID = "id"; |
||||||
|
private static final String FIELD_NUMBER = "number"; |
||||||
|
private static final String FIELD_UNIT_NAME = "unit_name"; |
||||||
|
private static final String FIELD_BILL_STATUS = "billstatus"; |
||||||
|
private static final String FIELD_IS_HISTORY = "is_history"; |
||||||
|
private static final String FIELD_VERSION_NUMBER = "version_number"; |
||||||
|
private static final String STATUS_ACTIVE = "A"; |
||||||
|
private static final String STATUS_CHANGED = "C"; |
||||||
|
private static final Integer IS_HISTORY_YES = 1; |
||||||
|
private static final Integer IS_HISTORY_NO = 0; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void beginOperationTransaction(BeginOperationTransactionArgs args) { |
||||||
|
try { |
||||||
|
ObjectValue model = args.getModel(); |
||||||
|
if (model == null) { |
||||||
|
setFailResult("获取表单数据失败"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
String pkId = model.getString(FIELD_ID); |
||||||
|
if (pkId == null || pkId.isEmpty()) { |
||||||
|
setFailResult("新增单据不允许执行变更操作"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
String newUnitName = model.getString(FIELD_UNIT_NAME); |
||||||
|
if (newUnitName == null || newUnitName.isEmpty()) { |
||||||
|
setFailResult("单位名称不能为空"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
OrmGenDataSourceUtil ormUtil = ormGenDataSourceUtil(); |
||||||
|
if (ormUtil == null) { |
||||||
|
setFailResult("获取数据库连接失败"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
Filter pkFilter = new Filter(); |
||||||
|
pkFilter.add(new FilterItem(FIELD_ID, "=", pkId)); |
||||||
|
ObjectCollection oldCollection = ormUtil.query(TABLE_NAME, pkFilter, null); |
||||||
|
if (oldCollection == null || oldCollection.isEmpty()) { |
||||||
|
setFailResult("未找到当前单据数据"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
ObjectValue oldBill = oldCollection.getObject(0); |
||||||
|
String oldUnitName = oldBill.getString(FIELD_UNIT_NAME); |
||||||
|
if (oldUnitName == null || oldUnitName.equals(newUnitName)) { |
||||||
|
setFailResult("单位名称未发生变化,无需变更"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
String billNumber = oldBill.getString(FIELD_NUMBER); |
||||||
|
if (billNumber == null || billNumber.isEmpty()) { |
||||||
|
setFailResult("单据编号不能为空"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// 通过单据编号 + 排除当前ID,查找同一业务单据之前变更产生的记录
|
||||||
|
ObjectValue previousChangedBill = findBillByNumberAndStatus(ormUtil, billNumber, pkId, STATUS_CHANGED); |
||||||
|
ObjectValue previousActiveBill = findBillByNumberAndStatus(ormUtil, billNumber, pkId, STATUS_ACTIVE); |
||||||
|
|
||||||
|
if (previousActiveBill != null) { |
||||||
|
// 二次变更:同一单据编号下已存在 A 记录(上次变更产生的),直接更新其 unit_name,无需新增
|
||||||
|
// 获取当前历史单据的最大版本号
|
||||||
|
int currentMaxVersion = getMaxVersionNumber(ormUtil, billNumber, pkId); |
||||||
|
if (previousChangedBill != null) { |
||||||
|
// 已有历史 C 记录,用当前旧单据数据覆盖它,并更新版本号
|
||||||
|
overwriteBill(ormUtil, previousChangedBill, oldBill, currentMaxVersion + 1); |
||||||
|
} else { |
||||||
|
// 无历史 C 记录,将当前旧单据标记为 C,并设置版本号
|
||||||
|
oldBill.put(FIELD_BILL_STATUS, STATUS_CHANGED); |
||||||
|
oldBill.put(FIELD_IS_HISTORY, IS_HISTORY_YES); |
||||||
|
oldBill.put(FIELD_VERSION_NUMBER, currentMaxVersion + 1); |
||||||
|
ormUtil.update(TABLE_NAME, oldBill, null); |
||||||
|
} |
||||||
|
// 直接更新 A 记录的 unit_name
|
||||||
|
previousActiveBill.put(FIELD_UNIT_NAME, newUnitName); |
||||||
|
ormUtil.update(TABLE_NAME, previousActiveBill, null); |
||||||
|
} else { |
||||||
|
// 首次变更:同一单据编号下没有 A 记录,走新增逻辑
|
||||||
|
oldBill.put(FIELD_BILL_STATUS, STATUS_CHANGED); |
||||||
|
oldBill.put(FIELD_IS_HISTORY, IS_HISTORY_YES); |
||||||
|
oldBill.put(FIELD_VERSION_NUMBER, 1); |
||||||
|
ormUtil.update(TABLE_NAME, oldBill, null); |
||||||
|
|
||||||
|
ObjectValue newBill = new ObjectValue(TABLE_NAME); |
||||||
|
copyValuesWithoutId(oldBill, newBill, FIELD_BILL_STATUS, FIELD_IS_HISTORY, FIELD_VERSION_NUMBER); |
||||||
|
newBill.put(FIELD_UNIT_NAME, newUnitName); |
||||||
|
newBill.put(FIELD_IS_HISTORY, IS_HISTORY_NO); |
||||||
|
newBill.put(FIELD_VERSION_NUMBER, 1); |
||||||
|
|
||||||
|
ObjectCollection copiedChildren = copyChildCollection(model.getValues().get(CHILD_TABLE_NAME)); |
||||||
|
if (copiedChildren != null && !copiedChildren.isEmpty()) { |
||||||
|
newBill.put(CHILD_TABLE_NAME, copiedChildren); |
||||||
|
} |
||||||
|
|
||||||
|
ormUtil.addNew(TABLE_NAME, newBill); |
||||||
|
updateNewBillStatus(ormUtil, pkId, newUnitName); |
||||||
|
} |
||||||
|
setSuccessResult(); |
||||||
|
} catch (Exception e) { |
||||||
|
e.printStackTrace(); |
||||||
|
setFailResult("单位名称变更处理失败:" + e.getMessage()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void copyValuesWithoutId(ObjectValue source, ObjectValue target, String... excludedFields) { |
||||||
|
Map<String, Object> values = source.getValues(); |
||||||
|
Iterator<String> it = values.keySet().iterator(); |
||||||
|
while (it.hasNext()) { |
||||||
|
String key = it.next(); |
||||||
|
if (FIELD_ID.equals(key) || isExcludedField(key, excludedFields)) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
// 排除 history 和 versionNumber 字段,由业务逻辑单独设置
|
||||||
|
if (FIELD_IS_HISTORY.equals(key) || FIELD_VERSION_NUMBER.equals(key)) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
target.put(key, values.get(key)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private boolean isExcludedField(String fieldName, String... excludedFields) { |
||||||
|
if (excludedFields == null) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
for (String excludedField : excludedFields) { |
||||||
|
if (fieldName.equals(excludedField)) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
private ObjectCollection copyChildCollection(Object childValue) { |
||||||
|
if (!(childValue instanceof ObjectCollection)) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
// 子表行只去掉主键,其他字段原样复制,避免丢失联系人等历史明细。
|
||||||
|
ObjectCollection oldChildren = (ObjectCollection) childValue; |
||||||
|
if (oldChildren.isEmpty()) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
ObjectCollection newChildren = new ObjectCollection(); |
||||||
|
for (int i = 0; i < oldChildren.size(); i++) { |
||||||
|
ObjectValue oldChild = oldChildren.getObject(i); |
||||||
|
if (oldChild == null) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
|
||||||
|
ObjectValue newChild = new ObjectValue(null); |
||||||
|
copyValuesWithoutId(oldChild, newChild); |
||||||
|
newChildren.addObject(newChild); |
||||||
|
} |
||||||
|
return newChildren; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 通过单据编号查找同一业务单据的变更记录。 |
||||||
|
* 查询条件:number = billNumber AND id != excludePkId AND billstatus = status |
||||||
|
* |
||||||
|
* @param ormUtil ORM 工具 |
||||||
|
* @param billNumber 单据编号(关联同一业务单据) |
||||||
|
* @param excludePkId 排除的单据主键(当前操作的记录) |
||||||
|
* @param status 单据状态 |
||||||
|
* @return 匹配的单据,无则返回 null |
||||||
|
*/ |
||||||
|
private ObjectValue findBillByNumberAndStatus(OrmGenDataSourceUtil ormUtil, String billNumber, String excludePkId, String status) throws Exception { |
||||||
|
Filter filter = new Filter(); |
||||||
|
filter.add(new FilterItem(FIELD_NUMBER, "=", billNumber)); |
||||||
|
filter.add(new FilterItem(FIELD_ID, "<>", excludePkId)); |
||||||
|
//filter.add(new FilterItem(FIELD_BILL_STATUS, "=", status));
|
||||||
|
ObjectCollection collection = ormUtil.query(TABLE_NAME, filter, null); |
||||||
|
if (collection == null || collection.isEmpty()) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return collection.getObject(0); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 用源单据数据覆盖目标单据(保留目标单据的 ID,其他字段用源数据替换)。 |
||||||
|
* |
||||||
|
* @param ormUtil ORM 工具 |
||||||
|
* @param targetBill 被覆盖的历史单据(保留其 ID) |
||||||
|
* @param sourceBill 用于覆盖的数据源 |
||||||
|
* @param versionNumber 版本号 |
||||||
|
*/ |
||||||
|
private void overwriteBill(OrmGenDataSourceUtil ormUtil, ObjectValue targetBill, ObjectValue sourceBill, int versionNumber) throws Exception { |
||||||
|
ObjectValue overwrittenBill = new ObjectValue(TABLE_NAME); |
||||||
|
overwrittenBill.put(FIELD_ID, targetBill.getString(FIELD_ID)); |
||||||
|
copyValuesWithoutId(sourceBill, overwrittenBill, FIELD_BILL_STATUS, FIELD_IS_HISTORY, FIELD_VERSION_NUMBER); |
||||||
|
overwrittenBill.put(FIELD_BILL_STATUS, STATUS_CHANGED); |
||||||
|
overwrittenBill.put(FIELD_IS_HISTORY, IS_HISTORY_YES); |
||||||
|
overwrittenBill.put(FIELD_VERSION_NUMBER, versionNumber); |
||||||
|
ormUtil.update(TABLE_NAME, overwrittenBill, null); |
||||||
|
} |
||||||
|
|
||||||
|
private void updateNewBillStatus(OrmGenDataSourceUtil ormUtil, String oldPkId, String newUnitName) throws Exception { |
||||||
|
Filter filter = new Filter(); |
||||||
|
filter.add(new FilterItem(FIELD_ID, "<>", oldPkId)); |
||||||
|
filter.add(new FilterItem(FIELD_UNIT_NAME, "=", newUnitName)); |
||||||
|
ObjectCollection collection = ormUtil.query(TABLE_NAME, filter, null); |
||||||
|
if (collection == null || collection.isEmpty()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
ObjectValue newBill = collection.getObject(0); |
||||||
|
if (newBill == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
newBill.put(FIELD_BILL_STATUS, STATUS_ACTIVE); |
||||||
|
newBill.put(FIELD_IS_HISTORY, IS_HISTORY_NO); |
||||||
|
newBill.put(FIELD_VERSION_NUMBER, 1); |
||||||
|
ormUtil.update(TABLE_NAME, newBill, null); |
||||||
|
} |
||||||
|
|
||||||
|
private void setSuccessResult() { |
||||||
|
OperationResult result = new OperationResult(); |
||||||
|
result.setSuccess(true); |
||||||
|
setOperationResult(result); |
||||||
|
} |
||||||
|
|
||||||
|
private void setFailResult(String message) { |
||||||
|
OperationResult result = new OperationResult(); |
||||||
|
result.setSuccess(false); |
||||||
|
result.setMessage(message); |
||||||
|
result.setShowMessage(true); |
||||||
|
setOperationResult(result); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取同一单据编号下的最大版本号(排除当前操作的记录)。 |
||||||
|
* |
||||||
|
* @param ormUtil ORM 工具 |
||||||
|
* @param billNumber 单据编号 |
||||||
|
* @param excludePkId 排除的单据主键 |
||||||
|
* @return 最大版本号,未找到则返回 0 |
||||||
|
*/ |
||||||
|
private int getMaxVersionNumber(OrmGenDataSourceUtil ormUtil, String billNumber, String excludePkId) throws Exception { |
||||||
|
Filter filter = new Filter(); |
||||||
|
filter.add(new FilterItem(FIELD_NUMBER, "=", billNumber)); |
||||||
|
filter.add(new FilterItem(FIELD_ID, "<>", excludePkId)); |
||||||
|
ObjectCollection collection = ormUtil.query(TABLE_NAME, filter, null); |
||||||
|
if (collection == null || collection.isEmpty()) { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
int maxVersion = 0; |
||||||
|
for (int i = 0; i < collection.size(); i++) { |
||||||
|
ObjectValue bill = collection.getObject(i); |
||||||
|
Object versionObj = bill.getValues().get(FIELD_VERSION_NUMBER); |
||||||
|
if (versionObj != null) { |
||||||
|
int version; |
||||||
|
if (versionObj instanceof Integer) { |
||||||
|
version = (Integer) versionObj; |
||||||
|
} else { |
||||||
|
version = Integer.parseInt(versionObj.toString()); |
||||||
|
} |
||||||
|
if (version > maxVersion) { |
||||||
|
maxVersion = version; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return maxVersion; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,95 @@ |
|||||||
|
package apelet.association.plugin.member; |
||||||
|
|
||||||
|
import apelet.common.core.object.ObjectValue; |
||||||
|
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: UnitNameChangePopupPlugin |
||||||
|
* @Author: huangdehua |
||||||
|
* @Date: 2026/5/9 |
||||||
|
* @Description: 入会申请与审核 - 变更单位名称弹窗插件 |
||||||
|
* 点击"变更"按钮时,弹出入会申请表单,并将列表中选中行数据带入弹窗中 |
||||||
|
*/ |
||||||
|
public class UnitNameChangePopupPlugin extends ExecutePluginParent { |
||||||
|
|
||||||
|
/** |
||||||
|
* 目标表单ID - membership_apply 表单在平台中的表单ID |
||||||
|
*/ |
||||||
|
private static final String TARGET_FORM_ID = "2048951917157027840"; |
||||||
|
|
||||||
|
/** |
||||||
|
* 触发按钮的标识 - 对应表单上按钮的 key/标识 |
||||||
|
*/ |
||||||
|
private static final String BUTTON_KEY = "变更"; |
||||||
|
|
||||||
|
/** |
||||||
|
* 列表页面中表格控件的变量名/key |
||||||
|
*/ |
||||||
|
private static final String TABLE_WIDGET_KEY = "table1777354992881"; |
||||||
|
|
||||||
|
/** |
||||||
|
* 传递到弹窗的参数key - 单据ID |
||||||
|
*/ |
||||||
|
private static final String PARAM_BILL_ID = "sourceBillId"; |
||||||
|
|
||||||
|
/** |
||||||
|
* 传递到弹窗的参数key - 单据编号 |
||||||
|
*/ |
||||||
|
private static final String PARAM_BILL_NUMBER = "sourceBillNumber"; |
||||||
|
|
||||||
|
/** |
||||||
|
* 按钮点击事件(列表按钮) |
||||||
|
* 点击"变更"按钮时,通过 getSelectData 获取列表中选中行的单据数据, |
||||||
|
* 以弹窗方式打开入会申请表单,并将选中行数据带入 |
||||||
|
* |
||||||
|
* @param buttonKey 按钮标识 |
||||||
|
* @param objectValue 列表按钮事件数据对象(非表单数据) |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void buttonTriggered(String buttonKey, ObjectValue objectValue) { |
||||||
|
// 仅响应"变更"按钮的点击事件
|
||||||
|
if (!BUTTON_KEY.equals(buttonKey)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// 【列表场景】通过框架提供的 getSelectData 方法获取选中/点击行的数据
|
||||||
|
// objectValue 中的 rowdata 包含列表所有行,getSelectData 会找到
|
||||||
|
// 标记了 isClick=true(点击行)或 isSelect=true(勾选行)的那一行
|
||||||
|
Map<String, Object> selectedRow = getSelectData(objectValue, TABLE_WIDGET_KEY); |
||||||
|
|
||||||
|
if (selectedRow == null) { |
||||||
|
showWarningMessage("请先在列表中选中一条单据"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// 从选中行中获取单据ID和编号
|
||||||
|
String billId = selectedRow.get("id") != null ? selectedRow.get("id").toString() : ""; |
||||||
|
String billNumber = selectedRow.get("number") != null ? selectedRow.get("number").toString() : ""; |
||||||
|
|
||||||
|
if (billId.isEmpty()) { |
||||||
|
showWarningMessage("选中的单据缺少ID信息,请重新选择"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// 调用 showForm 打开入会申请表单(新建空表单,不加载任何已有记录)
|
||||||
|
ShowParameter showParameter = new ShowParameter(); |
||||||
|
showParameter.setFormId(TARGET_FORM_ID); |
||||||
|
showParameter.setHowType(ShowTypeEnum.OPEN_ONLINE_MODAL); |
||||||
|
showParameter.setStatus(ViewStatus.EDIT); |
||||||
|
showParameter.setPkId(null); // 明确指定为空,表示新建表单而非打开已有单据
|
||||||
|
|
||||||
|
// 设置自定义参数,用于在目标表单中获取源单据数据
|
||||||
|
Map<String, Object> customParam = new HashMap<>(); |
||||||
|
customParam.put(PARAM_BILL_ID, billId); |
||||||
|
customParam.put(PARAM_BILL_NUMBER, billNumber); |
||||||
|
showParameter.setCustomParam(customParam); |
||||||
|
|
||||||
|
super.showForm(showParameter); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
package apelet.association.utils; |
||||||
|
|
||||||
|
import java.time.LocalDate; |
||||||
|
import java.time.format.DateTimeFormatter; |
||||||
|
|
||||||
|
public class CreatNumberUtils { |
||||||
|
public String creatNumber() { |
||||||
|
return LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
Loading…
Reference in new issue