{"id":200560,"date":"2025-05-06T08:40:47","date_gmt":"2025-05-06T00:40:47","guid":{"rendered":"https:\/\/server.hk\/cnblog\/200560\/"},"modified":"2025-05-06T08:40:47","modified_gmt":"2025-05-06T00:40:47","slug":"%e5%a6%82%e4%bd%95%e9%ab%98%e6%95%88%e8%8e%b7%e5%8f%96%e4%b8%80%e5%af%b9%e5%a4%9a%e5%85%b3%e7%b3%bb%e4%b8%ad%e8%ae%be%e5%a4%87%e7%9a%84%e6%9c%80%e6%96%b0%e7%8a%b6%e6%80%81%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/200560\/","title":{"rendered":"\u5982\u4f55\u9ad8\u6548\u83b7\u53d6\u4e00\u5bf9\u591a\u5173\u7cfb\u4e2d\u8bbe\u5907\u7684\u6700\u65b0\u72b6\u6001\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5982\u4f55\u9ad8\u6548\u83b7\u53d6\u4e00\u5bf9\u591a\u5173\u7cfb\u4e2d\u8bbe\u5907\u7684\u6700\u65b0\u72b6\u6001\uff1f<\/h1>\n<p>\u5b66\u4e60\u8981\u52aa\u529b\uff0c\u4f46\u662f\u4e0d\u8981\u6025\uff01\u4eca\u5929\u7684\u8fd9\u7bc7\u6587\u7ae0\u5c06\u4f1a\u4ecb\u7ecd\u5230\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u60f3\u6df1\u5165\u5b66\u4e60\uff0c\u53ef\u4ee5\u5173\u6ce8\u6211\uff01\u6211\u4f1a\u6301\u7eed\u66f4\u65b0\u76f8\u5173\u6587\u7ae0\u7684\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u90fd\u80fd\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241108\/1731054861672dcd0d62ad5.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u4e00\u5bf9\u591a\u67e5\u8be2\u4f18\u5316\uff1a\u9ad8\u6548\u83b7\u53d6\u8bbe\u5907\u6700\u65b0\u72b6\u6001<\/strong><\/p>\n<p>\u5728\u5904\u7406\u5173\u8054\u8868\u67e5\u8be2\u65f6\uff0c\u5982\u4f55\u9ad8\u6548\u5730\u83b7\u53d6\u4e00\u5bf9\u591a\u5173\u7cfb\u4e2d\u6700\u65b0\u7684\u4e00\u6761\u8bb0\u5f55\u662f\u4e00\u5927\u96be\u9898\u3002\u9488\u5bf9\u6b64\u9700\u6c42\uff0c\u6709\u4ee5\u4e0b\u4f18\u5316\u65b9\u6848\uff1a<\/p>\n<p><strong>\u5185\u8fde\u63a5\u67e5\u8be2<\/strong><\/p>\n<pre>select * from (select * from air_conditioner_record order by req_timestamp desc) as r group by air_conditioner_id order by req_timestamp desc<\/pre>\n<p>\u6b64\u65b9\u6848\u901a\u8fc7\u5185\u8fde\u63a5\u81ea\u8fde\u63a5\uff0c\u5c06\u6240\u6709\u8bbe\u5907\u8bb0\u5f55\u6309\u7167\u65f6\u95f4\u5012\u5e8f\u6392\u5217\u540e\u5206\u7ec4\uff0c\u518d\u6309\u7167\u65f6\u95f4\u5012\u5e8f\u6392\u5217\uff0c\u4ece\u800c\u5f97\u5230\u6bcf\u53f0\u8bbe\u5907\u7684\u6700\u65b0\u8bb0\u5f55\u3002<\/p>\n<p><strong>\u65f6\u95f4\u7a97\u53e3\u67e5\u8be2<\/strong><\/p>\n<pre>SELECT\n                r.air_conditioner_id,\n                r.curr_temp,\n                r.curr_power,\n                r.time_millis\n            FROM\n                air_conditioner_record r,\n            ( SELECT air_conditioner_id, max( time_millis ) max_time FROM air_conditioner_record WHERE time_millis &lt; UNIX_TIMESTAMP(NOW()) GROUP BY air_conditioner_id ) r2\n            WHERE\n                r2.air_conditioner_id = r.air_conditioner_id\n            AND r2.max_time = r.time_millis<\/pre>\n<p>\u6b64\u65b9\u6848\u521b\u5efa\u4e86\u4e00\u4e2a\u65f6\u95f4\u7a97\u53e3\uff0c\u4ec5\u8003\u8651\u5f53\u524d\u65f6\u95f4\u4e4b\u524d\u7684\u8bb0\u5f55\uff0c\u5e76\u5728\u8be5\u7a97\u53e3\u5185\u627e\u5230\u6bcf\u53f0\u8bbe\u5907\u7684\u6700\u65b0\u8bb0\u5f55\u3002\u8fd9\u79cd\u65b9\u6cd5\u9ad8\u6548\u4e14\u7b80\u6d01\u3002<\/p>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300a\u5982\u4f55\u9ad8\u6548\u83b7\u53d6\u4e00\u5bf9\u591a\u5173\u7cfb\u4e2d\u8bbe\u5907\u7684\u6700\u65b0\u72b6\u6001\uff1f\u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8\u4e3b\u673a\u5b9d\u8d1d\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u77e5\u8bc6\u70b9\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u9ad8\u6548\u83b7\u53d6\u4e00\u5bf9\u591a\u5173\u7cfb\u4e2d\u8bbe\u5907\u7684\u6700&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-200560","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200560","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=200560"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200560\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=200560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=200560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=200560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}