#
Junjie
4 天以前 6c520b6fefa96176fee458e5a656a94d1cd3dc3f
src/main/webapp/static/js/stationPathPolicy/stationPathPolicy.js
@@ -11,8 +11,16 @@
        s1MaxLenRatio: 1.15,
        s1MaxTurnDiff: 1,
        s2BusyWeight: 2.0,
        s2QueueWeight: 2.5,
        s2WaitWeight: 1.5,
        s2DeadlockWeight: 8.0,
        s2RunBlockWeight: 10.0,
        s2LoopLoadWeight: 12.0
        s2LoopLoadWeight: 12.0,
        circleMaxLoadLimit: 80.0,
        stationPathLenWeightPercent: 50,
        stationPathCongWeightPercent: 50,
        stationPathPassOtherOutStationWeightPercent: 100,
        stationPathPassOtherOutStationForceSkip: false
    }
}
@@ -72,7 +80,7 @@
        return {
            loading: false,
            saving: false,
            scoreMode: 'legacy',
            scoreMode: 'twoStage',
            defaultProfileCode: 'default',
            profiles: [],
            rules: [],
@@ -315,7 +323,7 @@
                        return
                    }
                    var data = res.data || {}
                    that.scoreMode = data.scoreMode || 'legacy'
                    that.scoreMode = data.scoreMode || 'twoStage'
                    that.defaultProfileCode = data.defaultProfileCode || 'default'
                    that.showRuleJson = false
                    that.showAllPathTags = false
