|
|
|
@ -98,6 +98,7 @@ public class UnitNameChangeFormInitPlugin extends ExecutePluginParent { |
|
|
|
// 获取源单据ID
|
|
|
|
// 获取源单据ID
|
|
|
|
String sourceBillId = getSourceBillId(objectValue); |
|
|
|
String sourceBillId = getSourceBillId(objectValue); |
|
|
|
String sourceBillNumber = getSourceBillNumber(objectValue); |
|
|
|
String sourceBillNumber = getSourceBillNumber(objectValue); |
|
|
|
|
|
|
|
this.setWidgetAttribute("history",AttributeEnum.VALUE_CHANGE, "0"); |
|
|
|
|
|
|
|
|
|
|
|
// 如果没有源单据ID,说明不是变更操作,正常返回
|
|
|
|
// 如果没有源单据ID,说明不是变更操作,正常返回
|
|
|
|
if (sourceBillId == null || sourceBillId.isEmpty()) { |
|
|
|
if (sourceBillId == null || sourceBillId.isEmpty()) { |
|
|
|
@ -147,6 +148,10 @@ public class UnitNameChangeFormInitPlugin extends ExecutePluginParent { |
|
|
|
if (sourceBillId == null || sourceBillId.trim().isEmpty()) { |
|
|
|
if (sourceBillId == null || sourceBillId.trim().isEmpty()) { |
|
|
|
sourceBillId = objectValue.getString(PARAM_BILL_ID_ALT); |
|
|
|
sourceBillId = objectValue.getString(PARAM_BILL_ID_ALT); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Object idObj = objectValue.get("id"); |
|
|
|
|
|
|
|
if (idObj != null && !Integer.valueOf(0).equals(idObj)) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
return sourceBillId != null && !sourceBillId.trim().isEmpty(); |
|
|
|
return sourceBillId != null && !sourceBillId.trim().isEmpty(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -156,6 +161,8 @@ public class UnitNameChangeFormInitPlugin extends ExecutePluginParent { |
|
|
|
throw new RuntimeException("获取数据库连接失败"); |
|
|
|
throw new RuntimeException("获取数据库连接失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int version = markOldBillsHistory(ormUtil, objectValue); |
|
|
|
|
|
|
|
|
|
|
|
ObjectValue newBill = new ObjectValue("membership_apply"); |
|
|
|
ObjectValue newBill = new ObjectValue("membership_apply"); |
|
|
|
Map values = objectValue.getValues(); |
|
|
|
Map values = objectValue.getValues(); |
|
|
|
for (Object item : values.entrySet()) { |
|
|
|
for (Object item : values.entrySet()) { |
|
|
|
@ -166,6 +173,8 @@ public class UnitNameChangeFormInitPlugin extends ExecutePluginParent { |
|
|
|
} |
|
|
|
} |
|
|
|
newBill.put(getDbFieldKey(key), entry.getValue()); |
|
|
|
newBill.put(getDbFieldKey(key), entry.getValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
newBill.put("history", "0"); |
|
|
|
|
|
|
|
newBill.put("version_number", version); |
|
|
|
|
|
|
|
|
|
|
|
ObjectCollection detailEntry = copyEntryForManualSave(objectValue.getObjectCollection(CHILD_WIDGET_KEY)); |
|
|
|
ObjectCollection detailEntry = copyEntryForManualSave(objectValue.getObjectCollection(CHILD_WIDGET_KEY)); |
|
|
|
if (detailEntry != null && !detailEntry.isEmpty()) { |
|
|
|
if (detailEntry != null && !detailEntry.isEmpty()) { |
|
|
|
@ -175,6 +184,64 @@ public class UnitNameChangeFormInitPlugin extends ExecutePluginParent { |
|
|
|
ormUtil.addNew("membership_apply", newBill); |
|
|
|
ormUtil.addNew("membership_apply", newBill); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int markOldBillsHistory(OrmGenDataSourceUtil ormUtil, ObjectValue objectValue) throws Exception { |
|
|
|
|
|
|
|
String sourceBillId = getSourceBillId(objectValue); |
|
|
|
|
|
|
|
if (sourceBillId == null || sourceBillId.trim().isEmpty()) { |
|
|
|
|
|
|
|
sourceBillId = objectValue.getString(PARAM_BILL_ID); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (sourceBillId == null || sourceBillId.trim().isEmpty()) { |
|
|
|
|
|
|
|
sourceBillId = objectValue.getString(PARAM_BILL_ID_ALT); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (sourceBillId == null || sourceBillId.trim().isEmpty()) { |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
apelet.common.orm.impl.Filter sourceFilter = new apelet.common.orm.impl.Filter(); |
|
|
|
|
|
|
|
sourceFilter.add(new apelet.common.orm.impl.FilterItem("id", "=", sourceBillId)); |
|
|
|
|
|
|
|
ObjectCollection sourceCollection = ormUtil.query("membership_apply", sourceFilter, null); |
|
|
|
|
|
|
|
if (sourceCollection == null || sourceCollection.isEmpty()) { |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ObjectValue sourceBill = sourceCollection.getObject(0); |
|
|
|
|
|
|
|
if (sourceBill == null) { |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String number = sourceBill.getString("number"); |
|
|
|
|
|
|
|
if (number == null || number.trim().isEmpty()) { |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
apelet.common.orm.impl.Filter sameNumberFilter = new apelet.common.orm.impl.Filter(); |
|
|
|
|
|
|
|
sameNumberFilter.add(new apelet.common.orm.impl.FilterItem("number", "=", number)); |
|
|
|
|
|
|
|
ObjectCollection sameBills = ormUtil.query("membership_apply", sameNumberFilter, null); |
|
|
|
|
|
|
|
if (sameBills == null || sameBills.isEmpty()) { |
|
|
|
|
|
|
|
sourceBill.put("history", "1"); |
|
|
|
|
|
|
|
sourceBill.put("version_number", 1); |
|
|
|
|
|
|
|
ormUtil.update("membership_apply", sourceBill, null); |
|
|
|
|
|
|
|
return 2; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ObjectValue> bills = new java.util.ArrayList<>(); |
|
|
|
|
|
|
|
for (int i = 0; i < sameBills.size(); i++) { |
|
|
|
|
|
|
|
ObjectValue bill = sameBills.getObject(i); |
|
|
|
|
|
|
|
if (bill != null) { |
|
|
|
|
|
|
|
bills.add(bill); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bills.sort(java.util.Comparator.comparingInt(this::getVersionNumberSafe)); |
|
|
|
|
|
|
|
int version = 1; |
|
|
|
|
|
|
|
for (ObjectValue bill : bills) { |
|
|
|
|
|
|
|
bill.put("history", "1"); |
|
|
|
|
|
|
|
bill.put("version_number", version); |
|
|
|
|
|
|
|
ormUtil.update("membership_apply", bill, null); |
|
|
|
|
|
|
|
version++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return version; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean shouldSkipManualSaveField(String key) { |
|
|
|
private boolean shouldSkipManualSaveField(String key) { |
|
|
|
return "id".equals(key) |
|
|
|
return "id".equals(key) |
|
|
|
|| "eventparams".equals(key) |
|
|
|
|| "eventparams".equals(key) |
|
|
|
@ -391,20 +458,12 @@ public class UnitNameChangeFormInitPlugin extends ExecutePluginParent { |
|
|
|
|
|
|
|
|
|
|
|
int version = 1; |
|
|
|
int version = 1; |
|
|
|
if (sameBills != null && !sameBills.isEmpty()) { |
|
|
|
if (sameBills != null && !sameBills.isEmpty()) { |
|
|
|
List<ObjectValue> bills = new java.util.ArrayList<>(); |
|
|
|
|
|
|
|
for (int i = 0; i < sameBills.size(); i++) { |
|
|
|
for (int i = 0; i < sameBills.size(); i++) { |
|
|
|
ObjectValue bill = sameBills.getObject(i); |
|
|
|
ObjectValue bill = sameBills.getObject(i); |
|
|
|
if (bill != null) { |
|
|
|
int billVersion = getVersionNumberSafe(bill); |
|
|
|
bills.add(bill); |
|
|
|
if (billVersion >= version) { |
|
|
|
} |
|
|
|
version = billVersion + 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bills.sort(java.util.Comparator.comparingInt(this::getVersionNumberSafe)); |
|
|
|
|
|
|
|
for (ObjectValue bill : bills) { |
|
|
|
|
|
|
|
bill.put("is_history", 1); |
|
|
|
|
|
|
|
bill.put("version_number", version); |
|
|
|
|
|
|
|
ormUtil.update("membership_apply", bill, null); |
|
|
|
|
|
|
|
version++; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|