bug修复
This commit is contained in:
parent
2141e30794
commit
811b2ce1e8
|
@ -128,54 +128,50 @@ public class EquipmentCardTaskPlugin extends AbstractTask {
|
|||
entrys.removeIf(record -> isLastMonth(zcgjDebillno));//若属于上个月那就删除重新塞入
|
||||
}
|
||||
}
|
||||
DynamicObject[] depresplitdetails = BusinessDataServiceHelper.load("fa_depresplitdetail", "billno,period,splitdept,assentry.costcentrer,assentry.splitamount", new QFilter[]{qf});
|
||||
DataSet rows = QueryServiceHelper.queryDataSet(this.getClass().getName(), "fa_depresplitdetail", "billno,period,period.number,splitdept,assentry.costcentrer,assentry.splitamount", qFilter.toArray(), "period.number DESC", 1);
|
||||
// Arrays.sort(depresplitdetails, (o1, o2) -> {
|
||||
// // 获取期间对象
|
||||
// DynamicObject p1 = o1.getDynamicObject("period");
|
||||
// DynamicObject p2 = o2.getDynamicObject("period");
|
||||
//
|
||||
// // === 修复1:正确的空值处理 ===
|
||||
// // 将空值放在最后(无论升降序)
|
||||
// if (p1 == null && p2 == null) return 0;
|
||||
// if (p1 == null) return 1; // o1空则排在后面
|
||||
// if (p2 == null) return -1; // o2空则排在后面
|
||||
//
|
||||
// String code1 = p1.getString("number");
|
||||
// String code2 = p2.getString("number");
|
||||
//
|
||||
// // 处理空字符串
|
||||
// if (code1 == null) code1 = "";
|
||||
// if (code2 == null) code2 = "";
|
||||
//
|
||||
// // === 修复2:自动检测日期格式 ===
|
||||
// DateTimeFormatter formatter = detectFormat(code1, code2);
|
||||
//
|
||||
// try {
|
||||
// YearMonth ym1 = parseYearMonth(code1, formatter);
|
||||
// YearMonth ym2 = parseYearMonth(code2, formatter);
|
||||
//
|
||||
// // === 修复3:正确的降序比较 ===
|
||||
// return ym2.compareTo(ym1); // 注意:这是ym2在前
|
||||
//
|
||||
// } catch (DateTimeParseException e) {
|
||||
// // === 修复4:数值化比较作为备选 ===
|
||||
// try {
|
||||
// int num1 = Integer.parseInt(code1.replaceAll("\\D", ""));
|
||||
// int num2 = Integer.parseInt(code2.replaceAll("\\D", ""));
|
||||
// return Integer.compare(num2, num1); // 降序数值比较
|
||||
// } catch (NumberFormatException ex) {
|
||||
// // 最终回退到字符串降序
|
||||
// return code2.compareTo(code1);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
for (Row depresplitdetail : rows) {
|
||||
DynamicObjectCollection depresplitdetails = QueryServiceHelper.query("fa_depresplitdetail", "billno,period,splitdept,assentry.costcentrer,assentry.splitamount", new QFilter[]{qf});
|
||||
// DynamicObject[] depresplitdetails = BusinessDataServiceHelper.load("fa_depresplitdetail", "billno,period,splitdept,assentry.costcentrer,assentry.splitamount", new QFilter[]{qf});
|
||||
// DataSet rows = QueryServiceHelper.queryDataSet(this.getClass().getName(), "fa_depresplitdetail", "billno,period,period.number,splitdept,assentry.costcentrer,assentry.splitamount", qFilter.toArray(), "period.number DESC", 1);
|
||||
// 增强版比较器(自动适配多种日期格式)
|
||||
Comparator<DynamicObject> smartComparator = (o1, o2) -> {
|
||||
DynamicObject p1 = o1.getDynamicObject("period");
|
||||
DynamicObject p2 = o2.getDynamicObject("period");
|
||||
|
||||
// 空值处理
|
||||
if (p1 == null && p2 == null) return 0;
|
||||
if (p1 == null) return 1;
|
||||
if (p2 == null) return -1;
|
||||
|
||||
String c1 = p1.getString("number");
|
||||
String c2 = p2.getString("number");
|
||||
if (c1 == null) c1 = "";
|
||||
if (c2 == null) c2 = "";
|
||||
|
||||
// 尝试解析为年月
|
||||
for (String pattern : new String[]{"yyyyMM", "yyyy-MM", "yyyy/MM"}) {
|
||||
try {
|
||||
DateTimeFormatter fmt = DateTimeFormatter.ofPattern(pattern);
|
||||
YearMonth ym1 = YearMonth.parse(c1, fmt);
|
||||
YearMonth ym2 = YearMonth.parse(c2, fmt);
|
||||
return ym2.compareTo(ym1); // 降序
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
// 纯数字比较(如 "202301")
|
||||
try {
|
||||
int num1 = Integer.parseInt(c1);
|
||||
int num2 = Integer.parseInt(c2);
|
||||
return Integer.compare(num2, num1);
|
||||
} catch (NumberFormatException e) {
|
||||
return c2.compareTo(c1); // 字符串降序
|
||||
}
|
||||
};
|
||||
depresplitdetails.sort(smartComparator);
|
||||
|
||||
for (DynamicObject depresplitdetail : depresplitdetails) {
|
||||
String billno = depresplitdetail.getString("billno");
|
||||
DynamicObject depresplitdetailInfo = BusinessDataServiceHelper.loadSingle("fa_depresplitdetail", new QFilter[]{new QFilter("billno", QCP.equals, billno)});
|
||||
DynamicObject period = depresplitdetailInfo.getDynamicObject("period");//折旧区间
|
||||
DynamicObject splitdept = depresplitdetailInfo.getDynamicObject("splitdept");//使用部门
|
||||
DynamicObjectCollection assentry = depresplitdetailInfo.getDynamicObjectCollection("assentry");
|
||||
DynamicObject period = depresplitdetail.getDynamicObject("period");//折旧区间
|
||||
DynamicObject splitdept = depresplitdetail.getDynamicObject("splitdept");//使用部门
|
||||
DynamicObjectCollection assentry = depresplitdetail.getDynamicObjectCollection("assentry");
|
||||
DynamicObject costcentrer = assentry.get(0).getDynamicObject("costcentrer");//成本中心
|
||||
BigDecimal splitamount = assentry.get(0).getBigDecimal("splitamount");//分摊金额
|
||||
DynamicObject addNew = entrys.addNew();
|
||||
|
|
Loading…
Reference in New Issue