{"id":1809,"date":"2024-11-10T13:43:51","date_gmt":"2024-11-10T05:43:51","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1809\/"},"modified":"2024-11-10T13:43:51","modified_gmt":"2024-11-10T05:43:51","slug":"%e5%a6%82%e4%bd%95%e5%88%a4%e6%96%ad%e6%95%b0%e7%bb%84%e5%af%b9%e8%b1%a1%e4%b8%ad%e7%9a%84%e9%87%8d%e5%a4%8d%e6%95%b0%e6%8d%ae%e5%b9%b6%e7%bb%9f%e8%ae%a1%e9%87%8d%e5%a4%8d%e6%ac%a1%e6%95%b0%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1809\/","title":{"rendered":"\u5982\u4f55\u5224\u65ad\u6570\u7ec4\u5bf9\u8c61\u4e2d\u7684\u91cd\u590d\u6570\u636e\u5e76\u7edf\u8ba1\u91cd\u590d\u6b21\u6570\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173059651271777.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5224\u65ad\u6570\u7ec4\u5bf9\u8c61\u4e2d\u7684\u91cd\u590d\u6570\u636e\u5e76\u7edf\u8ba1\u91cd\u590d\u6b21\u6570\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5224\u65ad\u6570\u7ec4\u5bf9\u8c61\u4e2d\u7684\u91cd\u590d\u6570\u636e\u5e76\u7edf\u8ba1\u91cd\u590d\u6b21\u6570\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5224\u65ad\u6570\u7ec4\u5bf9\u8c61\u7684\u91cd\u590d\u6570\u636e\u5e76\u7edf\u8ba1\u91cd\u590d\u6b21\u6570\uff1f<\/strong><\/p>\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u6570\u7ec4\u5bf9\u8c61\uff0c\u5176\u4e2d\u5305\u542b\u591a\u4e2a\u6570\u636e\u9879\uff0c\u6bcf\u4e2a\u6570\u636e\u9879\u90fd\u6709\u4e00\u4e2a\u552f\u4e00\u7684\u5b57\u6bb5&#8221;NO&#8221;\u3002\u9700\u8981\u6839\u636e&#8221;NO&#8221;\u5b57\u6bb5\u5224\u65ad\u662f\u5426\u5b58\u5728\u91cd\u590d\u6570\u636e\uff0c\u5e76\u4e3a\u6bcf\u4e2a\u6570\u636e\u9879\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u5b57\u6bb5&#8221;\u91cd\u590d\u6b21\u6570&#8221;\u6765\u663e\u793a\u91cd\u590d\u7684\u6b21\u6570\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4ee3\u7801\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u5b9e\u73b0\u8fd9\u4e00\u529f\u80fd\uff1a<\/p>\n<pre>const list = [\n  {\n    DF: 343,\n    Fstep: 0.2,\n    NO: 1004\n  },\n  {\n    DF: 344,\n    Fstep: 0.2,\n    NO: 1005\n  },\n  {\n    DF: 345,\n    Fstep: 0.2,\n    NO: 1004\n  },\n  {\n    DF: 346,\n    Fstep: 0.2,\n    NO: 1004\n  },\n  {\n    DF: 347,\n    Fstep: 0.2,\n    NO: 1006\n  },\n  {\n    DF: 348,\n    Fstep: 0.2,\n    NO: 1005\n  }\n];\n\nconst result = list.reduce((s, v) =&gt; {\n  const index = s.findIndex((it) =&gt; it.NO === v.NO);\n  if (index !== -1) {\n    s[index] = {\n      ...v,\n      startTime: s[index].startTime,\n      endTime: getNowDate(),\n      count: ++s[index].count\n    };\n  } else {\n    s.push({\n      ...v,\n      count: 1,\n      startTime: getNowDate(),\n      endTime: getNowDate()\n    });\n  }\n  return s;\n}, []);\n\nconsole.log(result);<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6b64\u4ee3\u7801\u5bf9\u6570\u7ec4\u5bf9\u8c61\u8fdb\u884c\u4e86\u5faa\u73af\uff0c\u4f7f\u7528reduce\u65b9\u6cd5\u5c06\u91cd\u590d\u7684\u6570\u636e\u9879\u5408\u5e76\u5e76\u66f4\u65b0count\u5b57\u6bb5\u7684\u503c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5224\u65ad\u6570\u7ec4\u5bf9\u8c61\u4e2d\u7684\u91cd\u590d\u6570\u636e\u5e76\u7edf\u8ba1\u91cd\u590d\u6b21\u6570\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5224\u65ad\u6570\u7ec4\u5bf9\u8c61\u7684\u91cd\u590d\u6570\u636e\u5e76\u7edf\u8ba1\u91cd\u590d\u6b21\u6570\uff1f \u7ed9\u5b9a\u4e00\u4e2a\u6570\u7ec4\u5bf9\u8c61\uff0c\u5176\u4e2d\u5305\u542b\u591a\u4e2a\u6570\u636e\u9879\uff0c\u6bcf\u4e2a\u6570\u636e\u9879\u90fd\u6709\u4e00\u4e2a\u552f\u4e00\u7684\u5b57\u6bb5&#8221;NO&#8221;\u3002\u9700\u8981\u6839\u636e&#8221;NO&#8221;\u5b57\u6bb5\u5224\u65ad\u662f\u5426\u5b58\u5728\u91cd\u590d\u6570\u636e\uff0c\u5e76\u4e3a\u6bcf\u4e2a\u6570\u636e\u9879\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u5b57\u6bb5&#8221;\u91cd\u590d\u6b21\u6570&#8221;\u6765\u663e\u793a\u91cd\u590d\u7684\u6b21\u6570\u3002 \u4ee5\u4e0b\u662f\u4e00\u4e2a\u4ee3\u7801\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u5b9e\u73b0\u8fd9\u4e00\u529f\u80fd\uff1a const list = [ { DF: 343, Fstep: 0.2, NO: 1004 }, { DF: 344, Fstep: 0.2, NO: 1005 }, { DF: 345, Fstep: 0.2, NO: 1004 }, { DF: 346, Fstep: 0.2, NO: 1004 }, { DF: 347, Fstep: 0.2, NO: 1006 }, { DF: 348, Fstep: 0.2, NO: 1005 } [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-1809","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1809","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=1809"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1809\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}