openatc-components 0.1.100 → 0.1.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -117,7 +117,7 @@ export default {
117
117
  }
118
118
  },
119
119
  created () {
120
- this.addMinSplit()
120
+ // this.addMinSplit()
121
121
  // console.log(this.list, 'list')
122
122
  },
123
123
  watch: {
@@ -134,7 +134,7 @@ export default {
134
134
  // let MaxCycle = globalParamModel.getParamsByType('patternList')[n].cycle
135
135
  // let pattern = globalParamModel.getParamsByType('patternList')[n]
136
136
  // globalParamModel.getParamsByType('patternList')[n].cycle = this.getMaxCycle(pattern)
137
- this.addMinSplit()
137
+ // this.addMinSplit()
138
138
  this.$emit('handleSplit', n, newList)
139
139
  },
140
140
  deep: true
@@ -0,0 +1,249 @@
1
+ /**
2
+ * Copyright (c) 2020 kedacom
3
+ * OpenATC is licensed under Mulan PSL v2.
4
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
5
+ * You may obtain a copy of Mulan PSL v2 at:
6
+ * http://license.coscl.org.cn/MulanPSL2
7
+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
8
+ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
9
+ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
10
+ * See the Mulan PSL v2 for more details.
11
+ **/
12
+ <template>
13
+ <div>
14
+ <div v-if="this.nowNumber === 1" class="optimizetype">
15
+ <span>{{$t('openatccomponents.pattern.optimizetype')}}</span>
16
+ <el-select v-model="value" clearable :placeholder="$t('openatccomponents.common.select')">
17
+ <el-option
18
+ v-for="item in typeOptions"
19
+ :key="item.value"
20
+ :label="$t('openatccomponents.overview.type' + item.value)"
21
+ :value="item.value"
22
+ >
23
+ </el-option>
24
+ </el-select>
25
+ <span class="optimiNum">{{$t('openatccomponents.pattern.optimizecycle')}}</span>
26
+ <el-input v-model="optimizecycle" clearable :placeholder="$t('openatccomponents.common.enter')"></el-input>
27
+ <el-button type="primary" @click="optimize()">{{$t('openatccomponents.pattern.inoptimize')}}</el-button>
28
+ </div>
29
+ <div class="common-board-column" :style="{marginTop:this.nowNumber === 1 ? 0 : '50px'}">
30
+ <div class="common-board-column-header">
31
+ {{headerText}}
32
+ </div>
33
+ <div class="common-board-table-header">
34
+ <el-row :gutter="13">
35
+ <el-col :span="4">{{this.$t('openatccomponents.overview.phase')}}
36
+ </el-col>
37
+ <el-col :span="10">{{this.$t('openatccomponents.overview.flow')}}
38
+ </el-col>
39
+ <el-col :span="10">{{this.$t('openatccomponents.overview.saturationflow')}}
40
+ </el-col>
41
+ </el-row>
42
+ </div>
43
+ <draggable
44
+ class="common-board-column-content"
45
+ :list="list"
46
+ :options="options">
47
+ <div class="common-board-item" v-for="element in list" :key="element.id">
48
+ <el-row :gutter="13">
49
+ <el-col :span="4">
50
+ <el-tooltip class="item" effect="dark" placement="left">
51
+ <div slot="content">{{element.name}}</div>
52
+ <div class="common-phase-description">
53
+ <xdrdirselector Width="40px" Height="40px" :Data="showStyle" :showlist="element.desc" :ISActiveMask="ISActiveMask" :MaskColor="MaskColor"></xdrdirselector>
54
+ </div>
55
+ </el-tooltip>
56
+ </el-col>
57
+ <el-col :span="10">
58
+ <el-input-number :controls="false" class="col-content" size="small" :step="1" v-model.number="element.flowperhour" ref="type" :disabled="element.mode === 7"></el-input-number>
59
+ </el-col>
60
+ <el-col :span="10">
61
+ <el-input-number :controls="false" class="col-content" size="small" :step="1" v-model.number="element.saturation" ref="types" :disabled="element.mode === 7"></el-input-number>
62
+ </el-col>
63
+ </el-row>
64
+ </div>
65
+ </draggable>
66
+ </div>
67
+ </div>
68
+ </template>
69
+ <script>
70
+ import draggable from 'vuedraggable'
71
+ import { getDuration } from '../../../api/cross'
72
+ import xdrdirselector from '../XRDDirSelector/XRDDirSelector'
73
+
74
+ export default {
75
+ name: 'patternOptimize',
76
+ components: {
77
+ draggable,
78
+ xdrdirselector
79
+ },
80
+ data () {
81
+ return {
82
+ showStyle: {
83
+ left: '8px',
84
+ top: '3px'
85
+ },
86
+ typeOptions: [{
87
+ value: 'flow-split-opt'
88
+ }, {
89
+ value: 'cycle-opt'
90
+ }],
91
+ value: '',
92
+ optimizecycle: 0
93
+ }
94
+ },
95
+ props: {
96
+ headerText: {
97
+ type: String,
98
+ default: 'Header'
99
+ },
100
+ rings: {
101
+ type: Object
102
+ },
103
+ nowNumber: {
104
+ type: Number
105
+ },
106
+ phaseList: {
107
+ type: Array
108
+ },
109
+ options: {
110
+ type: Object,
111
+ default () {
112
+ return {}
113
+ }
114
+ },
115
+ list: {
116
+ type: Array,
117
+ default () {
118
+ return []
119
+ }
120
+ },
121
+ // index: {
122
+ // type: Number
123
+ // },
124
+ ISActiveMask: {
125
+ type: Boolean,
126
+ default: true
127
+ },
128
+ // 当phase的描述为空时,显示的图形颜色。
129
+ MaskColor: {
130
+ type: String,
131
+ default: '#000000'
132
+ }
133
+ },
134
+ created () {
135
+ // this.addMinSplit()
136
+ this.addMin()
137
+ },
138
+ watch: {
139
+ list: {
140
+ handler: function () {
141
+ this.addMin()
142
+ // let list = this.$refs.type
143
+ // let flow = this.$refs.types
144
+ // console.log(this.list, 'list')
145
+ // let cycle = 0
146
+ // let n = this.index
147
+ // for (let i = 0; i < list.length; i++) {
148
+ // cycle = cycle + Number(list[i].currentValue)
149
+ // }
150
+ // const globalParamModel = this.$store.getters.globalParamModel
151
+ // // let MaxCycle = globalParamModel.getParamsByType('patternList')[n].cycle
152
+ // let pattern = globalParamModel.getParamsByType('patternList')[n]
153
+ // globalParamModel.getParamsByType('patternList')[n].cycle = this.getMaxCycle(pattern)
154
+ // this.addMinSplit()
155
+ // this.$emit('handleSplit', n)
156
+ },
157
+ deep: true
158
+ }
159
+ },
160
+ methods: {
161
+ optimize () {
162
+ let _that = this
163
+ let newPha = []
164
+ for (let i = 0; i < _that.rings.rings.length; i++) {
165
+ newPha.push(..._that.rings.rings[i])
166
+ }
167
+ let phaseData = newPha.map(item => {
168
+ return {
169
+ id: item.id,
170
+ flowperhour: item.flowperhour,
171
+ saturation: item.saturation
172
+ }
173
+ })
174
+ // let patternList = _that.$store.state.globalParam.tscParam.patternList
175
+ // console.log(patternList, 'patternList')
176
+ let pattern = _that.rings
177
+ let reqData = {
178
+ 'type': _that.value,
179
+ 'optcycle': _that.optimizecycle,
180
+ 'phaseList': _that.phaseList,
181
+ 'pattern': pattern,
182
+ 'phases': phaseData
183
+ }
184
+ for (let j = 0; j < newPha.length; j++) {
185
+ let comNum = (newPha[j].length / 4) * 1700 * 0.8
186
+ if (newPha[j].flowperhour > comNum) {
187
+ this.$confirm(this.$t('openatccomponents.overview.maxFlow'),
188
+ this.$t('openatccomponents.common.alarm'), {
189
+ confirmButtonText: this.$t('openatccomponents.common.confirm'),
190
+ cancelButtonText: this.$t('openatccomponents.common.cancel'),
191
+ type: 'warning'
192
+ }).then(() => {
193
+ getDuration(reqData).then(data => {
194
+ if (data.data.success) {
195
+ _that.$message({
196
+ type: 'success',
197
+ message: _that.$t('openatccomponents.pattern.success')
198
+ })
199
+ for (let i = 0; i < _that.rings.rings.length; i++) {
200
+ for (let j = 0; j < _that.rings.rings[i].length; j++) {
201
+ for (let h = 0; h < data.data.data.phase.length; h++) {
202
+ if (_that.rings.rings[i][j].id === data.data.data.phase[h].id) {
203
+ _that.rings.rings[i][j].value = data.data.data.phase[h].duration
204
+ // _that.rings[i][j].cycle = data.data.data.phase[h].cycle
205
+ }
206
+ }
207
+ }
208
+ }
209
+ }
210
+ }).catch(error => {
211
+ console.log(error)
212
+ })
213
+ }).catch(() => {
214
+ })
215
+ }
216
+ }
217
+ },
218
+ addMin () {
219
+ for (let i of this.list) {
220
+ if (!i.flowperhour || !i.saturation) {
221
+ i.flowperhour = 0
222
+ i.saturation = 1700
223
+ i.length = this.list.length
224
+ }
225
+ }
226
+ }
227
+ }
228
+ }
229
+ </script>
230
+ <style lang="scss" scoped>
231
+ .col-content {
232
+ width: 100%;
233
+ }
234
+ .optimizetype{
235
+ margin:0 0 10PX 0;
236
+ .el-input {
237
+ width: 80PX;
238
+ }
239
+ .el-select{
240
+ width: 145PX;
241
+ }
242
+ .el-button {
243
+ margin-left: 10PX;
244
+ }
245
+ .optimiNum {
246
+ padding-left: 10PX;
247
+ }
248
+ }
249
+ </style>
@@ -0,0 +1,2 @@
1
+ import PatternOptimize from './PatternOptimize.vue'
2
+ export default PatternOptimize
@@ -139,6 +139,21 @@
139
139
  </el-col>
140
140
  </el-row>
141
141
  </el-tab-pane>
142
+ <el-tab-pane :label="$t('openatccomponents.pattern.patternOptimize')" name="patternOptimize">
143
+ <pattern-optimize
144
+ v-for="n in optimizes"
145
+ :key="n" class="expendkanban"
146
+ :list="patternOne.length===0?planPattern.rings[n-1]:patternOne[0].rings[n-1]"
147
+ :rings="patternOne.length===0?planPattern:patternOne[0]"
148
+ :phaseList="phaseList"
149
+ :options="options"
150
+ :header-text="$t('openatccomponents.pattern.ring')+n"
151
+ :index="n"
152
+ :nowNumber="n"
153
+ @handleSplit="handleSplit"
154
+ >
155
+ </pattern-optimize>
156
+ </el-tab-pane>
142
157
  </el-tabs>
143
158
  </el-row>
144
159
  <div class="footer" v-if="realtimeStatusModalvisible">
@@ -209,6 +224,8 @@ export default {
209
224
  activeList: 'ring',
210
225
  ringCount: 1,
211
226
  ringCounts: 1,
227
+ barriers: [],
228
+ optimizes: 1,
212
229
  coordphaseOption: [],
213
230
  patternOne: [],
214
231
  planPattern: {},
@@ -230,6 +247,188 @@ export default {
230
247
  this.initData()
231
248
  },
232
249
  methods: {
250
+ tranform (arr) { // 分barrier
251
+ let newMap = new Map()
252
+ arr.forEach(({id, current}) => {
253
+ const find = newMap.get(current.join())
254
+ if (find) newMap.get(current.join()).push(id)
255
+ else newMap.set(current.join(), [id])
256
+ })
257
+ let ret = []
258
+ newMap.forEach((value, key) => {
259
+ ret.push(Array.from(new Set(key.split(',').map(Number).concat(value))))
260
+ })
261
+ const result = []
262
+ for (const a of ret) {
263
+ let merged = false
264
+ for (const r of result) {
265
+ if (this.check([...r], a)) {
266
+ a.forEach(item => r.add(item))
267
+ merged = true
268
+ }
269
+ }
270
+ if (!merged) {
271
+ result.push(new Set(a))
272
+ }
273
+ merged = false
274
+ }
275
+ return result.map(s => [...s])
276
+ },
277
+ check (arr1, arr2) {
278
+ return arr1.some(a1 => arr2.some(a2 => a1 === a2))
279
+ },
280
+ handleCurrentChange (val) { // 两个ring的数据
281
+ if (val === null || val.length === 0) return
282
+ // 按环序分组
283
+ let ringlength = []
284
+ let ringsequence = val.map(item => {
285
+ if (item.length === 0) return
286
+ ringlength.push(item.length)
287
+ return item.map(k => {
288
+ return k.id
289
+ })
290
+ })
291
+ let newRings = ringsequence.filter(item => item)
292
+ let minLength = Math.min(...ringlength)
293
+ let resultArrs = [] // 环1分组
294
+ let resultArr = [] // 环2分组
295
+ for (let j = 0; j < ringsequence[0].length; j += minLength) {
296
+ resultArrs.push(ringsequence[0].slice(j, j + minLength))
297
+ if (ringsequence[0].length === minLength) {
298
+ resultArrs.push([])
299
+ }
300
+ }
301
+ if (newRings.length > 1) {
302
+ for (let i = 0; i < ringsequence[1].length; i += minLength) {
303
+ resultArr.push(ringsequence[1].slice(i, i + minLength))
304
+ }
305
+ }
306
+ // this.patternInfo = []
307
+ // this.barrierList = []
308
+ let currentArr = []
309
+ let newPattern = []
310
+ val.map(i => {
311
+ newPattern.push(...i)
312
+ })
313
+ if (this.phaseList.length === 0) return
314
+ for (let patternStatus of val[0]) {
315
+ // if (patternStatus.mode !== 7) {
316
+ let concurrent = this.phaseList.filter((item) => {
317
+ return item.id === patternStatus.id // patternStatus.id当前相位id concurrent当前相位的并发相位
318
+ })[0].concurrent// 当前相位的并发相位
319
+ if (concurrent) {
320
+ let obj = {
321
+ id: patternStatus.id,
322
+ current: concurrent.sort()
323
+ }
324
+ currentArr.push(obj)
325
+ }
326
+ // }
327
+ }
328
+ if (currentArr.length !== 0) {
329
+ let newCurrent = this.tranform(currentArr)
330
+ // 取没个环与环关系的并集
331
+ let barrierRing1 = []
332
+ let barrierRing2 = []
333
+ let ring1 = [] // 环1与关系1的并集
334
+ for (let h = 0; h < newCurrent.length; h++) {
335
+ let adds = [...new Set(resultArrs[0])].filter(item => newCurrent[h].includes(item))
336
+ ring1.push(adds)
337
+ }
338
+ let ring1s = [] // 环1与关系2的并集
339
+ for (let h = 0; h < newCurrent.length; h++) {
340
+ let addRing1 = [...new Set(resultArrs[1])].filter(item => newCurrent[h].includes(item))
341
+ ring1s.push(addRing1)
342
+ }
343
+ barrierRing1.push(...ring1, ...ring1s)
344
+ let resultList = []
345
+ if (newRings.length > 1) {
346
+ let ring2s = [] // 环2与关系1的并集
347
+ for (let h = 0; h < newCurrent.length; h++) {
348
+ let addRing2 = [...new Set(resultArr[1])].filter(item => newCurrent[h].includes(item))
349
+ ring2s.push(addRing2)
350
+ }
351
+ let ring2 = [] // 环2与关系1的并集
352
+ for (let h = 0; h < newCurrent.length; h++) {
353
+ let add = [...new Set(resultArr[0])].filter(item => newCurrent[h].includes(item))
354
+ ring2.push(add)
355
+ }
356
+ barrierRing2.push(...ring2, ...ring2s)
357
+ for (let k = 0; k < barrierRing1.length; k++) {
358
+ resultList.push(barrierRing1[k].concat(barrierRing2[k]))
359
+ }
360
+ }
361
+ let resultLists = resultList.filter(item => item.length !== 0)
362
+ let ringArr = []
363
+ for (let l = 0; l < resultLists.length; l++) {
364
+ for (let d = 0; d < newCurrent.length; d++) {
365
+ if (newCurrent[d].filter(item => resultLists[l].includes(item)).length > 0) {
366
+ ringArr.push({
367
+ data: resultLists[l],
368
+ id: d + 1,
369
+ index: l
370
+ })
371
+ }
372
+ }
373
+ }
374
+ for (var i = 0; i < ringArr.length; i++) {
375
+ for (var j = i + 1; j < ringArr.length; j++) {
376
+ if (ringArr[i].id === ringArr[j].id && ringArr[i].index + 1 === ringArr[j].index) {
377
+ ringArr[i].data = ringArr[i].data.concat(ringArr[j].data)
378
+ ringArr.splice(ringArr.indexOf(ringArr[j].id), 1)
379
+ }
380
+ }
381
+ }
382
+ let resArr = ringArr.map(item => item.data)
383
+ let ringTeam = this.step1(this.phaseList, resArr)
384
+ let ringTeams = ringTeam.filter(item => item.length !== 0)
385
+ return this.setBarrier(ringTeams, val)
386
+ }
387
+ },
388
+ setBarrier (ringTeam, val) {
389
+ const patternObjs = {}
390
+ val.forEach(l => {
391
+ l.map(k => {
392
+ patternObjs[k.id] = k.value
393
+ })
394
+ })
395
+ let ret = ringTeam.map((y, index) => {
396
+ if (!y || y.length === 0) return
397
+ y.map(n => {
398
+ n.length = n.data.length > 1 ? n.data.reduce((pre, cur) => pre + patternObjs[cur], 0) : patternObjs[n.data[0]]
399
+ })
400
+ return {
401
+ barrier: index + 1,
402
+ length: y[0].length,
403
+ items: y.map(j => {
404
+ return {
405
+ ring: j.ring,
406
+ data: j.data
407
+ }
408
+ })
409
+ }
410
+ })
411
+ return ret
412
+ },
413
+ step1 (list, arr) { // 各个环包含的相位
414
+ const ret = []
415
+ const listObj = {}
416
+ list.forEach(l => {
417
+ listObj[l.id] = l.ring
418
+ })
419
+ arr.forEach(a => {
420
+ const retItem = []
421
+ a.forEach(b => {
422
+ if (listObj[b]) {
423
+ const find = retItem.find(r => r.ring === listObj[b])
424
+ if (find) find.data.push(b)
425
+ else retItem.push({ring: listObj[b], data: [b]})
426
+ }
427
+ })
428
+ ret.push(retItem)
429
+ })
430
+ return ret
431
+ },
233
432
  patternPlan () {
234
433
  let Pattern = {
235
434
  offset: 0,
@@ -257,6 +456,8 @@ export default {
257
456
  newPattern.rings[3].push(ring)
258
457
  }
259
458
  }
459
+ let barrier = this.handleCurrentChange(newPattern.rings)
460
+ newPattern.barriers = barrier
260
461
  this.planPattern = newPattern
261
462
  },
262
463
  getCycle () {
@@ -540,6 +741,8 @@ export default {
540
741
  this.ringCount = this.ringCount.sort(this.sortNumbers) // 把数组中的值按照从小到大的顺序重新排序
541
742
  this.ringCounts = Array.from(new Set(rings)) // 去除数组重复的元素
542
743
  this.ringCounts = this.ringCounts.sort(this.sortNumbers) // 把数组中的值按照从小到大的顺序重新排序
744
+ this.optimizes = Array.from(new Set(rings)) // 去除数组重复的元素
745
+ this.optimizes = this.optimizes.sort(this.sortNumbers) // 把数组中的值按照从小到大的顺序重新排序
543
746
  // this.increaseId()
544
747
  // this.getCycle()
545
748
  // this.updatePhaseDescription()
@@ -51,7 +51,7 @@
51
51
  <el-input
52
52
  v-if="this.contrloType === 'ring' || !this.contrloType"
53
53
  size="small"
54
- :value="stage.stageKanban.join(',')"
54
+ :value="stage.stageKanban?stage.stageKanban.join(','):''"
55
55
  ref="type"
56
56
  :disabled="true">
57
57
  </el-input>
@@ -14,6 +14,7 @@ import PatternStatus from './components/PatternStatus/index'
14
14
  import BoardCard from './components/BoardCard/index'
15
15
  import StageStatus from './components/StageStatus/index'
16
16
  import OverLap from './components/OverLap/index'
17
+ import PatternOptimize from './components/PatternOptimize/index'
17
18
  import Stages from './components/Stages/index'
18
19
  import PhaseMarker from './components/PhaseMarker/index'
19
20
  import overView from './components/overView/index'
@@ -48,6 +49,7 @@ const components = {
48
49
  patternList,
49
50
  CommonKanban,
50
51
  Stages,
52
+ PatternOptimize,
51
53
  PhaseMarker,
52
54
  overView,
53
55
  KanBan,