bug修复
This commit is contained in:
parent
5bc5287ee7
commit
2141e30794
|
@ -1,5 +1,7 @@
|
||||||
package zcgj.zcdev.zcdev.pr.task;
|
package zcgj.zcdev.zcdev.pr.task;
|
||||||
|
|
||||||
|
import kd.bos.algo.DataSet;
|
||||||
|
import kd.bos.algo.Row;
|
||||||
import kd.bos.context.RequestContext;
|
import kd.bos.context.RequestContext;
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
|
@ -12,6 +14,7 @@ import kd.bos.orm.query.QCP;
|
||||||
import kd.bos.orm.query.QFilter;
|
import kd.bos.orm.query.QFilter;
|
||||||
import kd.bos.schedule.executor.AbstractTask;
|
import kd.bos.schedule.executor.AbstractTask;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import kd.bos.servicehelper.QueryServiceHelper;
|
||||||
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||||
import zcgj.zcdev.zcdev.pr.plugin.form.AdjustAmountOftaxBillPlugin;
|
import zcgj.zcdev.zcdev.pr.plugin.form.AdjustAmountOftaxBillPlugin;
|
||||||
|
@ -29,6 +32,7 @@ import java.util.*;
|
||||||
*/
|
*/
|
||||||
public class EquipmentCardTaskPlugin extends AbstractTask {
|
public class EquipmentCardTaskPlugin extends AbstractTask {
|
||||||
private static final Log log = LogFactory.getLog(EquipmentCardTaskPlugin.class);
|
private static final Log log = LogFactory.getLog(EquipmentCardTaskPlugin.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {//同步资产卡片
|
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {//同步资产卡片
|
||||||
List<String> strings = new ArrayList<>();
|
List<String> strings = new ArrayList<>();
|
||||||
|
@ -123,54 +127,55 @@ public class EquipmentCardTaskPlugin extends AbstractTask {
|
||||||
String zcgjDebillno = entry.getString("zcgj_debillno");
|
String zcgjDebillno = entry.getString("zcgj_debillno");
|
||||||
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});
|
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);
|
||||||
// 获取期间对象
|
// Arrays.sort(depresplitdetails, (o1, o2) -> {
|
||||||
DynamicObject p1 = o1.getDynamicObject("period");
|
// // 获取期间对象
|
||||||
DynamicObject p2 = o2.getDynamicObject("period");
|
// DynamicObject p1 = o1.getDynamicObject("period");
|
||||||
|
// DynamicObject p2 = o2.getDynamicObject("period");
|
||||||
// === 修复1:正确的空值处理 ===
|
//
|
||||||
// 将空值放在最后(无论升降序)
|
// // === 修复1:正确的空值处理 ===
|
||||||
if (p1 == null && p2 == null) return 0;
|
// // 将空值放在最后(无论升降序)
|
||||||
if (p1 == null) return 1; // o1空则排在后面
|
// if (p1 == null && p2 == null) return 0;
|
||||||
if (p2 == null) return -1; // o2空则排在后面
|
// if (p1 == null) return 1; // o1空则排在后面
|
||||||
|
// if (p2 == null) return -1; // o2空则排在后面
|
||||||
String code1 = p1.getString("number");
|
//
|
||||||
String code2 = p2.getString("number");
|
// String code1 = p1.getString("number");
|
||||||
|
// String code2 = p2.getString("number");
|
||||||
// 处理空字符串
|
//
|
||||||
if (code1 == null) code1 = "";
|
// // 处理空字符串
|
||||||
if (code2 == null) code2 = "";
|
// if (code1 == null) code1 = "";
|
||||||
|
// if (code2 == null) code2 = "";
|
||||||
// === 修复2:自动检测日期格式 ===
|
//
|
||||||
DateTimeFormatter formatter = detectFormat(code1, code2);
|
// // === 修复2:自动检测日期格式 ===
|
||||||
|
// DateTimeFormatter formatter = detectFormat(code1, code2);
|
||||||
try {
|
//
|
||||||
YearMonth ym1 = parseYearMonth(code1, formatter);
|
// try {
|
||||||
YearMonth ym2 = parseYearMonth(code2, formatter);
|
// YearMonth ym1 = parseYearMonth(code1, formatter);
|
||||||
|
// YearMonth ym2 = parseYearMonth(code2, formatter);
|
||||||
// === 修复3:正确的降序比较 ===
|
//
|
||||||
return ym2.compareTo(ym1); // 注意:这是ym2在前
|
// // === 修复3:正确的降序比较 ===
|
||||||
|
// return ym2.compareTo(ym1); // 注意:这是ym2在前
|
||||||
} catch (DateTimeParseException e) {
|
//
|
||||||
// === 修复4:数值化比较作为备选 ===
|
// } catch (DateTimeParseException e) {
|
||||||
try {
|
// // === 修复4:数值化比较作为备选 ===
|
||||||
int num1 = Integer.parseInt(code1.replaceAll("\\D", ""));
|
// try {
|
||||||
int num2 = Integer.parseInt(code2.replaceAll("\\D", ""));
|
// int num1 = Integer.parseInt(code1.replaceAll("\\D", ""));
|
||||||
return Integer.compare(num2, num1); // 降序数值比较
|
// int num2 = Integer.parseInt(code2.replaceAll("\\D", ""));
|
||||||
} catch (NumberFormatException ex) {
|
// return Integer.compare(num2, num1); // 降序数值比较
|
||||||
// 最终回退到字符串降序
|
// } catch (NumberFormatException ex) {
|
||||||
return code2.compareTo(code1);
|
// // 最终回退到字符串降序
|
||||||
}
|
// return code2.compareTo(code1);
|
||||||
}
|
// }
|
||||||
});
|
// }
|
||||||
for (DynamicObject depresplitdetail : depresplitdetails) {
|
// });
|
||||||
|
for (Row depresplitdetail : rows) {
|
||||||
String billno = depresplitdetail.getString("billno");
|
String billno = depresplitdetail.getString("billno");
|
||||||
DynamicObject period = depresplitdetail.getDynamicObject("period");//折旧区间
|
DynamicObject depresplitdetailInfo = BusinessDataServiceHelper.loadSingle("fa_depresplitdetail", new QFilter[]{new QFilter("billno", QCP.equals, billno)});
|
||||||
DynamicObject splitdept = depresplitdetail.getDynamicObject("splitdept");//使用部门
|
DynamicObject period = depresplitdetailInfo.getDynamicObject("period");//折旧区间
|
||||||
DynamicObjectCollection assentry = depresplitdetail.getDynamicObjectCollection("assentry");
|
DynamicObject splitdept = depresplitdetailInfo.getDynamicObject("splitdept");//使用部门
|
||||||
|
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();
|
||||||
|
@ -223,7 +228,6 @@ public class EquipmentCardTaskPlugin extends AbstractTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 自动检测日期格式的辅助方法
|
// 自动检测日期格式的辅助方法
|
||||||
private DateTimeFormatter detectFormat(String code1, String code2) {
|
private DateTimeFormatter detectFormat(String code1, String code2) {
|
||||||
// 常见格式检测
|
// 常见格式检测
|
||||||
|
@ -239,7 +243,8 @@ public class EquipmentCardTaskPlugin extends AbstractTask {
|
||||||
if (!code1.isEmpty()) YearMonth.parse(code1, fmt);
|
if (!code1.isEmpty()) YearMonth.parse(code1, fmt);
|
||||||
if (!code2.isEmpty()) YearMonth.parse(code2, fmt);
|
if (!code2.isEmpty()) YearMonth.parse(code2, fmt);
|
||||||
return fmt; // 找到匹配格式
|
return fmt; // 找到匹配格式
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 默认返回标准格式
|
// 默认返回标准格式
|
||||||
|
|
Loading…
Reference in New Issue