{"id":10008143,"date":"2023-08-23T13:01:47","date_gmt":"2023-08-23T05:01:47","guid":{"rendered":"https:\/\/blog.itmax.cn\/?p=10008143"},"modified":"2023-08-23T13:01:47","modified_gmt":"2023-08-23T05:01:47","slug":"%e5%ba%93%e5%ad%98%e9%a2%84%e5%8d%a0%e6%9e%b6%e6%9e%84%e5%8d%87%e7%ba%a7%e6%96%b9%e6%a1%88%e8%ae%be%e8%ae%a1-%e4%ba%a4%e6%98%93%e5%ba%93%e5%ad%98%e4%b8%ad%e5%bf%83-%e4%ba%ac%e4%b8%9c%e7%89%a9","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10008143","title":{"rendered":"\u5e93\u5b58\u9884\u5360\u67b6\u6784\u5347\u7ea7\u65b9\u6848\u8bbe\u8ba1-\u4ea4\u6613\u5e93\u5b58\u4e2d\u5fc3 | \u4eac\u4e1c\u7269\u6d41\u6280\u672f\u56e2\u961f"},"content":{"rendered":"<h2>\u80cc\u666f\u4ecb\u7ecd<\/h2>\n<p>\u4f34\u968f\u7269\u6d41\u884c\u4e1a\u7684\u8fc5\u731b\u53d1\u5c55\uff0c\u4e00\u4f53\u5316\u4f9b\u5e94\u94fe\u6a21\u5f0f\u7684\u843d\u5730\uff0c\u5bf9\u7cfb\u7edf\u541e\u5410\u3001\u7cfb\u7edf\u7a33\u5b9a\u53d1\u51fa\u5de8\u5927\u6311\u6218\uff0c\u5e93\u5b58\u4f5c\u4e3a\u4f9b\u5e94\u94fe\u7684\u91cd\u4e2d\u4e4b\u91cd\u8868\u73b0\u66f4\u4e3a\u660e\u663e\u3002\u8fd1\u4e09\u5e74\u6570\u636e\u53ef\u4ee5\u770b\u51fa\uff1a<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044141472\" alt=\"\" title=\"\"><\/p>\n<p>\u63a5\u5165\u5546\u5bb6\u540c\u6bd4\u589e\u957f37.64%\u3001\u8d27\u54c1\u79cd\u7c7b\u540c\u6bd4\u589e\u957f53.66%<\/p>\n<p>\u8d27\u54c1\u6570\u91cf\u540c\u6bd4\u589e\u957f46.43%\u3001\u4ed3\u5e93\u6570\u91cf\u540c\u6bd4\u589e\u957f18.87%<\/p>\n<p>\u901a\u8fc7\u5206\u6790\u8fc7\u5f80\u5927\u4fc3\u6d41\u91cf\uff0c\u5206\u949f\u7ea7\u6d41\u91cf\u589e\u957f\u7387\u4e3a75%\uff0c\u5927\u4fc3\u4ed3\u5185\u53cd\u9988\u4e09\u65b9\u8ba2\u5355\u4e0b\u4f20\u4e0d\u53ca\u65f6\uff0c\u5e93\u5b58\u9884\u5360\u541e\u5410\u91cf\u548c\u6027\u80fd\u662f\u5bfc\u81f4\u8ba2\u5355\u79ef\u538b\u56e0\u7d20\u4e4b\u4e00\u3002\u76ee\u524d\u5e93\u5b58\u4f7f\u7528mysql\u6570\u636e\u5e93\u4f5c\u4e3a\u63a5\u5355\u9884\u5360\u7684\u625b\u91cf\u624b\u6bb5\uff0c\u968f\u7740\u4e00\u4f53\u5316\u4f9b\u5e94\u94fe\u5efa\u8bbe\u4ee5\u53ca\u91cd\u70b9KA\u5546\u5bb6\u4e0d\u65ad\u63a5\u5165\uff0c\u73b0\u6709\u5e93\u5b58\u67b6\u6784\u5728\u4e1a\u52a1\u652f\u6491\u4e0a\u5b58\u5728\u98ce\u9669\u548c\u7f3a\u9677\u3002<\/p>\n<p>\u6b64\u5916\u672a\u67653\u52305\u5e74\u4e1a\u52a1\u589e\u957f\u3001\u6d41\u91cf\u589e\u957f\u9884\u8ba1\u589e\u957f5-10\u500d\u3002\u4e3a\u907f\u514d\u7cfb\u7edf\u6027\u80fd\u548c\u6280\u672f\u67b6\u6784\u7f3a\u9677\u5bfc\u81f4\u4e1a\u52a1\u635f\u5931\uff0c\u8f7b\u91cf\u7ea7\u5e93\u5b58\u67b6\u6784\u52bf\u5728\u5fc5\u884c\u3002<\/p>\n<p>\/\/ \u540d\u8bcd\u89e3\u91ca\uff1a<\/p>\n<p>\u5e93\u5b58\u9884\u5360\uff1a\u662f\u6307\u6d88\u8d39\u8005\u62cd\u4e0b\u5546\u54c1\u8ba2\u5355\u540e\uff0c\u5e93\u5b58\u5148\u4e3a\u8be5\u8ba2\u5355\u77ed\u6682\u9884\u7559\uff0c\u9884\u7559\u7684\u5e93\u5b58\u5373\u4e3a\u9884\u5360\u5e93\u5b58\u3002<\/p>\n<h2>\u67b6\u6784\u539f\u5219<\/h2>\n<blockquote><p><strong>\u67b6\u6784<\/strong>\uff1a\u662f\u2faf\u5411\u95ee\u9898\uff0c\u89e3\u51b3\u95ee\u9898\u7684\u624b\u6bb5\u3002 \u5e93\u5b58\u7cfb\u7edf\u7684\u95ee\u9898: \u975e\u529f\u80fd\u6027\uff1a1.\u9ad8\u5e76\u53d1 2.\u7cfb\u7edf\u7a33\u5b9a\u6027(\u5bb9\u707e) 3.\u6570\u636e\u4e00\u81f4\u6027 \u529f\u80fd\u6027: 1.\u4e1a\u52a1\u590d\u6742 2.\u6570\u636e\u4e00\u81f4\u6027<\/p><\/blockquote>\n<h2>\u7cfb\u7edf\u8bbe\u8ba1<\/h2>\n<h3>\u8bbe\u8ba1\u601d\u8def<\/h3>\n<ol>\n<li>\u5f53\u524d\u5e93\u5b58\u7cfb\u7edf\u74f6\u9888\u5728\u54ea\u91cc\uff1f\uff1a\u6297\u5199\u6d41\u91cf\uff0c\u6570\u636e\u5e93\u6210\u4e3a\u74f6\u9888\u70b9\u3002<\/li>\n<li>\u5982\u4f55\u89e3\u51b3\u7cfb\u7edf\u74f6\u9888\uff1f\uff1a\u7531\u9ad8\u5e76\u53d1\u7ec4\u4ef6Redis\u66ff\u4ee3\u6570\u636e\u5e93\u3002<\/li>\n<li>\u5229\u7528Redis\u9700\u8981\u89e3\u51b3\u54ea\u4e9b\u95ee\u9898\uff1f\uff1a\u9632\u8d85\u5356\uff0c\u5f02\u6b65\u5199\u6570\u636e\u5e93\u4fdd\u8bc1\u6700\u7ec8\u4e00\u81f4\u6027\u3002<\/li>\n<\/ol>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044141473\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h3>\u603b\u4f53\u8bbe\u8ba1<\/h3>\n<ul>\n<li><strong>\u625b\u91cf\u90e8\u5206<\/strong>\uff1a\u5e93\u5b58\u6027\u80fd\u74f6\u9888\u5728\u9884\u5360\uff0c\u4f20\u7edf\u67b6\u6784\u4e3b\u8981\u4f9d\u9760\u6570\u636e\u5e93\u4e8b\u52a1\u4fdd\u6301\u6570\u636e\u4e00\u81f4\u4ee5\u53ca\u6570\u636e\u8bfb\u5199\uff1b\u65b0\u7248\u67b6\u6784\u8bbe\u8ba1\u5c06\u6570\u636e\u625b\u91cf\u90e8\u5206\u79fb\u690d\u5230Redis\uff0c\u5229\u7528Redis\u9ad8\u6027\u80fd\u541e\u5410\u89e3\u51b3\u9ad8\u5e76\u53d1\u573a\u666f\u4e0b\u6570\u636e\u8bfb\u5199\u3002<\/li>\n<li><strong>\u6570\u636e\u56de\u5199<\/strong>\uff1aRedis\u8fdb\u884c\u625b\u91cf\u524a\u5cf0\uff0c\u540e\u7eed\u6570\u636e\u4ec5\u7528\u4e8e\u8bb0\u8d26\uff0c\u6700\u7ec8\u727a\u7272\u6570\u636e\u7684\u77ed\u6682\u4e00\u81f4\u6027\u8fbe\u5230\u524a\u5cf0\u7684\u76ee\u7684\u3002<\/li>\n<li><strong>\u5dee\u5f02\u90e8\u5206<\/strong>\uff1a\u8001\u7248\u672c\u5e93\u5b58\u9884\u5360\u8bbe\u8ba1\u4ec5\u4f9d\u9760\u6570\u636e\u8fdb\u884c\u6570\u636e\u5904\u7406\uff0c\u65b0\u7248\u8bbe\u8ba1\u4f9d\u9760\u5207\u91cf\u914d\u7f6e\u5efa\u6570\u636e\u5207\u6362\u5230Redis\uff0c\u5229\u7528Redis\u9ad8\u8bfb\u5199\u8fdb\u884c\u524a\u5cf0\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044141474\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h3>\u8be6\u7ec6\u8bbe\u8ba1<\/h3>\n<ul>\n<li>\u4e3b\u6d41\u7a0b\uff1a<\/li>\n<\/ul>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044141475\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<ul>\n<li><strong>\u5e93\u5b58\u521d\u59cb\u5316<\/strong>\uff1a\u7ade\u6001\u6761\u4ef6\u5229\u7528Redis watch\u547d\u4ee4\u6765\u5b9e\u73b0\u9501\u7b49\u5f85\uff0c\u89e3\u51b3\u5e76\u53d1\u573a\u666f\u6570\u636e\u4e0d\u4e00\u81f4\u95ee\u9898\u3002<\/li>\n<li><strong>LUA\u6267\u884c\u5668<\/strong>\uff1a\u5c06\u539f\u5b50\u64cd\u4f5c\u6307\u4ee4\/\u590d\u7528\u6307\u4ee4\u5c01\u88c5\u5230LUA\u811a\u672c\u4e2d\u4ee5\u51cf\u5c11\u7f51\u7edc\u5f00\u9500\u3002<\/li>\n<li><strong>\u8865\u507f\u673a\u5236\uff1ai&gt;<\/strong> \u6267\u884c\u6d41\u7a0b\u4e2d\u6240\u6709\u4e1a\u52a1\u5f02\u5e38\u53d1\u751f\u65f6\u4f1a\u540c\u6b65\u53d1\u8d77\u53cd\u5411\u64cd\u4f5c\u8bf7\u6c42\uff1b<strong>ii&gt;<\/strong> \u53cd\u5411\u64cd\u4f5c\u6267\u884c\u5f02\u5e38\u540e\u4f1a\u63d0\u4ea4\u5f02\u6b65\u53cd\u5411\u64cd\u4f5c\u4efb\u52a1\uff1b**iii&gt;**\u5f02\u6b65\u4efb\u52a1\u6267\u884c\u5f02\u5e38\u540e\uff0c\u4f9d\u8d56\u76d1q\u63a7\u7cfb\u7edf\u626b\u63cf\u5f02\u5e38\u5355\u636e\u6216\u5f02\u5e38\u5e93\u5b58\u5e76\u4fee\u6539\u5f02\u5e38\u5e93\u5b58\u91cf<\/li>\n<\/ul>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044141476\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<ul>\n<li><strong>\u56de\u6eaf\u56de\u5199<\/strong>\uff1a\u4efb\u52a1\u843d\u5e93\u540e\u53d1\u51famq\u7ec4\u88c5\u53c2\u6570\u8c03\u7528\u6570\u636e\u56de\u5199\u670d\u52a1\uff0c\u6570\u636e\u56de\u5199\u670d\u52a1\u64cd\u4f5c\u5e93\u5b58\u6570\u91cf\uff1b\u540c\u65f6\u56de\u5199redis\u6570\u636e\uff0c\u91ca\u653e\u9884\u5360\u91cf\u5e93\u5b58\u6570\u636e\uff1b\u66f4\u65b0\u4efb\u52a1\u5e93\u6570\u636e\u72b6\u6001<\/li>\n<\/ul>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044141477\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h3>\u6570\u636e\u7ed3\u6784<\/h3>\n<ul>\n<li><strong>\u5e93\u5b58\u8bb0\u5f55\u7d22\u5f15<\/strong>\uff1a{deptNo|goodsNo|warehouseNo}|stockStatus|stockType|goodsLevel<\/li>\n<li><strong>hashTag<\/strong>\uff1a{deptNo|goodsNo|warehouseNo}|stockStatus|stockType|goodsLevel<\/li>\n<li><strong>\u53ef\u552e\u5e93\u5b58\u6570\u91cf<\/strong>\uff1ausableKey\uff1a{\u5e93\u5b58\u8bb0\u5f55\u7d22\u5f15}<\/li>\n<li><strong>\u6263\u51cf\u5e93\u5b58\u91cf<\/strong>\uff1ausableSubtractKey\uff1a{\u5e93\u5b58\u8bb0\u5f55\u7d22\u5f15} \uff0c\u8bb0\u5f55Redis\u5230DB\u6267\u884c\u671f\u95f4\u51cf\u5e93\u5b58\u91cf<\/li>\n<li><strong>\u9884\u5360\u9632\u91cdkey<\/strong>\uff1aoperateKey\uff1a{\u5e93\u5b58\u8bb0\u5f55\u7d22\u5f15\uff1a\u5355\u53f7} \u9632\u91cdkey\u9632\u5e76\u53d1\u91cd\u590d\u8bf7\u6c42<\/li>\n<li><strong>\u56de\u6eda\u9632\u91cd<\/strong>\uff1arollbackOperateKey\uff1a{\u5e93\u5b58\u8bb0\u5f55\u7d22\u5f15}<\/li>\n<li><strong>\u7f3a\u91cf\u9884\u5360\u5e93\u5b58\u91cf<\/strong>\uff1aullageOperateKey\uff1a{\u5e93\u5b58\u8bb0\u5f55\u7d22\u5f15}<\/li>\n<li><strong>\u6263\u51cf\u5e93\u5b58\u5355\u636e\u8bb0\u5f55<\/strong>\uff1ahSetrecord: {\u5e93\u5b58\u8bb0\u5f55\u7d22\u5f15}<\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th>key<\/th>\n<th>\u9884\u5360<\/th>\n<th>\u7f3a\u91cf\u9884\u5360<\/th>\n<th>\u56de\u6eda<\/th>\n<th>\u56de\u5199<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>\u53ef\u552e\u5e93\u5b58\u6570\u91cf<\/strong><\/td>\n<td>&#8211;<\/td>\n<td>&#8211;<\/td>\n<td>+<\/td>\n<td>\u4e0d\u53d8<\/td>\n<\/tr>\n<tr>\n<td><strong>\u6263\u51cf\u5e93\u5b58\u91cf<\/strong><\/td>\n<td>+<\/td>\n<td>+<\/td>\n<td>&#8211;<\/td>\n<td>&#8211;<\/td>\n<\/tr>\n<tr>\n<td><strong>\u9884\u5360\u9632\u91cdkey<\/strong><\/td>\n<td>+<\/td>\n<td>+<\/td>\n<td>&#8211;<\/td>\n<td>\u4e0d\u53d8<\/td>\n<\/tr>\n<tr>\n<td><strong>\u56de\u6eda\u9632\u91cd<\/strong><\/td>\n<td>\u4e0d\u53d8<\/td>\n<td>\u4e0d\u53d8<\/td>\n<td>+<\/td>\n<td>\u4e0d\u53d8<\/td>\n<\/tr>\n<tr>\n<td><strong>\u7f3a\u91cf\u9884\u5360\u5e93\u5b58\u91cf<\/strong><\/td>\n<td>\u4e0d\u53d8<\/td>\n<td>+<\/td>\n<td>\u53cd\u5411<\/td>\n<td>\u4e0d\u53d8<\/td>\n<\/tr>\n<tr>\n<td><strong>\u6263\u51cf\u5e93\u5b58\u5355\u636e\u8bb0\u5f55<\/strong><\/td>\n<td>+<\/td>\n<td>+<\/td>\n<td>&#8211;<\/td>\n<td>&#8211;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Redis&#038;DB<\/h3>\n<ul>\n<li>\u9996\u5148\u8fdb\u884credis&#038;\u4ece\u5e93\u6570\u636e\u6bd4\u5bf9\uff0c\u82e5\u5b58\u5728\u5dee\u5f02\u5219\u5bf9\u4e3b\u5e93\u8fdb\u884c\u6821\u9a8c<\/li>\n<li>\u6bd4\u5bf9\u8fc7\u7a0b\u4e2d\uff0cDB\u4e2dsku\u660e\u7ec6\u884c\u8fdb\u884c\u9501\u5b9a(for update)\uff0c\u6bd4\u5bf9\u903b\u8f91\u4e3aDB\u53ef\u7528\u5e93\u5b58\u91cf==(Redis\u53ef\u7528\u5e93\u5b58\u91cf+Redis\u9884\u5360\u91cf)<\/li>\n<li>\u6709\u5dee\u5f02\uff0c\u62a5\u8b66\u4e14\u89e6\u53d1SDK\u53ef\u7528\u91cf\u8fc7\u671f\uff0c\u540c\u65f6\u77eb\u6b63\u9884\u5360\u91cf<\/li>\n<\/ul>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044141478\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h3>\u5bb9\u707e\u65b9\u6848<\/h3>\n<hr>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044141479\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\/\/ \u5bf9\u7cfb\u7edf\u5bb9\u9519\/\u964d\u7ea7\u3001\u76d1\u63a7\u673a\u5236(\u7a7a\u95f4\u6362\u7a33\u5b9a\u6027\uff0c\u4e24\u4efdredis\uff0c\u6545\u969c3\u6b21\u4e22\u6570)\uff0c\u6d41\u91cf\u5206\u5e03\u6750\u6599\uff0c618\u6d41\u91cf\u5927\u3001\u5cf0\u503c\u6570\u636e\u5207\u91cf\u3002\u6570\u636e\u4e0d\u4e00\u81f4\uff0c\u591a\u4e2a\u5546\u5bb6\uff0c\u4e0d\u80fd\u8d85\u8fc75\u5206\u3002<\/p>\n<p>\u9884\u5360\u4efb\u52a1\u6301\u4e45\u5316\uff1amysql\u9700\u8981\u5c06\u6838\u5fc3\u5c5e\u6027\u5b57\u6bb5\u6570\u636e\u6301\u4e45\u5316\uff1a\u4e8b\u4e1a\u90e8\uff0c\u5546\u54c1\u7f16\u7801\uff0c\u4ed3\u7f16\u7801\uff0c\u7b49\u7ea7\uff0c\u5e93\u5b58\u7c7b\u578b\uff0c\u5e93\u5b58\u72b6\u6001\uff0c\u9884\u5360\u5e93\u5b58\u91cf\uff0c\u4efb\u52a1\u72b6\u6001;\u8c03\u5ea6\u6267\u884c\u5b8c\u6210\u540e\u9700\u8981\u66f4\u65b0stockTask\u72b6\u6001\u4e3a\u5b8c\u6210<\/p>\n<p>\u521d\u59cb\u5316\uff1a<\/p>\n<p>(1) lock db<\/p>\n<p>(2) sum stockTask<\/p>\n<p>(3)\u4f7f\u7528DB\u53ef\u7528\u5e93\u5b58\u521d\u59cb\u5316Redis\u53ef\u7528\u5e93\u5b58\uff0cstockTask\u9884\u5360\u91cf\u521d\u59cb\u5316Redis\u9884\u5360\u91cf<\/p>\n<p>(4)Redis\u5e93\u5b58\u56de\u6eda\uff0c\u5982\u679c\u9884\u5360\u91cfkey\u4e0d\u5b58\u5728\uff0c\u8be5key\u4e0d\u9700\u8981\u56de\u6eda<\/p>\n<h2>\u6027\u80fd\u7ed3\u679c<\/h2>\n<hr>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044141480\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>23\u5e74618\u5927\u4fc3<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044141481\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044141482\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h2>\u5207\u91cf\u7ec6\u5219<\/h2>\n<p>\u5207\u91cf\u7ec6\u5219<\/p>\n<h2>\u51b7\u70ed\u6570\u636e<\/h2>\n<p>OMS\u5e93\u5b58\u51b7\u70ed\u88c5\u7f6e<\/p>\n<p>\u9884\u5360\u67b6\u6784\u5347\u7ea7\u5207\u91cf\u91cd\u70b9key\u76d1\u63a7<\/p>\n<p>\u5e93\u5b58\u9884\u5360\u67b6\u6784\u5347\u7ea7\u5207\u91cf\u5546\u5bb6<\/p>\n<p>\u67b6\u6784\u5347\u7ea7\u5207\u91cf\u5546\u5bb6\u660e\u7ec62<\/p>\n<p>\u5df2\u5207\u91cf\u5546\u5bb6<\/p>\n<h2>\u53cd\u5411\u5207\u91cf<\/h2>\n<blockquote>\n<p>\u539f\u6709\u8bbe\u8ba1\u4e2d\u5b58\u5728\u4ee5\u4e0b\u540d\u5355<\/p>\n<p>\u7981\u6b62\u5207\u91cf\u5546\u5bb6\uff1a\u4f18\u5148\u7ea7\u8f83\u9ad8\uff0c\u4e00\u65e6\u5728\u540d\u5355\u4e2d\uff0c\u7981\u6b62\u5207\u91cf<\/p>\n<p>\u6279\u6b21\u5e93\u5b58\u5546\u5bb6\uff1a\u6279\u6b21\u5e93\u5b58\u7ba1\u7406\u5546\u5bb6\uff0c\u76ee\u524d\u8be5\u90e8\u5206\u80fd\u529b\u5c1a\u672a\u5efa\u8bbe<\/p>\n<p>\u52a8\u6001\u8d28\u62bc\u5546\u5bb6\uff1a\u7269\u6d41\u91d1\u878d\u4e1a\u52a1\uff0c\u76ee\u524d\u8be5\u90e8\u5206\u80fd\u529b\u5c1a\u672a\u5efa\u8bbe \u5207\u91cf\u540d\u5355\u5546\u5bb6\uff1a\u8be5\u90e8\u5206\u4e3a\u5207\u91cf\u5546\u5bb6<\/p>\n<p>\u539f\u6709\u5207\u91cf\u6d41\u7a0b\uff1a\uff01\u7981\u6b62\u5207\u91cf-&gt;\uff01\u6279\u6b21\u5e93\u5b58-&gt;\uff01\u52a8\u6001\u8d28\u62bc-&gt;\u5207\u91cf\u540d\u5355\u4e2d\uff0c\u901a\u8fc7\u4ee5\u4e0a\u6821\u9a8c\u4e3a\u5207\u91cf\u5546\u5bb6\u3002<\/p>\n<p>\u539f\u6709\u6d41\u7a0b\u5728\u589e\u91cf\u5546\u5bb6\u4e2d\u9700\u8981\u624b\u52a8\u5c06\u5546\u5bb6\u914d\u7f6e\u5230\u5207\u91cf\u540d\u5355\u4e2d\u624d\u53ef\u8fdb\u884c\u5207\u91cf\u64cd\u4f5c\uff0c\u5bf9\u4e8e\u65b0\u589e\u5546\u5bb6\u573a\u666f\u64cd\u4f5c\u4e0d\u53d8\uff0c\u4e14\u539f\u6709\u6d41\u7a0b\u4e2d\u903b\u8f91\u5e93\u5b58\u540d\u5355\u4e3a\u75db\u70b9\uff1a\u903b\u8f91\u5e93\u5b58\u7684\u542f\u7528\u914d\u7f6e\u5728\u4e8b\u4e1a\u90e8\u4e3b\u6570\u636e\u4e2d\uff0c\u4e0d\u5728\u5e93\u5b58\u4fa7\u3002<\/p>\n<p>\u65b0\u7248\u5207\u91cf\u6d41\u7a0b\u4e2d\u5bf9\u5207\u91cf\u540d\u5355\u8fdb\u884c\u4f18\u5316\uff0c\u5c06\u539f\u6765\u5207\u91cf\u540d\u5355\u5546\u5bb6\u62c6\u5206\u6210\u975e\u903b\u8f91\u5e93\u5b58\u540d\u5355\u3001\u903b\u8f91\u5e93\u5b58\u4e24\u4e2a\u540d\u5355\uff0c\u5176\u4e2d\uff1a<\/p>\n<p>\u975e\u903b\u8f91\u5e93\u5b58\u540d\u5355\uff1a\u5305\u542b\u53ef\u5207\u91cf\u5546\u5bb6<\/p>\n<p>\u903b\u8f91\u5e93\u5b58\u540d\u5355\uff1a\u903b\u8f91\u5e93\u5b58\u5546\u5bb6\uff0c\u8be5\u90e8\u5206\u4e0d\u53ef\u5207\u91cf<\/p>\n<\/blockquote>\n<p>\u539f\u6d41\u7a0b\u65b0\u6d41\u7a0b\u5bf9\u5207\u91cf\u5546\u5bb6\u540d\u5355\u8fdb\u884c\u4f18\u5316\uff0c\u62c6\u5206\u6210\u975e\u903b\u8f91\u5e93\u5b58\u540d\u5355\u3001\u903b\u8f91\u5e93\u5b58\u4e24\u4e2a\u540d\u5355<\/p>\n<h2>\u6784\u5efa\u6a21\u578b(\u6279\u6b21\u5e93\u5b58&#038;\u5185\u5b58\u6a21\u578b\u5f85\u7eed)<\/h2>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044141483\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h3>Redis\u5b58\u50a8\u6570\u636e\u7ed3\u6784<\/h3>\n<ul>\n<li>MD\u751f\u6210\u89c4\u5219\u5de5\u5177\u96c6<\/li>\n<\/ul>\n<p>\u25e6\u903b\u8f91\u5e93\u5b58MD5\u5de5\u5177<\/p>\n<pre><code>     StringBuffer md5Key = new StringBuffer();\n     md5Key.append(logicWarehouseStock.getGoodsNo()+&quot;_&quot;+logicWarehouseStock.getWarehouseNo()+&quot;_&quot;+logicWarehouseStock.getOwnerNo()+\n             &quot;_&quot;+logicWarehouseStock.getDeptNo()+&quot;_&quot;+logicWarehouseStock.getStockType()+&quot;_&quot;+logicWarehouseStock.getGoodsLevel());\n     if(StringUtils.isBlank(logicWarehouseStock.getFactor1())){\n         md5Key.append(&quot;_0&quot;);\n     }else {\n         md5Key.append(&quot;_&quot;+logicWarehouseStock.getFactor1());\n     }\n     if(StringUtils.isBlank(logicWarehouseStock.getFactor2())){\n         md5Key.append(&quot;_0&quot;);\n     }else {\n         md5Key.append(&quot;_&quot;+logicWarehouseStock.getFactor2());\n     }\n     if(StringUtils.isBlank(logicWarehouseStock.getFactor3())){\n         md5Key.append(&quot;_0&quot;);\n     }else {\n         md5Key.append(&quot;_&quot;+logicWarehouseStock.getFactor3());\n     }\n     if(StringUtils.isBlank(logicWarehouseStock.getFactor4())){\n         md5Key.append(&quot;_0&quot;);\n     }else {\n         md5Key.append(&quot;_&quot;+logicWarehouseStock.getFactor4());\n     }\n     if(logicWarehouseStock.getYn()== null){\n      md5Key.append(&quot;_1&quot;);\n     }else {\n         md5Key.append(&quot;_&quot;+logicWarehouseStock.getYn());\n     }\n     md5Key.toString().hashCode()\n\n\n\n\n\n\n<\/code><\/pre>\n<ul>\n<li>\u6279\u6b21\u5e93\u5b58MD5\u5de5\u5177<\/li>\n<\/ul>\n<pre><code>public void fillMd5Value(){\n        StringBuffer md5Key = new StringBuffer();\n        md5Key.append(warehouseNo);\n        md5Key.append(&quot;_&quot;);\n        md5Key.append(goodsNo);\n        md5Key.append(&quot;_&quot;);\n        md5Key.append(goodsLevel);\n        md5Key.append(&quot;_&quot;);\n        md5Key.append(stockType);\n        \/\/\u904d\u5386\u7c7b\u5b57\u6bb5\u4e0d\u904d\u5386map\u662f\u4e3a\u4e86\u63a7\u5236MD5\u7684\u7ec4\u6210\u987a\u5e8f\n        Class clazz = BatchAttrStock.class;\n        Field[] fields = clazz.getDeclaredFields();\n        try {\n            int batchFieldCount = 0 ;\n            for (Field field : fields){\n                BatchAttrEnum attrEnum = BatchAttrEnum.batchFieldEnumMap.get(field.getName());\n                \/\/\u4e0d\u662f\u6279\u5c5e\u6027\u7684\u5b57\u6bb5\u4e0d\u8fdb\u5165MD5\u7684\u7ec4\u6210\n                if (attrEnum == null){\n                    continue;\n                }\n                batchFieldCount ++;\n                field.setAccessible(true);\n                Object value = field.get(this);\n                if (value == null ){\n                    md5Key.append(&quot;0&quot;);\n                    continue;\n                }\n                if(field.getType().toString().contains(&quot;String&quot;)){\n                    md5Key.append(value);\n                    continue;\n                }\n                if(field.getType().toString().contains(&quot;Date&quot;)){\n                    Date timeField = (Date) value;\n                    md5Key.append(timeField.getTime());\n                    continue;\n                }\n                throw new RuntimeException(attrEnum.getField()+&quot;\u586b\u5145MD5\u5f02\u5e38&quot;);\n            }\n            \/\/\u9ed8\u8ba450\u4e2a\u6279\u5c5e\u6027\u957f\u5ea6,\u957f\u5ea6\u4e0d\u591f0\u8865\u9f50\n            int remainLength = 50 - batchFieldCount;\n            String str = String.format(&quot;%0&quot;+remainLength+&quot;d&quot;, 0);\n            md5Key.append(str);\n\n        }catch (Exception e){\n            throw new RuntimeException(&quot;\u586b\u5145MD5\u5f02\u5e38.&quot;);\n        }\n\n        md5Key.append(yn);\n        String md5Value =  MD5Util.md5(md5Key.toString());\n        setMd5Value(md5Value);\n    }\n\n\n\n\n\n\n<\/code><\/pre>\n<ul>\n<li>MD&#038;ID&#038;\u5c5e\u6027\u4fdd\u5b58\u5de5\u5177<\/li>\n<\/ul>\n<p>\u672c\u6587\u7bc7\u5e45\u6709\u9650\uff0c\u4f59\u4e0b\u4e8c\u671f\u8fdb\u884c\u5206\u4eab\u3002<\/p>\n<blockquote>\n<p>\u4f5c\u8005\uff1a\u4eac\u4e1c\u7269\u6d41 \u91d1\u9e4f<\/p>\n<p>\u6765\u6e90\uff1a\u4eac\u4e1c\u4e91\u5f00\u53d1\u8005\u793e\u533a \u81ea\u733f\u5176\u8bf4Tech \u8f6c\u8f7d\u8bf7\u6ce8\u660e\u6765\u6e90<\/p>\n<\/blockquote>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000044141470\">https:\/\/segmentfault.com\/a\/1190000044141470<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f\u4ecb\u7ecd \u4f34\u968f\u7269\u6d41\u884c\u4e1a\u7684\u8fc5\u731b\u53d1\u5c55\uff0c\u4e00\u4f53\u5316\u4f9b\u5e94\u94fe\u6a21\u5f0f\u7684\u843d\u5730\uff0c\u5bf9\u7cfb\u7edf\u541e\u5410\u3001\u7cfb\u7edf\u7a33\u5b9a\u53d1\u51fa\u5de8\u5927\u6311\u6218\uff0c\u5e93\u5b58\u4f5c\u4e3a\u4f9b\u5e94\u94fe\u7684\u91cd [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10008143","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10008143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10008143"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10008143\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10008143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10008143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10008143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}