日韩欧美一区二区久久-日韩欧美一区二区三区-日韩欧美一区二区三区不卡-日韩欧美一区二区三区不卡视频-日韩欧美一区二区三区不卡在线

產(chǎn)品中心 業(yè)內(nèi)新聞 案例中心 視頻中心

Mobox低代碼平臺- 主類及子類數(shù)據(jù)導入實現(xiàn) Mobox低代碼平臺- 主類及子類數(shù)據(jù)導入實現(xiàn)

Mobox低代碼平臺- 主類及子類數(shù)據(jù)導入實現(xiàn)

我們在巨星工藝系統(tǒng)里面遇到,用戶需要將產(chǎn)品工藝一次性導入的需求

軟件系統(tǒng)架構(gòu)圖:

數(shù)據(jù)對象介紹

產(chǎn)品及工藝導入,我們提供了一個excel模板

定義導入腳本(自定義腳本)

–[[

??? 編碼: CappImport

??? 名稱: 產(chǎn)品及工藝信息導入

??? 作者:whx???

??? 入口函數(shù):ImportCapp

 

??? 功能說明:

??????? 產(chǎn)品及工藝的導入,在導入的時候判斷一下產(chǎn)品是否存在?如果不存在要新創(chuàng)建

??????? 導入格式見《產(chǎn)品-工藝-導入test.xlsx》

??? 變更歷史:

??????? V1.0? whx??? 2023-4-12????? 新建

 

??? 數(shù)據(jù)結(jié)構(gòu)說明

???????? 產(chǎn)品

?????????????????? 工藝1

?????????????????? 工藝2

?????????????????? 工藝…

???????? 其中,有數(shù)據(jù)對象《產(chǎn)品》 子類 《工藝》 (S_GDS_CODE 為關(guān)聯(lián)字段)

???????? 使用前,將2個對象的所有字段 對應的變量都定義一下? 《參考代碼里面的? 產(chǎn)品字段對應變量定義;工藝字段對應變量定義》

–]]

 

json? = require(“json”)

mobox = require(“OILua_JavelinExt”)

require(“oi_basestrfunc”)

 

function ImportCapp(strLuaDEID)

??? local nRet, strRetInfo

? ??— 獲取導入的數(shù)據(jù), 返回 [{“attr”:”xx”,”value”:””},…]

???

??? nRet, strRetInfo = mobox.getInputParameter(strLuaDEID)

??? –mobox.writeSysLog(“nRet”,nRet)

 

??? if (nRet ~= 0 or strRetInfo == ”) then

??????? mobox.error(strLuaDEID, “無法獲取導入數(shù)據(jù)!”)

??????? return

??? end

??? –mobox.writeSysLog(“strRetInfo”,strRetInfo)

??? local retJson = json.decode(strRetInfo)

???

??? local input = retJson[“parameter”]

???

??? local n, nCount, nValue

??? local strAddAttr = ”

 

??? — 產(chǎn)品字段對應變量定義

??? local strGDSCode = ”

 

??? local strGDSName = ”

??? local strGDSClass = ”

??? local strGDSSeries = ”

??? local strGDSSpec = ”

??? local strGDSDescribe = ”

 

??? — 工藝字段對應變量定義

??? local strMPName = ”

??? local strMPCode = ”

??? local strMPDescrive = ”

??? local strN_On = ”

 

??? — 步驟1 獲取從excel導入的一行數(shù)據(jù),根據(jù)excel的產(chǎn)品規(guī)格定義進行屬性組合 strAddAttr

??? nCount = #input

??? for n = 1, nCount do

??????? strAttr = input[n].attr

??????? strValue = input[n].value

??????? if (strAttr ~= ” and strValue ~= ”) then

 

??????????? — 根據(jù)導入的excel產(chǎn)品規(guī)格頭名稱進行判斷

??????????? — 關(guān)鍵屬性判斷

??????????? if (strAttr == “產(chǎn)品編碼”) then

??????????????? if (strValue == ”) then

??????????????????? mobox.error(strLuaDEID, strAttr .. “不能為空!”)

??????????????????? return

??????????????? end

??????????????? strGDSCode = strValue

??????????????? strAddAttr = strAddAttr .. ‘{“attr”:”S_GDS_CODE”,”value”:”‘ .. strGDSCode .. ‘”},’

 

??????????? elseif (strAttr == “產(chǎn)品名稱”) then

??????????????? if (strValue == ”) then

??????????????????? mobox.error(strLuaDEID, strAttr .. “不能為空!”)

??????? ????????????return

??????????????? end

??????????????? strGDSName = strValue

??????????????? strAddAttr = strAddAttr .. ‘{“attr”:”S_GDS_NAME”,”value”:”‘ .. strGDSName .. ‘”},’

 