@@ -361,8 +369,18 @@
                this.$message.warning('默认模板编码没有对应模板')
                return
            }
            var defaultProfile = null
            for (var i = 0; i < this.profiles.length; i++) {
                if (this.profiles[i].profileCode === this.defaultProfileCode) {
                    defaultProfile = this.profiles[i]
                    break
                }
            }
            if (!defaultProfile || Number(defaultProfile.status) !== 1) {
                this.$message.warning('默认模板必须启用')
                return
            }
            var payload = {
                scoreMode: this.scoreMode,
                defaultProfileCode: this.defaultProfileCode,
                profiles: this.profiles.map(this.sanitizeProfileForSave),
                rules: this.rules.map(this.sanitizeRuleForSave)
@@ -769,7 +787,7 @@
            var scaleX = usableWidth / contentWidth
            var scaleY = usableHeight / contentHeight
            var scale = Math.min(scaleX, scaleY, 1.7)
            var zoomPercent = Math.max(60, Math.min(220, Math.floor(scale * 100)))
            var zoomPercent = Math.max(1, Math.min(220, Math.floor(scale * 100)))
            var centerX = (bounds.minX + bounds.maxX) / 2
            var centerY = (bounds.minY + bounds.maxY) / 2
            this.mapZoomPercent = zoomPercent
@@ -815,7 +833,7 @@
            if (zoomPercent == null) {
                return
            }
            zoomPercent = Math.max(60, Math.min(220, zoomPercent))
            zoomPercent = Math.max(1, Math.min(220, zoomPercent))
            if (!wrap || !this.mapContext.width || !this.mapContext.height) {
                this.mapZoomPercent = zoomPercent
                return
@@ -844,19 +862,18 @@
            if (!this.mapContext.nodes.length) {
                return
            }
            if (event.ctrlKey || event.metaKey) {
                var wrap = this.$refs.mapCanvasWrap
                if (!wrap) {
                    return
                }
                var rect = wrap.getBoundingClientRect()
                var delta = event.deltaY < 0 ? 10 : -10
                var nextPercent = Math.max(60, Math.min(220, this.mapZoomPercent + delta))
                this.setMapZoomAroundPoint(nextPercent, event.clientX - rect.left, event.clientY - rect.top)
            var wrap = this.$refs.mapCanvasWrap
            if (!wrap) {
                return
            }
            this.mapPanX -= event.deltaX
            this.mapPanY -= event.deltaY
            var wheelDelta = Math.abs(event.deltaY) >= Math.abs(event.deltaX) ? event.deltaY : event.deltaX
            if (!wheelDelta) {
                return
            }
            var rect = wrap.getBoundingClientRect()
            var delta = wheelDelta < 0 ? 10 : -10
            var nextPercent = Math.max(1, Math.min(220, this.mapZoomPercent + delta))
            this.setMapZoomAroundPoint(nextPercent, event.clientX - rect.left, event.clientY - rect.top)
        },
        beginMapDrag: function (event) {
            var wrap = this.$refs.mapCanvasWrap
@@ -1140,6 +1157,15 @@
        },
        normalizeProfile: function (raw) {
            var config = Object.assign({}, this.defaultProfileConfig(), this.parseJson(raw.configJson) || raw.config || {})
            config.circleMaxLoadLimit = this.toNumberSafe(config.circleMaxLoadLimit)
            config.stationPathLenWeightPercent = this.toNumberSafe(config.stationPathLenWeightPercent)
            config.stationPathCongWeightPercent = this.toNumberSafe(config.stationPathCongWeightPercent)
            config.stationPathPassOtherOutStationWeightPercent = this.toNumberSafe(config.stationPathPassOtherOutStationWeightPercent)
            config.circleMaxLoadLimit = config.circleMaxLoadLimit == null ? 80 : config.circleMaxLoadLimit
            config.stationPathLenWeightPercent = config.stationPathLenWeightPercent == null ? 50 : config.stationPathLenWeightPercent
            config.stationPathCongWeightPercent = config.stationPathCongWeightPercent == null ? 50 : config.stationPathCongWeightPercent
            config.stationPathPassOtherOutStationWeightPercent = config.stationPathPassOtherOutStationWeightPercent == null ? 100 : config.stationPathPassOtherOutStationWeightPercent
            config.stationPathPassOtherOutStationForceSkip = !!config.stationPathPassOtherOutStationForceSkip
            return {
                id: raw.id || null,
                profileCode: raw.profileCode || '',
@@ -1185,6 +1211,12 @@
            return JSON.parse(JSON.stringify(model))
        },
        sanitizeProfileForSave: function (item) {
            var config = Object.assign({}, item.config || {})
            config.circleMaxLoadLimit = this.toNumberSafe(config.circleMaxLoadLimit) == null ? 80 : this.toNumberSafe(config.circleMaxLoadLimit)
            config.stationPathLenWeightPercent = this.toNumberSafe(config.stationPathLenWeightPercent) == null ? 50 : this.toNumberSafe(config.stationPathLenWeightPercent)
            config.stationPathCongWeightPercent = this.toNumberSafe(config.stationPathCongWeightPercent) == null ? 50 : this.toNumberSafe(config.stationPathCongWeightPercent)
            config.stationPathPassOtherOutStationWeightPercent = this.toNumberSafe(config.stationPathPassOtherOutStationWeightPercent) == null ? 100 : this.toNumberSafe(config.stationPathPassOtherOutStationWeightPercent)
            config.stationPathPassOtherOutStationForceSkip = !!config.stationPathPassOtherOutStationForceSkip
            return {
                id: item.id || null,
                profileCode: item.profileCode,
@@ -1192,7 +1224,7 @@
                priority: Number(item.priority || 100),
                status: Number(item.status || 0),
                memo: item.memo || '',
                config: Object.assign({}, item.config || {})
                config: config
            }
        },
        sanitizeRuleForSave: function (item) {
@@ -1278,6 +1310,16 @@
            var num = Number(value)
            return isNaN(num) ? null : num
        },
        displayLoadLimitPercent: function (value) {
            var num = this.toNumberSafe(value)
            if (num == null) {
                num = 80
            }
            if (num <= 1) {
                num = num * 100
            }
            return num.toFixed(1) + '%'
        },
        notNull: function (value) {
            return value != null
        },