Commit 1158d70681967fb3cb9b193feb0cd1a4b25ff39f
Merge branch 'fix/DEFECT-1491' into 'main_dev'
fix: 修复服务命令中bool类型的值未进行校验 See merge request yunteng/thingskit-scada!117
Showing
1 changed file
with
6 additions
and
1 deletions
... | ... | @@ -13581,6 +13581,10 @@ class UseLayUi { |
13581 | 13581 | if (identifierValue && !Utils.stringIsJSON(identifierValue)) return error(`${functionName}字段需要一个JSON对象`) |
13582 | 13582 | needFormat && (value[identifier] = Utils.stringToJSON(identifierValue)) |
13583 | 13583 | break |
13584 | + case UseLayUi.thingsModelType.BOOL: | |
13585 | + if (identifierValue && (identifierValue != 0 && identifierValue != 1)) return error(`${functionName}字段只能为1或0`) | |
13586 | + needFormat && (value[identifier] = Number(identifierValue)) | |
13587 | + break | |
13584 | 13588 | default: |
13585 | 13589 | break |
13586 | 13590 | } |
... | ... | @@ -13601,6 +13605,7 @@ class UseLayUi { |
13601 | 13605 | INT: 'INT', |
13602 | 13606 | DOUBLE: 'DOUBLE', |
13603 | 13607 | STRUCT: 'STRUCT', |
13608 | + BOOL: 'BOOL' | |
13604 | 13609 | } |
13605 | 13610 | |
13606 | 13611 | /** |
... | ... | @@ -16295,7 +16300,7 @@ class HandleDataInteraction { |
16295 | 16300 | ...(method == '06' ? [{ value, message: `下发类型必须为整型,缩放因子为${zoomFactor}`, validator(value) { return !isNaN(value) && getNumberFloatPart(Number(value)) * zoomFactor % 1 === 0 } }, { value: Number(value) * zoomFactor, message: `最大值不能超过65535,缩放因子为${zoomFactor}`, validator(value) { return Number(value) <= parseInt('ffff', 16) } }] : []), |
16296 | 16301 | ...(method == '16' ? [{ value, message: '下发类型精确到两位小数', validator(value) { return /^-?\d+(\.\d{0,2})?$/.test(Math.floor(Number(value)) * zoomFactor + getNumberFloatPart(Number(value)) * zoomFactor) } }] : []) |
16297 | 16302 | ]) |
16298 | - | |
16303 | + | |
16299 | 16304 | if (method == '06' || method == '16') { |
16300 | 16305 | value = Math.trunc(value) * zoomFactor + getNumberFloatPart(value) * zoomFactor |
16301 | 16306 | } | ... | ... |