Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

获取 Ones 同组数据 #17

Open
qwqcode opened this issue Feb 20, 2021 · 0 comments
Open

获取 Ones 同组数据 #17

qwqcode opened this issue Feb 20, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@qwqcode
Copy link
Owner

qwqcode commented Feb 20, 2021

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);
@qwqcode qwqcode added the enhancement New feature or request label Feb 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant