Browse Source

Merge branch 'dev_feature_入会申请变更' into dev

dev
huangdehua 2 weeks ago
parent
commit
5cf2ac8dec
  1. 105
      common/common-association/src/main/java/apelet/association/plugin/member/UnitNameChangeFormInitPlugin.java
  2. 30
      common/common-association/src/main/java/apelet/association/plugin/member/UnitNameChangeOperationPlugin.java

105
common/common-association/src/main/java/apelet/association/plugin/member/UnitNameChangeFormInitPlugin.java

@ -117,6 +117,110 @@ public class UnitNameChangeFormInitPlugin extends ExecutePluginParent { @@ -117,6 +117,110 @@ public class UnitNameChangeFormInitPlugin extends ExecutePluginParent {
this.setWidgetAttribute("table-btn primary", AttributeEnum.SHOW, false);
}
@Override
public void buttonTriggered(String widgetVariableName, ObjectValue objectValue) {
super.buttonTriggered(widgetVariableName, objectValue);
if (!"保存".equals(widgetVariableName)) {
return;
}
if (!isChangeBill(objectValue)) {
return;
}
try {
saveChangeBillManually(objectValue);
this.cancelOperate();
this.showMessage("保存成功");
} catch (Exception e) {
this.cancelOperate();
this.showErrorMessage("保存失败:" + e.getMessage());
}
}
private boolean isChangeBill(ObjectValue objectValue) {
if (objectValue == null) {
return false;
}
String sourceBillId = getSourceBillId(objectValue);
if (sourceBillId == null || sourceBillId.trim().isEmpty()) {
sourceBillId = objectValue.getString(PARAM_BILL_ID_ALT);
}
return sourceBillId != null && !sourceBillId.trim().isEmpty();
}
private void saveChangeBillManually(ObjectValue objectValue) throws Exception {
OrmGenDataSourceUtil ormUtil = (OrmGenDataSourceUtil) ormGenDataSourceUtil();
if (ormUtil == null) {
throw new RuntimeException("获取数据库连接失败");
}
ObjectValue newBill = new ObjectValue("membership_apply");
Map values = objectValue.getValues();
for (Object item : values.entrySet()) {
Map.Entry entry = (Map.Entry) item;
String key = entry.getKey().toString();
if (shouldSkipManualSaveField(key)) {
continue;
}
newBill.put(getDbFieldKey(key), entry.getValue());
}
ObjectCollection detailEntry = copyEntryForManualSave(objectValue.getObjectCollection(CHILD_WIDGET_KEY));
if (detailEntry != null && !detailEntry.isEmpty()) {
newBill.put(CHILD_TABLE_NAME, detailEntry);
}
ormUtil.addNew("membership_apply", newBill);
}
private boolean shouldSkipManualSaveField(String key) {
return "id".equals(key)
|| "eventparams".equals(key)
|| PARAM_BILL_ID.equals(key)
|| PARAM_BILL_ID_ALT.equals(key)
|| PARAM_BILL_NUMBER.equals(key)
|| CHILD_TABLE_NAME.equals(key)
|| CHILD_WIDGET_KEY.equals(key);
}
private String getDbFieldKey(String widgetKey) {
for (Map.Entry<String, String> entry : FIELD_WIDGET_MAPPING.entrySet()) {
if (entry.getValue().equals(widgetKey)) {
return entry.getKey();
}
}
return widgetKey;
}
private ObjectCollection copyEntryForManualSave(ObjectCollection sourceEntry) {
if (sourceEntry == null || sourceEntry.isEmpty()) {
return null;
}
ObjectCollection targetEntry = new ObjectCollection();
for (int i = 0; i < sourceEntry.size(); i++) {
ObjectValue sourceRow = sourceEntry.getObject(i);
if (sourceRow == null) {
continue;
}
ObjectValue targetRow = new ObjectValue(CHILD_TABLE_NAME);
Map rowValues = sourceRow.getValues();
for (Object item : rowValues.entrySet()) {
Map.Entry entry = (Map.Entry) item;
String key = entry.getKey().toString();
if ("id".equals(key) || CHILD_PARENT_FIELD.equals(key)) {
continue;
}
targetRow.put(key, entry.getValue());
}
targetEntry.addObject(targetRow);
}
return targetEntry;
}
/**
* 从ObjectValue中获取源单据ID
* eventparams 中获取
@ -246,6 +350,7 @@ public class UnitNameChangeFormInitPlugin extends ExecutePluginParent { @@ -246,6 +350,7 @@ public class UnitNameChangeFormInitPlugin extends ExecutePluginParent {
// 设置字段值到表单控件
try {
this.setWidgetAttribute("id",AttributeEnum.VALUE_CHANGE,null);
this.setWidgetAttribute(widgetKey, AttributeEnum.VALUE_CHANGE, value);
} catch (Exception e) {
// 字段可能不存在,忽略异常

30
common/common-association/src/main/java/apelet/association/plugin/member/UnitNameChangeOperationPlugin.java

@ -1,30 +0,0 @@ @@ -1,30 +0,0 @@
package apelet.association.plugin.member;
import apelet.common.core.object.ObjectValue;
import apelet.common.online.plugin.BeginOperationTransactionArgs;
import apelet.common.online.plugin.OperationResult;
import apelet.common.online.plugin.OperationServicePlugIn;
/**
* 单位名称变更单操作插件
*/
public class UnitNameChangeOperationPlugin extends OperationServicePlugIn {
private static final String FIELD_NUMBER = "number";
@Override
public void beginOperationTransaction(BeginOperationTransactionArgs args) {
ObjectValue model = args.getModel();
keepExistingBillNumber(model);
}
private void keepExistingBillNumber(ObjectValue model) {
if (model == null) {
return;
}
String number = model.getString(FIELD_NUMBER);
if (number != null && !number.trim().isEmpty()) {
model.put(FIELD_NUMBER, number);
}
}
}
Loading…
Cancel
Save