youhua
This commit is contained in:
parent
632ef9bef7
commit
47437dd7e1
|
@ -147,60 +147,16 @@ public class EquipmentCardTaskPlugin extends AbstractTask {
|
|||
if (eceq_equipment != null) {
|
||||
DynamicObjectCollection entrys = eceq_equipment.getDynamicObjectCollection("zcgj_entryentity");
|
||||
QFilter qf = new QFilter("realcard.number", QCP.equals, number);
|
||||
if (entrys.size() > 0) {//若分录行数大于0 则取上月的
|
||||
for (int i = 0; i < entrys.size(); i++) {
|
||||
DynamicObject entry = entrys.get(i);
|
||||
long billnoid = entry.getLong("zcgj_debillno");
|
||||
qf.and(new QFilter("id", QCP.not_equals, billnoid));
|
||||
// entrys.removeIf(record -> isLastMonth(zcgjDebillno));//若属于上个月那就删除重新塞入
|
||||
}
|
||||
}
|
||||
// if (entrys.size() > 0) {//若分录行数大于0 则取上月的
|
||||
// for (int i = 0; i < entrys.size(); i++) {
|
||||
// DynamicObject entry = entrys.get(i);
|
||||
// long billnoid = entry.getLong("zcgj_debillno");
|
||||
// qf.and(new QFilter("id", QCP.not_equals, billnoid));
|
||||
//// entrys.removeIf(record -> isLastMonth(zcgjDebillno));//若属于上个月那就删除重新塞入
|
||||
// }
|
||||
// }
|
||||
DynamicObjectCollection depresplitdetails = QueryServiceHelper.query("fa_depresplitdetail", "id,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", "id,billno,period,splitdept,assentry,assentry.costcentrer,assentry.splitamount",
|
||||
// new QFilter[]{new QFilter("realcard.number", QCP.equals, number)}, "period.number DESC");
|
||||
// DynamicObjectCollection depresplitdetails = ORM.create().toPlainDynamicObjectCollection(rows.copy());
|
||||
// // 增强版比较器(自动适配多种日期格式)
|
||||
// for (int i = 0; i < depresplitdetails.size(); i++) {
|
||||
// DynamicObject item = depresplitdetails.get(i);
|
||||
//// log.info("排序前 " + i + ": " + item.getDynamicObject("period").getString("number"));
|
||||
// }
|
||||
// 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 (int i = 0; i < depresplitdetails.size(); i++) {
|
||||
// DynamicObject item = depresplitdetails.get(i);
|
||||
// log.info("排序前 " + i + ": " + item.getDynamicObject("period").getString("number"));
|
||||
// }
|
||||
//按字段 menuindex 排序
|
||||
log.info("前depresplitdetails:"+depresplitdetails.toArray().toString() + "长度:"+depresplitdetails.size());
|
||||
Collections.sort(depresplitdetails , new Comparator<DynamicObject>(){
|
||||
@Override
|
||||
public int compare(DynamicObject o1, DynamicObject o2) {
|
||||
|
@ -211,7 +167,10 @@ public class EquipmentCardTaskPlugin extends AbstractTask {
|
|||
return oo2.getDynamicObject("period").getString("number").compareTo(oo1.getDynamicObject("period").getString("number"));
|
||||
}
|
||||
});
|
||||
for (DynamicObject depresplitdetail : depresplitdetails) {
|
||||
log.info("后depresplitdetails:"+depresplitdetails.toArray().toString() + "长度:"+depresplitdetails.size());
|
||||
entrys.clear();
|
||||
for (int x = 0 ; x<depresplitdetails.size() ; x++) {
|
||||
DynamicObject depresplitdetail = depresplitdetails.get(x);
|
||||
long id = depresplitdetail.getLong("id");
|
||||
DynamicObject loadSingle = BusinessDataServiceHelper.loadSingle("fa_depresplitdetail", new QFilter[]{new QFilter("id", QCP.equals, id)});
|
||||
// String billnoid = loadSingle.getString("billno");
|
||||
|
@ -220,7 +179,7 @@ public class EquipmentCardTaskPlugin extends AbstractTask {
|
|||
DynamicObjectCollection assentry = loadSingle.getDynamicObjectCollection("assentry");
|
||||
DynamicObject costcentrer = assentry.get(0).getDynamicObject("costcentrer");//成本中心
|
||||
BigDecimal splitamount = assentry.get(0).getBigDecimal("splitamount");//分摊金额
|
||||
DynamicObject addNew = entrys.addNew();
|
||||
DynamicObject addNew = new DynamicObject(assentry.getDynamicObjectType());
|
||||
addNew.set("zcgj_debillno", id);
|
||||
addNew.set("zcgj_assperiod", period);
|
||||
addNew.set("zcgj_headusedept", splitdept);
|
||||
|
@ -228,6 +187,7 @@ public class EquipmentCardTaskPlugin extends AbstractTask {
|
|||
addNew.set("zcgj_entryname", assetname);
|
||||
addNew.set("zcgj_costcenter", costcentrer);
|
||||
addNew.set("zcgj_shareamount", splitamount);
|
||||
entrys.add(addNew);
|
||||
}
|
||||
SaveServiceHelper.save(new DynamicObject[]{eceq_equipment});
|
||||
}
|
||||
|
@ -312,3 +272,48 @@ public class EquipmentCardTaskPlugin extends AbstractTask {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
// 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", "id,billno,period,splitdept,assentry,assentry.costcentrer,assentry.splitamount",
|
||||
// new QFilter[]{new QFilter("realcard.number", QCP.equals, number)}, "period.number DESC");
|
||||
// DynamicObjectCollection depresplitdetails = ORM.create().toPlainDynamicObjectCollection(rows.copy());
|
||||
// // 增强版比较器(自动适配多种日期格式)
|
||||
// for (int i = 0; i < depresplitdetails.size(); i++) {
|
||||
// DynamicObject item = depresplitdetails.get(i);
|
||||
//// log.info("排序前 " + i + ": " + item.getDynamicObject("period").getString("number"));
|
||||
// }
|
||||
// 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 (int i = 0; i < depresplitdetails.size(); i++) {
|
||||
// DynamicObject item = depresplitdetails.get(i);
|
||||
// log.info("排序前 " + i + ": " + item.getDynamicObject("period").getString("number"));
|
||||
// }
|
||||
//按字段 menuindex 排序
|
Loading…
Reference in New Issue