Commit 52661c2cb3c0a18465f3cf62ff2958a391160899
Merge branch 'fix/service-command-issue' into 'main_dev'
fix: 修复服务命令下发同步异步方式&&过滤只读输入参数 See merge request yunteng/thingskit-scada!84
Showing
2 changed files
with
37 additions
and
21 deletions
@@ -5336,7 +5336,6 @@ App.prototype.save = function (name, done) { | @@ -5336,7 +5336,6 @@ App.prototype.save = function (name, done) { | ||
5336 | file.saveAs(name, success, error) | 5336 | file.saveAs(name, success, error) |
5337 | } | 5337 | } |
5338 | 5338 | ||
5339 | - console.log('file', file) | ||
5340 | } catch (err) { | 5339 | } catch (err) { |
5341 | error(err); | 5340 | error(err); |
5342 | } | 5341 | } |
@@ -7537,7 +7537,12 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7537,7 +7537,12 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7537 | /** | 7537 | /** |
7538 | * @description 标识符号 | 7538 | * @description 标识符号 |
7539 | */ | 7539 | */ |
7540 | - IDENTIFIER: 'identifier' | 7540 | + IDENTIFIER: 'identifier', |
7541 | + | ||
7542 | + /** | ||
7543 | + * @description 服务调用方式 | ||
7544 | + */ | ||
7545 | + CALL_TYPE: 'callType' | ||
7541 | } | 7546 | } |
7542 | 7547 | ||
7543 | /** | 7548 | /** |
@@ -7656,6 +7661,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7656,6 +7661,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7656 | [enumGetValue[content.type]]: content.value, | 7661 | [enumGetValue[content.type]]: content.value, |
7657 | 7662 | ||
7658 | // 参数设置 | 7663 | // 参数设置 |
7664 | + [enumConst.CALL_TYPE]: content[enumConst.CALL_TYPE], | ||
7659 | [enumConst.IDENTIFIER]: content[enumConst.IDENTIFIER], | 7665 | [enumConst.IDENTIFIER]: content[enumConst.IDENTIFIER], |
7660 | [enumConst.JSON_COMMAND]: content[enumConst.JSON_COMMAND], | 7666 | [enumConst.JSON_COMMAND]: content[enumConst.JSON_COMMAND], |
7661 | [enumConst.WAY]: content[enumConst.WAY] || enumWayType.ONE_WAY, | 7667 | [enumConst.WAY]: content[enumConst.WAY] || enumWayType.ONE_WAY, |
@@ -7711,10 +7717,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7711,10 +7717,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7711 | $(`#${enumActionEl.LINK_EL_ID}`).css({ display: 'none' }) | 7717 | $(`#${enumActionEl.LINK_EL_ID}`).css({ display: 'none' }) |
7712 | $(`#${enumActionEl.PAGE_EL_ID}`).css({ display: 'none' }) | 7718 | $(`#${enumActionEl.PAGE_EL_ID}`).css({ display: 'none' }) |
7713 | // $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: 'flex' }) | 7719 | // $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: 'flex' }) |
7714 | - $(`#${enumActionEl.WAY_SELECT}`).css({ display: 'block' }) | ||
7715 | $(`#${enumActionEl.COMMAND_TYPE_EL}`).css({ display: 'block' }) | 7720 | $(`#${enumActionEl.COMMAND_TYPE_EL}`).css({ display: 'block' }) |
7716 | 7721 | ||
7717 | $(`#${enumActionEl.INPUT_DATA_FORM}`).css({ display: isCustom ? 'none' : 'block' }) | 7722 | $(`#${enumActionEl.INPUT_DATA_FORM}`).css({ display: isCustom ? 'none' : 'block' }) |
7723 | + $(`#${enumActionEl.WAY_SELECT}`).css({ display: isCustom ? 'block' : 'none' }) | ||
7718 | $(`#${enumActionEl.SERVICE_EL}`).css({ display: isCustom ? 'none' : 'block' }) | 7724 | $(`#${enumActionEl.SERVICE_EL}`).css({ display: isCustom ? 'none' : 'block' }) |
7719 | $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: isTCP && isCustom ? 'block' : 'none' }) | 7725 | $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: isTCP && isCustom ? 'block' : 'none' }) |
7720 | $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: !isTCP && isCustom ? 'flex' : 'none' }) | 7726 | $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: !isTCP && isCustom ? 'flex' : 'none' }) |
@@ -7787,6 +7793,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7787,6 +7793,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7787 | type: formVal[enumConst.ACTION], | 7793 | type: formVal[enumConst.ACTION], |
7788 | value: formVal[enumGetValue[formVal[enumConst.ACTION]]], | 7794 | value: formVal[enumGetValue[formVal[enumConst.ACTION]]], |
7789 | ...(isParamsSetting ? { | 7795 | ...(isParamsSetting ? { |
7796 | + [enumConst.CALL_TYPE]: formVal[enumConst.CALL_TYPE], | ||
7790 | [enumConst.IDENTIFIER]: formVal[enumConst.IDENTIFIER], | 7797 | [enumConst.IDENTIFIER]: formVal[enumConst.IDENTIFIER], |
7791 | [enumConst.JSON_COMMAND]: formVal[enumConst.JSON_COMMAND], | 7798 | [enumConst.JSON_COMMAND]: formVal[enumConst.JSON_COMMAND], |
7792 | [enumConst.WAY]: formVal[enumConst.WAY], | 7799 | [enumConst.WAY]: formVal[enumConst.WAY], |
@@ -7871,6 +7878,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7871,6 +7878,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7871 | const flag = value === COMMAND_TYPE_ENUM.CUSTOM | 7878 | const flag = value === COMMAND_TYPE_ENUM.CUSTOM |
7872 | const isTCPTransportType = transportType === 'TCP' | 7879 | const isTCPTransportType = transportType === 'TCP' |
7873 | $(`#${enumActionEl.INPUT_DATA_FORM}`).css({ display: flag ? 'none' : 'block' }) | 7880 | $(`#${enumActionEl.INPUT_DATA_FORM}`).css({ display: flag ? 'none' : 'block' }) |
7881 | + $(`#${enumActionEl.WAY_SELECT}`).css({ display: flag ? 'block' : 'none' }) | ||
7874 | $(`#${enumActionEl.SERVICE_EL}`).css({ display: flag ? 'none' : 'block' }) | 7882 | $(`#${enumActionEl.SERVICE_EL}`).css({ display: flag ? 'none' : 'block' }) |
7875 | $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: isTCPTransportType && flag ? 'block' : 'none' }) | 7883 | $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: isTCPTransportType && flag ? 'block' : 'none' }) |
7876 | $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: !isTCPTransportType && flag ? 'flex' : 'none' }) | 7884 | $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: !isTCPTransportType && flag ? 'flex' : 'none' }) |
@@ -7893,7 +7901,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7893,7 +7901,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7893 | } else { | 7901 | } else { |
7894 | form.val(enumActionEl.FORM_FILTER, { [enumConst.SERVICE_COMMAND]: needRender.functionJson?.inputData?.[0]?.serviceCommand || '' }) | 7902 | form.val(enumActionEl.FORM_FILTER, { [enumConst.SERVICE_COMMAND]: needRender.functionJson?.inputData?.[0]?.serviceCommand || '' }) |
7895 | } | 7903 | } |
7896 | - form.val(enumActionEl.FORM_FILTER, { [enumConst.SERVICE_ORIGINAL_CONFIGURATION]: JSON.stringify(needRender.functionJson?.inputData || []), [enumConst.IDENTIFIER]: needRender?.identifier }) | 7904 | + form.val(enumActionEl.FORM_FILTER, { [enumConst.SERVICE_ORIGINAL_CONFIGURATION]: JSON.stringify(needRender.functionJson?.inputData || []), [enumConst.IDENTIFIER]: needRender?.identifier, [enumConst.CALL_TYPE]: needRender?.callType }) |
7897 | }) | 7905 | }) |
7898 | 7906 | ||
7899 | try { | 7907 | try { |
@@ -8009,14 +8017,6 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -8009,14 +8017,6 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
8009 | </select> | 8017 | </select> |
8010 | </div> | 8018 | </div> |
8011 | </div> | 8019 | </div> |
8012 | - <div class="layui-form-item" id="${enumActionEl.WAY_SELECT}" style="display:none;"> | ||
8013 | - <label class="layui-form-label" style="width: 120px;">单向/双向 ${createHelpMessage(`单向:服务器向网关设备、直连设备发送指令。发送指令后,设备不会返回任何信息。\n | ||
8014 | - 双向:服务器向网关设备、直连设备发送指令。发送指令后,设备返回响应信息。`, 'way')}</label> | ||
8015 | - <div class="layui-input-block" style="margin-left: 150px;"> | ||
8016 | - <input type="radio" name="${enumConst.WAY}" value="${enumWayType.ONE_WAY}" title="单向" checked> | ||
8017 | - <input type="radio" name="${enumConst.WAY}" value="${enumWayType.TWO_WAY}" title="双向"> | ||
8018 | - </div> | ||
8019 | - </div> | ||
8020 | <div id="${enumActionEl.COMMAND_TYPE_EL}" class="layui-form-item" style="display: none;"> | 8020 | <div id="${enumActionEl.COMMAND_TYPE_EL}" class="layui-form-item" style="display: none;"> |
8021 | <label class="layui-form-label" style="width: 120px;">命令下发方式</label> | 8021 | <label class="layui-form-label" style="width: 120px;">命令下发方式</label> |
8022 | <div class="layui-input-block" style="margin-left: 150px;"> | 8022 | <div class="layui-input-block" style="margin-left: 150px;"> |
@@ -8025,6 +8025,14 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -8025,6 +8025,14 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
8025 | </select> | 8025 | </select> |
8026 | </div> | 8026 | </div> |
8027 | </div> | 8027 | </div> |
8028 | + <div class="layui-form-item" id="${enumActionEl.WAY_SELECT}" style="display:none;"> | ||
8029 | + <label class="layui-form-label" style="width: 120px;">单向/双向 ${createHelpMessage(`单向:服务器向网关设备、直连设备发送指令。发送指令后,设备不会返回任何信息。\n | ||
8030 | + 双向:服务器向网关设备、直连设备发送指令。发送指令后,设备返回响应信息。`, 'way')}</label> | ||
8031 | + <div class="layui-input-block" style="margin-left: 150px;"> | ||
8032 | + <input type="radio" name="${enumConst.WAY}" value="${enumWayType.ONE_WAY}" title="单向" checked> | ||
8033 | + <input type="radio" name="${enumConst.WAY}" value="${enumWayType.TWO_WAY}" title="双向"> | ||
8034 | + </div> | ||
8035 | + </div> | ||
8028 | <div class="layui-form-item" id="${enumActionEl.SERVICE_EL}" style="display: none;"> | 8036 | <div class="layui-form-item" id="${enumActionEl.SERVICE_EL}" style="display: none;"> |
8029 | <label class="layui-form-label" style="width: 120px;">服务</label> | 8037 | <label class="layui-form-label" style="width: 120px;">服务</label> |
8030 | <div class="layui-input-block" style="margin-left: 150px;"> | 8038 | <div class="layui-input-block" style="margin-left: 150px;"> |
@@ -8036,6 +8044,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -8036,6 +8044,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
8036 | <input type="text" name="${enumConst.IDENTIFIER}" placeholder="标识符" /> | 8044 | <input type="text" name="${enumConst.IDENTIFIER}" placeholder="标识符" /> |
8037 | </div> | 8045 | </div> |
8038 | <div style="display: none;"> | 8046 | <div style="display: none;"> |
8047 | + <input type="text" name="${enumConst.CALL_TYPE}" placeholder="服务调用方式" /> | ||
8048 | + </div> | ||
8049 | + <div style="display: none;"> | ||
8039 | <input type="text" name="${enumConst.SERVICE_COMMAND}" placeholder="服务命令" /> | 8050 | <input type="text" name="${enumConst.SERVICE_COMMAND}" placeholder="服务命令" /> |
8040 | </div> | 8051 | </div> |
8041 | <div style="display: none;"> | 8052 | <div style="display: none;"> |
@@ -13201,7 +13212,7 @@ class UseLayUi { | @@ -13201,7 +13212,7 @@ class UseLayUi { | ||
13201 | /** | 13212 | /** |
13202 | * | 13213 | * |
13203 | * @param {{ | 13214 | * @param {{ |
13204 | - * accessMode: 'r' | 'w', | 13215 | + * accessMode: 'r' | 'rw', |
13205 | * functionName: string, | 13216 | * functionName: string, |
13206 | * id: string, | 13217 | * id: string, |
13207 | * identifier: string, | 13218 | * identifier: string, |
@@ -13217,11 +13228,12 @@ class UseLayUi { | @@ -13217,11 +13228,12 @@ class UseLayUi { | ||
13217 | */ | 13228 | */ |
13218 | static genThingsModelInputDataForm(inputData, labelWidth = 80, formFilter = 'inputDataFilter') { | 13229 | static genThingsModelInputDataForm(inputData, labelWidth = 80, formFilter = 'inputDataFilter') { |
13219 | const list = [] | 13230 | const list = [] |
13220 | - inputData.forEach(item => { | ||
13221 | - const { identifier, functionName, dataType = {} } = item | 13231 | + for (const item of inputData) { |
13232 | + const { identifier, functionName, dataType = {}, accessMode } = item | ||
13233 | + if (accessMode === 'r') continue | ||
13222 | const { type } = dataType | 13234 | const { type } = dataType |
13223 | list.push(UseLayUi.createInputTemplate({ label: functionName, value: identifier, labelWidth, type })) | 13235 | list.push(UseLayUi.createInputTemplate({ label: functionName, value: identifier, labelWidth, type })) |
13224 | - }) | 13236 | + } |
13225 | const template = ` | 13237 | const template = ` |
13226 | <form class="layui-form" action="" lay-filter="${formFilter}"> | 13238 | <form class="layui-form" action="" lay-filter="${formFilter}"> |
13227 | ${list.join('')} | 13239 | ${list.join('')} |
@@ -13252,9 +13264,10 @@ class UseLayUi { | @@ -13252,9 +13264,10 @@ class UseLayUi { | ||
13252 | } | 13264 | } |
13253 | 13265 | ||
13254 | const validate = (item) => { | 13266 | const validate = (item) => { |
13255 | - const { dataType, identifier, functionName } = item | 13267 | + const { dataType, identifier, functionName, accessMode } = item |
13256 | const { type } = dataType || {} | 13268 | const { type } = dataType || {} |
13257 | const identifierValue = value[identifier] | 13269 | const identifierValue = value[identifier] |
13270 | + if (accessMode === 'r') return true | ||
13258 | switch (type) { | 13271 | switch (type) { |
13259 | case UseLayUi.thingsModelType.INT: | 13272 | case UseLayUi.thingsModelType.INT: |
13260 | if (isNaN(identifierValue)) return error(`${functionName}字段需要一个数字`) | 13273 | if (isNaN(identifierValue)) return error(`${functionName}字段需要一个数字`) |
@@ -15906,7 +15919,7 @@ class HandleDataInteraction { | @@ -15906,7 +15919,7 @@ class HandleDataInteraction { | ||
15906 | 15919 | ||
15907 | let flag = false | 15920 | let flag = false |
15908 | let value | 15921 | let value |
15909 | - | 15922 | + |
15910 | if (isCustom) { | 15923 | if (isCustom) { |
15911 | if (isTCP) { | 15924 | if (isTCP) { |
15912 | value = content.tcpCommand | 15925 | value = content.tcpCommand |
@@ -16028,20 +16041,24 @@ class HandleDataInteraction { | @@ -16028,20 +16041,24 @@ class HandleDataInteraction { | ||
16028 | 16041 | ||
16029 | async function defaultHandler(value, callback) { | 16042 | async function defaultHandler(value, callback) { |
16030 | let { deviceId, attr } = contentData.dataSources.find(item => item.nodeId === nodeId) || {} | 16043 | let { deviceId, attr } = contentData.dataSources.find(item => item.nodeId === nodeId) || {} |
16031 | - | 16044 | + console.log(content) |
16032 | /** | 16045 | /** |
16033 | * @type {command: string , commandType: string, service: string, wary: string, tcpCommand: string} | 16046 | * @type {command: string , commandType: string, service: string, wary: string, tcpCommand: string} |
16034 | */ | 16047 | */ |
16035 | - let { command, way, tcpCommand } = content | 16048 | + let { command, way, service, callType } = content |
16036 | const identifier = content?.identifier | 16049 | const identifier = content?.identifier |
16037 | const params = content?.transportType === 'TCP' | 16050 | const params = content?.transportType === 'TCP' |
16038 | ? value | 16051 | ? value |
16039 | : identifier | 16052 | : identifier |
16040 | ? { [identifier]: value } | 16053 | ? { [identifier]: value } |
16041 | : value | 16054 | : value |
16055 | + | ||
16056 | + if (service) { | ||
16057 | + way = callType === 'ASYNC' ? 'twoway' : 'oneway' | ||
16058 | + } | ||
16042 | const instructionData = { | 16059 | const instructionData = { |
16043 | method: "methodThingskit", | 16060 | method: "methodThingskit", |
16044 | - additionalInfo: { cmdType: 'API' }, | 16061 | + additionalInfo: { cmdType: service ? '1' : 'API' }, |
16045 | persistent: true, | 16062 | persistent: true, |
16046 | params, | 16063 | params, |
16047 | } | 16064 | } |