获取 Ones 同组数据
qwqcode opened this issue · comments
qwqcode commented
function GetSameGrpOnes(planList) {
rec = {};
planList.forEach((plan) => {
plan.grpList.forEach((grp) => {
grp.asgnList.forEach((one) => {
if (!rec[one.oneName])
rec[one.oneName] = {
ones: [],
date: {},
};
rOnes = rec[one.oneName].ones;
rDate = rec[one.oneName].date;
grp.asgnList
.map((o) => o.oneName)
.filter((o) => o != one.oneName)
.forEach((name) => {
if (!rOnes.includes(name)) {
rOnes.push(name);
}
grpName = grp.name;
planDate = plan.actionTime;
planDateStr = new Date(planDate).toISOString().slice(0, 10);
if (!rDate[name])
rDate[name] = {
sameTimes: 0,
begin: planDate,
end: planDate,
grps: [],
beginStr: planDateStr,
endStr: planDateStr,
dates: [],
};
ro = rDate[name];
if (planDate < ro.begin) {
ro.begin = planDate;
ro.beginStr = planDateStr;
}
if (planDate > ro.end) {
ro.end = planDate;
ro.endStr = planDateStr;
}
if (!ro.grps.includes(grpName)) {
ro.grps.push(grpName);
ro.sameTimes++;
}
if (!ro.dates.includes(planDate)) {
ro.dates.push(planDateStr);
}
});
});
});
});
return rec;
}
// 获取 Ones 同组数据
GetSameGrpOnes(p);
function GetEarliestPlanDate(p) {
t = p[0].actionTime;
p.forEach((a) => {
if (a.actionTime < t) {
t = a.actionTime;
}
});
return new Date(t).toISOString();
}
// 获取最早的 Plan 时间
GetEarliestPlanDate(p);