{"id":2176,"date":"2024-02-26T13:43:40","date_gmt":"2024-02-26T05:43:40","guid":{"rendered":"http:\/\/www.plm.cn\/?p=2176"},"modified":"2024-02-26T13:59:21","modified_gmt":"2024-02-26T05:59:21","slug":"gungho%e4%bb%bb%e5%8a%a1%e4%ba%8c%e6%ac%a1%e5%bc%80%e5%8f%91-%e4%bb%bb%e5%8a%a1%e5%88%86%e7%b1%bb%e9%9b%86%e6%88%903000%e5%8a%9f%e8%83%bd%e7%9a%84%e6%89%a9%e5%b1%95%e5%b1%9e%e6%80%a7excel%e5%af%bc","status":"publish","type":"post","link":"http:\/\/www.plm.cn\/2176\/","title":{"rendered":"Gungho\u4efb\u52a1\u4e8c\u6b21\u5f00\u53d1-\u4efb\u52a1\u5206\u7c7b\u96c6\u62103000\u529f\u80fd\u7684\u6269\u5c55\u5c5e\u6027excel\u5bfc\u5165"},"content":{"rendered":"
\u8fd9\u4e2a\u662f\u4e00\u4e2a\u6807\u51c6\u7684\u5bfc\u5165\u6a21\u677f \uff0c\u4f7f\u7528\u524d\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539 \u8868\u540d\uff0c\u5b57\u6bb5\u540d\u79f0\uff0c\u5b57\u6bb5\u4e2d\u6587\u540d\uff0c\u5b57\u6bb5\u5bf9\u5e94\u8d4b\u503c\u53d8\u91cf\u540d\u79f0\u3002<\/p>\n
–[[<\/p>\n
\u8fd9\u4e2a\u662f\u4e00\u4e2a\u6807\u51c6\u7684\u811a\u672c\uff0c\u53ef\u4ee5<\/p>\n
1\u3001\u4fee\u6539\u91cc\u9762\u7684\u6570\u636e\u5bf9\u8c61\u540d\u79f0 \u6837\u54c1\u6280\u672f\u53c2\u6570<\/span><\/p>\n 2\u3001\u5b57\u6bb5\u76f8\u5173\u540d\u79f0\uff08\u5b57\u6bb5\u4e2d\u6587\u540d\u3001\u5b57\u6bb5\u540d\u79f0\u3001\u5b57\u6bb5\u8d4b\u503c\u53d8\u91cf\u540d\u79f0\uff09<\/p>\n \u5b57\u6bb5\u540d\u79f0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u5b57\u6bb5\u4e2d\u6587\u540d\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u5b57\u6bb5\u5bf9\u5e94\u8d4b\u503c\u53d8\u91cf\u540d<\/span><\/p>\n N_SN\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u5e8f\u53f7\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0nSN<\/span><\/p>\n S_ITEM_NAME\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u540d\u79f0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0strItemName<\/span><\/p>\n S_ITEM_M_S_N\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u578b\u53f7_\u89c4\u683c_\u6570\u91cf\u00a0 \u00a0strItemMSN<\/span><\/p>\n S_ITEM_CODE\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u7f16\u53f7\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0strItemCode<\/span><\/p>\n S_MANUFACTURER\u00a0 \u00a0 \u00a0 \u00a0 \u751f\u4ea7\u5355\u4f4d\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 strFacturer<\/span><\/p>\n 3\u3001\u82e5\u5b57\u6bb5\u4e0d\u591f\u591a\uff0c\u6216\u592a\u591a\uff0c\u9700\u8981\u8c03\u6574\u7a0b\u5e8f<\/p>\n 4\u3001\u91cc\u9762\u7684\u552f\u4e00\u6027\u5224\u65ad\u662f task_id + S_ITEM_NAME + S_ITEM_CODE \uff08\u9700\u8981\u6839\u636e\u60c5\u51b5\u8c03\u6574\uff09<\/p>\n –]]<\/p>\n \u529f\u80fd\u8bf4\u660e\uff1a<\/span><\/span>json = require(“json”)<\/p>\n mobox = require(“OILua_JavelinExt”)<\/p>\n require(“oi_basestrfunc”)<\/p>\n function ImportExcle(strLuaDEID)<\/p>\n local nRet, strRetInfo<\/p>\n local strPrjID = ”<\/p>\n local strTaskID = ”<\/p>\n — \u83b7\u53d6\u5168\u5c40\u53d8\u91cf prj_id, task_id<\/p>\n nRet, strRetInfo = mobox.getGlobalAttr( strLuaDEID, “task_id”,”prj_id” )<\/p>\n if ( nRet ~= 0 or strRetInfo == ” ) then<\/p>\n mobox.error( strLuaDEID, “\u7cfb\u7edf\u65e0\u6cd5\u83b7\u53d6\u5168\u5c40\u53d8\u91cf “..strRetInfo )<\/p>\n return<\/p>\n end<\/p>\n local input_paramter = json.decode( strRetInfo )<\/p>\n strTaskID = input_paramter[1].value<\/p>\n strPrjID = input_paramter[2].value<\/p>\n if ( strTaskID == ” ) then<\/p>\n mobox.error( strLuaDEID, “\u5fc5\u987b\u8981\u6709\u9879\u76ee\u53ca\u4efb\u52a1\u76f8\u5173\u4fe1\u606f” )<\/p>\n return<\/p>\n end<\/p>\n — \u83b7\u53d6\u5bfc\u5165\u7684\u5355\u6761\u6570\u636e, \u8fd4\u56de {\u201cid\u201d:\u201dxxx\u201d,\u201dattrs\u201d:[{\u201cattr\u201d:\u201dattr1\u2033,\u201dvalue\u201d:\u201dxxx1\u2033},{\u201cattr\u201d:\u201dattr2\u2033,\u201dvalue\u201d:\u201dxxx2\u2033}, \u2026]}<\/p>\n nRet, strRetInfo = mobox.getInputParameter(strLuaDEID)<\/p>\n if (nRet ~= 0 or strRetInfo == ” ) then<\/p>\n mobox.error(strLuaDEID, “\u65e0\u6cd5\u83b7\u53d6\u5bfc\u5165\u6570\u636e!”..strRetInfo)<\/p>\n return<\/p>\n end<\/p>\n local n, nCount, nValue<\/p>\n local strAddAttr = ”<\/p>\n local strAttr = ”<\/p>\n local strSetSQL = ”<\/p>\n — \u4e00\u4e9b\u5173\u952e\u5c5e\u6027 \uff08\u811a\u672c \u540e\u671f\u53ea\u9700\u8981\u6539\u5b57\u6bb5\u540d\u79f0\u5c31\u53ef\u4ee5\uff09<\/p>\n local nSN\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0— \u5bf9\u5e94 \u5e8f\u53f7 N_SN<\/p>\n local strItemName = ”\u00a0 \u00a0 \u00a0 \u00a0 — \u5bf9\u5e94 \u540d\u79f0 S_ITEM_NAME<\/p>\n local strItemMSN = ”\u00a0 \u00a0 \u00a0 \u00a0 \u00a0— \u5bf9\u5e94 \u578b\u53f7_\u89c4\u683c_\u6570\u91cf S_ITEM_M_S_N<\/p>\n local strItemCode = ”\u00a0 \u00a0 \u00a0 \u00a0 \u00a0— \u5bf9\u5e94 \u7f16\u53f7 S_ITEM_CODE<\/p>\n local strFacturer = ”\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 — \u5bf9\u5e94 \u751f\u4ea7\u5355\u4f4d S_MANUFACTURER<\/p>\n <\/p>\n — \u56e0\u4e3a\u6bcf\u6b21\u5bfc\u5165\u53ea\u4f20\u4e00\u6761\u8bb0\u5f55\uff0c\u6240\u4ee5\u5f53\u524d\u6761\u5199\u5165 prj_id \u53ca task_id<\/p>\n strAddAttr = strAddAttr .. ‘{“attr”:”G_TASK_ID”,”value”:”‘ .. strTaskID .. ‘”},’<\/p>\n strAddAttr = strAddAttr .. ‘{“attr”:”G_PRJ_ID”,”value”:”‘ .. strPrjID .. ‘”},’<\/p>\n local retJson =json.decode(strRetInfo)<\/p>\n local input_rows =retJson[“parameter”]<\/p>\n — \u6b65\u9aa41 \u83b7\u53d6\u4eceexcel\u5bfc\u5165\u7684\u4e00\u884c\u6570\u636e\uff0c\u6839\u636eexcel\u7684\u5217\u5b9a\u4e49\u8fdb\u884c\u5c5e\u6027\u7ec4\u5408 strAddAttr<\/p>\n nCount = #input_rows<\/p>\n for n = 1, nCount do<\/p>\n strAttr = input_rows[n].attr<\/p>\n strValue = input_rows[n].value<\/p>\n — \u6839\u636e\u5bfc\u5165\u7684excel\u5217\u5934\u540d\u79f0\u8fdb\u884c\u5224\u65ad<\/p>\n — \u5173\u952e\u5c5e\u6027\u5224\u65ad<\/p>\n if (strAttr == “\u540d\u79f0”) then<\/p>\n if (strValue == ”) then<\/p>\n mobox.error(strLuaDEID, strAttr .. “\u4e0d\u80fd\u4e3a\u7a7a!”)<\/p>\n return<\/p>\n end<\/p>\n strItemName = strValue <\/p>\n — \u5e38\u89c4\u5c5e\u6027<\/p>\n elseif (strAttr == “\u5e8f\u53f7”) then<\/p>\n nSN = strValue elseif (strAttr == “\u578b\u53f7_\u89c4\u683c_\u6570\u91cf”) then<\/p>\n strItemMSN = strValue elseif (strAttr == “\u7f16 \u53f7”) then<\/p>\n strItemCode= strValue elseif (strAttr == “\u751f\u4ea7\u5382\u5bb6”) then<\/p>\n strFacturer = strValue end<\/p>\n end — \u6b65\u9aa42 \u6839\u636e \uff08\u540d\u79f0+\u7f16\u53f7+taskid\uff09 \u6765\u5224\u65ad\u5bfc\u5165\u7684\u68c0\u6d4b\u6570\u636e\u662f\u5426\u5df2\u7ecf\u5b58\u5728 mobox.error(strLuaDEID, “\u5728\u68c0\u67e5\u6837\u54c1\u6280\u672f\u53c2\u6570\u662f\u5426\u5b58\u5728\u65f6\u5931\u8d25! ” .. strRetInfo)<\/p>\n return if (strRetInfo == ‘yes’) then<\/p>\n — \u5df2\u7ecf\u5b58\u5728\uff0c\u6839\u636e\u5bfc\u5165\u7684\u6570\u636e\u8fdb\u884c\u8986\u76d6<\/p>\n strCondition = “S_ITEM_NAME='” .. strItemName .. “‘ and G_TASK_ID='”..strTaskID..”‘ and S_ITEM_CODE='” .. strItemCode.. “‘”<\/p>\n strSetSQL = “N_SN='” ..nSN.. “‘, S_ITEM_NAME = ‘” .. strItemName ..”‘ , S_ITEM_CODE ='” ..strItemCode .. “‘ , S_ITEM_M_S_N = ‘” .. strItemMSN ..”‘ “<\/p>\n nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, “\u6837\u54c1\u6280\u672f\u53c2\u6570”, strCondition, strSetSQL)<\/p>\n if (nRet ~= 0) then<\/p>\n mobox.error(strLuaDEID, strRetInfo)<\/p>\n return<\/p>\n end<\/p>\n elseif (strRetInfo == ‘no’) then<\/p>\n — \u521b\u5efa \u6837\u54c1\u6280\u672f\u53c2\u6570<\/p>\n — mobox.writeSysLog(“strAddAttr1”, strAddAttr1)<\/p>\n strAddAttr1 = ‘[‘ .. strAddAttr1 .. ‘]’<\/p>\n mobox.writeSysLog(“strAddAttr2”, strAddAttr1)<\/p>\n nRet, strRetInfo = mobox.createDataObj(strLuaDEID, “\u6837\u54c1\u6280\u672f\u53c2\u6570”, strAddAttr1)<\/p>\n if (nRet ~= 0) then<\/p>\n mobox.error(strLuaDEID, “\u521b\u5efa\u6837\u54c1\u6280\u672f\u53c2\u6570\u5931\u8d25! ” .. strRetInfo )<\/p>\n return end <\/p><\/blockquote>\n Gungho\u4efb\u52a1\u4e8c\u6b21\u5f00\u53d1-\u4efb\u52a1\u5206\u7c7b\u96c6\u62103000\u529f\u80fd\u7684\u6e05\u5355\u5bfc\u5165 \u8fd9\u4e2a\u662f\u4e00\u4e2a\u6807\u51c6\u7684\u5bfc\u5165\u6a21\u677f \uff0c\u4f7f\u7528\u524d\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539 […]<\/p>\n","protected":false},"author":1,"featured_media":1818,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,5],"tags":[13,14],"class_list":["post-2176","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-eckf","category-plmcenter","tag-shouche","tag-jiaoben"],"_links":{"self":[{"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/posts\/2176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/comments?post=2176"}],"version-history":[{"count":4,"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/posts\/2176\/revisions"}],"predecessor-version":[{"id":2180,"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/posts\/2176\/revisions\/2180"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/media\/1818"}],"wp:attachment":[{"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/media?parent=2176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/categories?post=2176"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/tags?post=2176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
\nstrAddAttr = strAddAttr .. ‘{“attr”:”S_ITEM_NAME”,”value”:”‘ .. strItemName .. ‘”},’<\/p>\n
\nstrAddAttr = strAddAttr .. ‘{“attr”:”N_SN”,”value”:”‘ .. nSN .. ‘”},’<\/p>\n
\nstrAddAttr = strAddAttr .. ‘{“attr”:”S_ITEM_M_S_N”,”value”:”‘ .. strItemMSN .. ‘”},’<\/p>\n
\nstrAddAttr = strAddAttr .. ‘{“attr”:”S_ITEM_CODE”,”value”:”‘ .. strItemCode .. ‘”},’<\/p>\n
\nstrAddAttr = strAddAttr .. ‘{“attr”:”S_MANUFACTURER”,”value”:”‘ .. strFacturer .. ‘”},’<\/p>\n
\n–\u53bb\u9664\u6700\u540e\u4e00\u4e2a\uff0c
\nlocal strAddAttr1 = trim_laster_char(strAddAttr)<\/p>\n
\n— \u5982\u679c\u5df2\u7ecf\u5b58\u5728\uff0c\u6839\u636e\u5bfc\u5165\u7684\u6570\u636e\u8fdb\u884c\u8986\u76d6
\n— \u5982\u679c\u4e0d\u5b58\u5728\u9700\u8981\u521b\u5efa
\nlocal attrs
\nlocal strCondition = “S_ITEM_NAME='” .. strItemName .. “‘ and G_TASK_ID='”..strTaskID..”‘ and S_ITEM_CODE='” .. strItemCode.. “‘”
\nnRet, strRetInfo = mobox.existThisData(strLuaDEID, “\u6837\u54c1\u6280\u672f\u53c2\u6570”, strCondition)
\nif (nRet ~= 0 ) then<\/p>\n
\nend<\/p>\n
\nend<\/p>\n
\nend<\/p>\nfunction<\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"