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