??????????? elseif (strAttr == “過程名稱”) then

??????????????? if (strValue == ”) then

??????????????????? mobox.error(strLuaDEID, strAttr .. “不能為空!”)

??????????????????? return

??????????????? end

??????????????? strMPName = strValue

??????????????? strAddAttr = strAddAttr .. ‘{“attr”:”S_MP_NAME”,”value”:”‘ .. strMPName .. ‘”},’

???????????????

??????????? elseif (strAttr == “過程編號”) then

??????????????? if (strValue == ”) then

??????????????????? mobox.error(strLuaDEID, strAttr .. “不能為空!”)

??????????????????? return

??????????????? end

??????????????? strMPCode = strValue

????? ??????????strAddAttr = strAddAttr .. ‘{“attr”:”S_MP_CODE”,”value”:”‘ .. strMPCode .. ‘”},’

???????????????

??????????? — 常規(guī)屬性

 

??????????? elseif (strAttr == “產(chǎn)品分類”) then

??????????????? strGDSClass = strValue

??????????????? strAddAttr = strAddAttr .. ‘{“attr”:”S_GDS_CLASS”,”value”:”‘ .. strGDSClass .. ‘”},’

 

??????????? elseif (strAttr == “產(chǎn)品系列”) then

??????????????? strGDSSeries = strValue

??????????????? strAddAttr = strAddAttr .. ‘{“attr”:”S_GDS_SERIES”,”value”:”‘ .. strGDSSeries .. ‘”},’

 

????????? ??elseif (strAttr == “產(chǎn)品規(guī)格”) then

??????????????? strGDSSpec = strValue

??????????????? strAddAttr = strAddAttr .. ‘{“attr”:”S_GDS_SPEC”,”value”:”‘ .. strGDSSpec .. ‘”},’

 

??????????? elseif (strAttr == “產(chǎn)品描述”) then

??????????????? strGDSDescribe = strValue

??????????????? strAddAttr = strAddAttr .. ‘{“attr”:”S_GDS_DESCRIBE”,”value”:”‘ .. strGDSDescribe .. ‘”},’

 

??????????? elseif (strAttr == “序號”) then

??????????????? strN_On = strValue

??????????????? strAddAttr = strAddAttr .. ‘{“attr”:”N_ON”,”value”:”‘ .. strN_On .. ‘”},’

 

??????????? elseif (strAttr == “過程描述”) then

??????????????? strMPDescrive = strValue

??????????????? strAddAttr = strAddAttr .. ‘{“attr”:”S_MP_DESCRIBE”,”value”:”‘ .. strMPDescrive .. ‘”},’

??????????? end

??????? end

 

??? end

??? –去除最后一個,

??? local strAddAttr1 = trim_laster_char(strAddAttr)

 

??? — 步驟2 根據(jù)(產(chǎn)品編碼 + 過程名稱) 來判斷導入的工藝步驟是否已經(jīng)存在

??? —?????? 如果已經(jīng)存在,根據(jù)導入的數(shù)據(jù)進行覆蓋

??? —?????? 如果不存在需要創(chuàng)建

??? local attrs

??? local strCondition = “S_GDS_CODE='” .. strGDSCode .. “‘ and S_MP_NAME = ‘” .. strMPName .. “‘ “

??? nRet, strRetInfo = mobox.existThisData(strLuaDEID, “工藝”, strCondition)

??? if (nRet ~= 0) then

??????? mobox.error(strLuaDEID, “在檢查工藝是否存在時失敗! ” .. strRetInfo)

??? ????return

??? end

 

??? if (strRetInfo == ‘yes’) then

??????? — 已經(jīng)存在,根據(jù)導入的數(shù)據(jù)進行覆蓋

??????? strCondition = “S_GDS_CODE='” .. strGDSCode .. “‘ and S_MP_NAME = ‘” .. strMPName .. “‘ “

 

??????? strSetSQL = “S_GDS_CODE = ‘” ..strGDSCode ..”‘ , S_MP_DESCRIBE ='” ..strMPDescrive ..

??????????? “‘ , S_MP_NAME = ‘” .. strMPName .. “‘ , S_MP_CODE = ‘” .. strMPCode .. “‘ , N_ON = ‘” .. strN_On ..”‘ “

 

??????? nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, “工藝”, strCondition, strSetSQL)

??????? if (nRet ~= 0) then

??????????? mobox.error(strLuaDEID, strRetInfo)

??????????? return

??????? end

??????? return

 

???? elseif (strRetInfo == ‘no’) then

???? — 新增工藝

???????? attrs = ‘[{“attr”:”S_GDS_CODE”,”value”:”‘ .. strGDSCode .. ‘”},’

???????? .. ‘{“attr”:”S_MP_NAME”,”value”:”‘ .. strMPName .. ‘”},’

???????? .. ‘{“attr”:”N_ON”,”value”:”‘ .. strN_On .. ‘”},’

???????? .. ‘{“attr”:”S_MP_CODE”,”value”:”‘ .. strMPCode .. ‘”},’

???????? .. ‘{“attr”:”S_MP_DESCRIBE”,”value”:”‘ ..? strMPDescrive .. ‘”}]’

 

??? — mobox.writeSysLog(“attrs”,attrs)

???

???????? nRet, strRetInfo = mobox.createDataObj(strLuaDEID, “工藝”, attrs)

???????? if (nRet ~= 0) then

?????????????????? mobox.error(strLuaDEID, “創(chuàng)建工藝失敗! ” .. strRetInfo)

?????????????????? return

???????? end

 

???????? ?— 導入的工藝不存在的時候,就需要判斷一下 產(chǎn)品是否存在

???????? — 如果不存在需要創(chuàng)建

???????? — 判斷產(chǎn)品是否存在

???????? strCondition = “S_GDS_CODE='” .. strGDSCode .. “‘”

???????? nRet, strRetInfo = mobox.existThisData(strLuaDEID, “產(chǎn)品”, strCondition)

???????? if (nRet ~= 0) then

?????????????????? mobox.error(strLuaDEID, “在檢查產(chǎn)品是否存在時失敗! ” .. strRetInfo)

?????????????????? return

???????? end

 

???????? if (strRetInfo == ‘no’) then

???????? — 新增產(chǎn)品

 

?????????????????? attrs = ‘[{“attr”:”S_GDS_CODE”,”value”:”‘ .. strGDSCode .. ‘”},’

?????????????????? .. ‘{“attr”:”S_GDS_NAME”,”value”:”‘ .. strGDSName .. ‘”},’

?????????????????? .. ‘{“attr”:”S_GDS_CLASS”,”value”:”‘ .. strGDSClass .. ‘”},’

?????????????????? .. ‘{“attr”:”S_GDS_SERIES”,”value”:”‘ .. strGDSSeries .. ‘”},’

?????????????????? .. ‘{“attr”:”S_GDS_SPEC”,”value”:”‘ .. strGDSSpec .. ‘”},’

?????????????????? .. ‘{“attr”:”S_GDS_DESCRIBE”,”value”:”‘ .. strGDSDescribe .. ‘”}]’

 

?????????????????? –mobox.writeSysLog(“attrs”,attrs)

?????????????????? nRet, strRetInfo = mobox.createDataObj(strLuaDEID, “產(chǎn)品”, attrs)

?????????????????? if (nRet ~= 0) then

??????????????????????????? mobox.error(strLuaDEID, “創(chuàng)建產(chǎn)品失敗! ” .. strRetInfo)

??????????????????????????? return

?????????????????? end

?? ? end

 

??? end

 

end

定義導入命令

設置導入命令的相關(guān)參數(shù)

 

我們可以通過excel批量導入企業(yè)的工藝信息

標簽:方案腳本 上一篇: 下一篇:
展開更多
預約軟件體驗

loading...

主站蜘蛛池模板: 土耳其毛片 | 麻豆网页| 久久久久综合中文字幕 | 国产精品免费看久久久香蕉 | 成人啪啪www| 亚洲女视频 | 特级aav毛片日本免费视频 | 免费视频一区 | av18在线播放| 成人性生交大片免费看午夜a | 欧美一区二区放荡人妇 | 国内精自视频品线六区免费 | 天天影视欲香欲色成人网 | 黄色的视频在线免费观看 | 国产欧美自拍 | 伊人网综合在线视频 | 国产视频999 | 六月丁香婷婷色狠狠久久 | 午夜精品久久久久 | 中文字幕日韩在线一区国内 | 亚洲久久久久 | 在线观看香蕉免费啪在线观看 | 国产在线爱做人成小视频 | 国产真人毛片一级视频 | 国产精品单位女同事在线 | 成人国产午夜在线视频 | 国产精品久久不卡日韩美女 | 久久视频免费在线观看 | 亚洲 欧美 日韩 另类 | 黄色永久免费网站 | 国产精品亚洲片在线观看麻豆 | 国产高清好大好夹受不了了 | 亚洲黄色毛片 | 免费一级黄色片 | 中国一级特黄真人毛片免费看 | 精品国产美女福到在线不卡f | 黄色草逼视频 | 国产成人综合网在线播放 | 欧美日韩亚洲第一页 | 日韩版码免费福利视频 | 久久久久99精品成人片三人毛片 |