From f6edee889e34cc5de979e05eac4dffe81e29a9f9 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期一, 17 四月 2023 16:55:13 +0800
Subject: [PATCH] 1.多排备份

---
 src/views/deviceManager/deviceGroup.vue |  337 +++++++++++++++++++++++++++++++++----------------------
 1 files changed, 200 insertions(+), 137 deletions(-)

diff --git a/src/views/deviceManager/deviceGroup.vue b/src/views/deviceManager/deviceGroup.vue
index d9d3c9e..425c95f 100644
--- a/src/views/deviceManager/deviceGroup.vue
+++ b/src/views/deviceManager/deviceGroup.vue
@@ -1,3 +1,5 @@
+<!--澶氭帓闈為〉绛惧舰寮�-->
+
 <template>
   <div>
     <div class="body" :style="{height:mainHeight+'px'}">
@@ -1178,7 +1180,9 @@
           startdate: handleDatetime(new Date()), // 褰撳墠鏃ユ湡锛堜粖澶╋級
           enddate: row.AdvaScheEndDate //  瑕佹眰浜や粯鏃堕棿
         })
+        row.AdvaSchePiroQueNumber = row.AdvaSchePiroQue === '姝e父' ? 3 : row.AdvaSchePiroQue === '绱ф��' ? 2 : 1
       })
+
       const res = await NewOnclickAdvancedSchedulingDevice(DATA)
       // 濡傛灉Message鏈夋姤閿欎俊鎭垯缁堟鎵ц鍚庨潰閫昏緫
       if (res.rus.Message) {
@@ -1346,6 +1350,9 @@
         allCapacity.forEach(it => {
           if (item.wo_code === it.wo_code) {
             this.pushCapacity(everyEqpCapacity, it.id, it.gtArray)
+            it.gtArray = it.gtArray.filter((currentValue, currentIndex, selfArr) => {
+              return selfArr.findIndex(item => item.start === currentValue.start) === currentIndex
+            })
             // it.gtArray.sort((a, b) => new Date(a.end).getTime() - new Date(b.end).getTime())
           }
         })
@@ -1367,14 +1374,34 @@
           }
         }
       }
+
+      // 灏嗗伐鍗曠殑浼樺厛绾ц繘琛屾帓搴忥紝鍏堜互鏃堕棿鎺掞紝鍐嶄互浼樺厛绾ф帓
+      this.getMultipleSelectionOrder()
+
       // this.eqpTopTempData = JSON.parse(JSON.stringify(this.schedulingData))
 
-      console.log(waitingForScheduling, 'waitingForScheduling')
-      console.log(allCapacity, 'allCapacity')
-      console.log(this.schedulingData, 'schedulingData')
-      // console.log(JSON.stringify(this.schedulingData), 'schedulingData')
-      console.log(this.schedulingAllData, 'schedulingAllData')
-      console.log(everyEqpCapacity, 'everyEqpCapacity')
+      // console.log(waitingForScheduling, 'waitingForScheduling')
+      // console.log(allCapacity, 'allCapacity')
+      // console.log(this.schedulingData, 'schedulingData')
+      // // console.log(JSON.stringify(this.schedulingData), 'schedulingData')
+      // console.log(this.schedulingAllData, 'schedulingAllData')
+      // console.log(everyEqpCapacity, 'everyEqpCapacity')
+    },
+    // 灏嗗伐鍗曠殑浼樺厛绾ц繘琛屾帓搴忥紝鍏堜互鏃堕棿鎺掞紝鍐嶄互浼樺厛绾ф帓
+    getMultipleSelectionOrder() {
+      // 1.鍏堥�氳繃鏃堕棿鍘婚噸鐭ラ亾鏈夊摢鍑犲ぉ鐨勬椂闂�       // 2.閬嶅巻杩欏嚑澶╃殑鏃堕棿锛岃繃婊ゅ嚭鐩稿搴旂殑宸ュ崟
+      const newArr = []
+      this.multipleSelection.filter((currentValue, currentIndex, selfArr) => {
+        return selfArr.findIndex(item => item.AdvaScheEndDate === currentValue.AdvaScheEndDate) === currentIndex
+      }).map(i => i.AdvaScheEndDate).forEach(i => {
+        newArr.push(this.multipleSelection.filter(j => j.AdvaScheEndDate === i))
+      })
+      // 鏍规嵁鏃ユ湡鐩稿悓鐨勶紝宸ュ崟浼樺厛绾ц繘琛屾帓搴�
+      newArr.filter(i => {
+        i.sort((a, b) => b.AdvaSchePiroQueNumber - a.AdvaSchePiroQueNumber)
+      })
+      // 鎺掑ソ涔嬪悗  宸ュ崟椤哄簭灏辨槸鏁翠釜鐨勪紭鍏堢骇
+      this.multipleSelection = newArr.flat()// 浜岀淮杞竴缁�
     },
     // 鏃堕棿/璁惧浼樺厛鎺掔▼
     prepareArrange() {
@@ -1387,7 +1414,7 @@
       // 璁惧浼樺厛鎴栬�呮椂闂翠紭鍏� 瀵规暟鎹繘琛岀殑鏍煎紡杞崲
       if (this.schedulingData !== '' && this.formBottom.types === 'N') { // 璁惧浼樺厛
         this.eqpDataTransition()
-        this.editLastValue(this.schedulingData)
+        // this.editLastValue(this.schedulingData)
       } else if (this.timeTopTempData !== '' && this.formBottom.types === 'Y') { // 鏃堕棿浼樺厛
         this.filterAlreadyScheduleTime() // 鎵嬪姩杩囨护鎵�鏈夋椂闂村凡鎺掔▼
         this.timeDataTransition()
@@ -1397,144 +1424,180 @@
     },
     // 璁惧浼樺厛   鏁版嵁鏍煎紡杞崲
     eqpDataTransition() {
-      let needNumber = this.formBottom.needArrangeNumber // 闇�鎺掓暟閲�
-      let flag1 = 0
-      console.log(this.schedulingData, 33)
-      console.log(this.schedulingData.length, 33)
-      for (const i in this.schedulingData) {
-        console.log(i, '涓浗绉诲姩')
-        let end_arr = [] // 宸叉帓绋嬬殑鏁扮粍
-        let need_arr = [] // 寰呮帓绋嬬殑鏁扮粍
+      const needNumber = this.formBottom.needArrangeNumber // 闇�鎺掓暟閲�
 
-        let capacity_arr = [] // 瑕佹帓绋嬬殑鏁扮粍
-        this.schedulingData[i].gtArray.sort((a, b) => new Date(a.end).getTime() - new Date(b.end).getTime())
+      // 灏嗕骇鑳界殑鎵�鏈夊�间笌澶氶�夋鐨勯�変腑鐨勮鏃堕棿杩涜鍖归厤鏍¢獙 浠ヤ究鍚庣画璁$畻
+      this.multipleSelection.forEach(item => {
+        this.schedulingAllData.forEach(it => {
+          // 鎵惧埌宸ュ崟鎵�瀵瑰簲鐨勮澶囪繘琛岃绠楁帓绋�   鍐欏嚭璁$畻閫昏緫  杩欓儴鍒嗘瘮杈冧笂澶�
+          if (it.wo_code === item.AdvaScheWorkCode) {
+            it.gtArray.forEach(i => {
+              const t = i.start.split(' ')[0]
+              // 浠h〃褰撳墠宸ュ崟涓嬬殑浜ц兘鏄惁鍙帓
+              i.status = new Date(t).getTime() <= new Date(item.AdvaScheEndDate).getTime()
 
-        end_arr = JSON.parse(JSON.stringify(this.schedulingData[i].gtArray.filter(item => item.type === 'h_schedule'))) // 宸叉帓绋嬫暟缁�
-        need_arr = JSON.parse(JSON.stringify(this.schedulingData[i].gtArray.filter(item => item.type === 'capacity'))) // 瀹归噺
-        console.log(need_arr, 5)
-        console.log(JSON.stringify(need_arr))
+              console.log(i)
 
-        if (end_arr && end_arr.length > 0) {
-          capacity_arr = need_arr.map(item => {
-            // 鎺掗櫎鎺夊凡缁忔帓绋嬬殑瀛樺湪hshedule锛宻tart锛宔nd閮界浉绛夌殑鎯呭喌
-            const schedule = end_arr.filter(it => {
-              return new Date(item.start).getTime() <= new Date(it.start).getTime() &&
-                new Date(item.end).getTime() >= new Date(it.end).getTime()
+              // 鐩墠璁$畻閫昏緫杩樹笉澶竻妤氭�庝箞鍐� 澶笂澶翠簡
+
+              console.log(it.id, 'it')
+
+              const end_time = ''
+              const mistiming = ''
+              // 宸ュ崟鐩稿悓涔嬪悗   搴旇鏍规嵁鏃堕棿浼樺厛鎴栬�呰澶囦紭鍏�  瀵硅澶囪繘琛屼竴涓�鎺掔▼
+
+              // 浜ц兘鏈夊嚑娈� data鐨勪釜鏁版渶澶氬氨鏈夊嚑涓�
+              const data = {
+                id: it.id,
+                start: '2023-04-17 13:00:00',
+                end: '2023-04-17 16:00:00',
+                type: 'schedule',
+                cl_name: item.AdvaSchePartName,
+                cl_code: item.AdvaSchePartNumber,
+                work_order: item.AdvaScheWorkCode,
+                AdvaScheUom: item.AdvaScheUom,
+                number: 0,
+                real_number: 0
+              }
+
+              // 杩欎釜鍦版柟涓嶅   鍐欎笉鍑烘潵浜�
+              // data.start = it.gtArray[0].start // 鍏堝彧鑰冭檻涓�绉嶆儏鍐�
+              // data.start = it.gtArray[0].start // 鍏堝彧鑰冭檻涓�绉嶆儏鍐�
+              data.number = '230'
+              data.real_number = '230'
+              const index = this.schedulingData.findIndex(i => i.id === it.id)
+              this.schedulingData[index].gtArray.push(data)
+
+              return false
             })
-
-            if (schedule && schedule.length > 0) {
-              item.start = this.MinutesTest(schedule[schedule.length - 1]['end'])
-            }
-
-            const schedule1 = end_arr.filter(schedule => {
-              return new Date(item.start).getTime() === new Date(schedule.start).getTime() &&
-                new Date(item.end).getTime() === new Date(schedule.end).getTime()
-            })
-            if (schedule1 && schedule1.length > 0) {
-              item.capacity = false
-            }
-
-            return item
-          }).filter(item => item.capacity !== false)
-        } else {
-          capacity_arr = need_arr
-        }
-
-        const id_obj = {
-          id: '',
-          start_time: ''
-        }
-        if (end_arr != '') {
-          (id_obj.id = end_arr[0].id), (id_obj.start_time = end_arr[0].end)
-        }
-
-        capacity_arr = this.filterOutTime(capacity_arr) // 杩囨护鎺夊綋鍓嶆椂闂翠箣鍓嶇殑涓嶈兘鎺掔▼
-
-        for (const w in capacity_arr) {
-          console.log(capacity_arr[w], 'capacity_arr')
-          let end_time = ''
-          let mistiming = ''
-          const data = {
-            id: capacity_arr[w].id,
-            start: '',
-            end: '',
-            type: 'schedule',
-            cl_name: capacity_arr[w].partname, // 浜у搧鍚嶇О
-            cl_code: capacity_arr[w].partcode, // 浜у搧缂栫爜
-            work_order: capacity_arr[w].work_order,
-            AdvaScheUom: capacity_arr[w].AdvaScheUom,
-            number: 0,
-            real_number: 0
           }
-          if (
-            id_obj.start_time !== '' &&
-            flag1 === 0 &&
-            new Date(id_obj.start_time).getTime() >= new Date(capacity_arr[w].start).getTime()
-          ) {
-            data.start = this.MinutesTest(id_obj.start_time)
-            flag1 = 1
-          } else {
-            data.start = capacity_arr[w].start
-          }
-          let nowTime = (this.schedulingData[i].AdvaDevicRhythm * needNumber) / capacity_arr[w].mod
-          end_time = this.formSeconds(nowTime, data.start, capacity_arr[w].mod) // 鎬诲叡鐨勭粨鏉熸椂闂�
-          data.end = end_time
-          mistiming = this.compareTime(
-            end_time,
-            capacity_arr[w].end,
-            capacity_arr[w].mod
-          ) // 鎬诲叡鐨勭粨鏉熸椂闂�-褰撳墠鐨勭粨鏉熸椂闂� = 鍓╀笅澶氫箙鏃堕棿
-          if (mistiming >= 0) {
-            data.number =
-              ((new Date(data.end) - new Date(data.start)) *
-                capacity_arr[w].mod) /
-              this.schedulingData[i].AdvaDevicRhythm /
-              1000
-            data.real_number =
-              ((new Date(data.end) - new Date(data.start)) *
-                capacity_arr[w].mod) /
-              this.schedulingData[i].AdvaDevicRhythm /
-              1000
-            data.number = data.number.toFixed(0)
-            data.end_num = true
-            if (new Date(data.start) >= new Date(data.end)) {
-            } else {
-              this.schedulingData[i].gtArray.push(data)
-            }
-            return false
-          } else {
-            data.end = capacity_arr[w].end
+        })
+      })
 
-            if (new Date(data.end).getTime() < new Date(data.start)) {
-              continue // 鍥犱负寮�濮嬫椂闂存瘮缁撴潫鏃堕棿澶� 闇�瑕佽烦杩囧悗闈㈡楠�
-            }
+      // 杩欎釜鏄绠楀嚭鏉ョ殑鏁板�硷紝闇�瑕乸ush鍒皊chedulingData涓�
 
-            // 杩欓噷闄や互涓�鍗冩槸鍥犱负 new Date() 寰楀埌鐨勬槸姣  姣杞寲涓虹鏄崈杩涘埗
-            // 涓�娈垫椂闂存鍐呯殑鐢熶骇閲�=涓よ�呮椂闂村樊锛堟绉掞級/1000  / 鐢熶骇鑺傛媿 * 绋煎姩鐜�
-            data.number =
-              ((new Date(data.end) - new Date(data.start)) *
-                capacity_arr[w].mod) /
-              this.schedulingData[i].AdvaDevicRhythm /
-              1000
+      //         'id': 'JG002',
+      //         'start': '2023-04-17 10:10:21',
+      //         'end': '2023-04-17 11:30:00',
+      //         'type': 'schedule',
+      //         'cl_name': '涓绘満',
+      //         'cl_code': '201',
+      //         'work_order': 'MO-2023-04-0001_1',
+      //         'AdvaScheUom': '涓�',
+      //         'number': '64',
+      //         'real_number': 63.72
 
-            data.real_number =
-              ((new Date(data.end) - new Date(data.start)) *
-                capacity_arr[w].mod) /
-              this.schedulingData[i].AdvaDevicRhythm /
-              1000
+      // this.schedulingData = [
+      //   {
+      //     'id': 'JG002',
+      //     'name': '绮惧伐璁惧2#',
+      //     'AdvaDevicRhythm': '15.0',
+      //     'status': true,
+      //     'colorPair': {
+      //       'dark': 'rgb(83, 186, 241,0.8)',
+      //       'light': 'rgb(83, 186, 241,0.1)',
+      //       'light_capacity': 'rgb(209,239,237,0.8)',
+      //       'h_schedule': 'rgb(100,255,192,0.8)',
+      //       'scheduleing': 'rgb(20,182,231,0.8)'
+      //     },
+      //     'gtArray': [
+      //       {
+      //         'start': '2023-04-17 08:00:00',
+      //         'end': '2023-04-17 11:30:00',
+      //         'id': 'JG002',
+      //         'mod': 0.2,
+      //         'type': 'capacity'
+      //       },
+      //       {
+      //         'start': '2023-04-17 13:00:00',
+      //         'end': '2023-04-17 18:00:00',
+      //         'id': 'JG002',
+      //         'mod': 0.2,
+      //         'type': 'capacity'
+      //       },
+      //       {
+      //         'id': 'JG002',
+      //         'start': '2023-04-17 10:10:21',
+      //         'end': '2023-04-17 11:30:00',
+      //         'type': 'schedule',
+      //         'cl_name': '涓绘満',
+      //         'cl_code': '201',
+      //         'work_order': 'MO-2023-04-0001_1',
+      //         'AdvaScheUom': '涓�',
+      //         'number': '64',
+      //         'real_number': 63.72
+      //       },
+      //       {
+      //         'id': 'JG002',
+      //         'start': '2023-04-17 13:00:00',
+      //         'end': '2023-04-17 18:00:00',
+      //         'type': 'schedule',
+      //         'cl_name': '涓绘満',
+      //         'cl_code': '201',
+      //         'work_order': 'MO-2023-04-0001_1',
+      //         'AdvaScheUom': '涓�',
+      //         'number': '240',
+      //         'real_number': 240
+      //       }
+      //     ]
+      //   },
+      //   {
+      //     'id': 'SB001',
+      //     'name': '璁惧001',
+      //     'AdvaDevicRhythm': '15.0',
+      //     'status': true,
+      //     'colorPair': {
+      //       'dark': 'rgb(83, 186, 241,0.8)',
+      //       'light': 'rgb(83, 186, 241,0.1)',
+      //       'light_capacity': 'rgb(209,239,237,0.8)',
+      //       'h_schedule': 'rgb(100,255,192,0.8)',
+      //       'scheduleing': 'rgb(20,182,231,0.8)'
+      //     },
+      //     'gtArray': [
+      //       {
+      //         'start': '2023-04-17 08:00:00',
+      //         'end': '2023-04-17 11:30:00',
+      //         'id': 'SB001',
+      //         'mod': 0.3,
+      //         'type': 'capacity'
+      //       },
+      //       {
+      //         'start': '2023-04-17 13:00:00',
+      //         'end': '2023-04-17 18:00:00',
+      //         'id': 'SB001',
+      //         'mod': 0.3,
+      //         'type': 'capacity'
+      //       },
+      //       {
+      //         'id': 'SB001',
+      //         'start': '2023-04-17 10:10:21',
+      //         'end': '2023-04-17 11:30:00',
+      //         'type': 'schedule',
+      //         'cl_name': '涓绘満',
+      //         'cl_code': '201',
+      //         'work_order': 'MO-2023-04-0001_1',
+      //         'AdvaScheUom': '涓�',
+      //         'number': '96',
+      //         'real_number': 95.58
+      //       },
+      //       {
+      //         'id': 'SB001',
+      //         'start': '2023-04-17 13:00:00',
+      //         'end': '2023-04-17 18:00:00',
+      //         'type': 'schedule',
+      //         'cl_name': '涓绘満',
+      //         'cl_code': '201',
+      //         'work_order': 'MO-2023-04-0001_1',
+      //         'AdvaScheUom': '涓�',
+      //         'number': '360',
+      //         'real_number': 360
+      //       }
+      //     ]
+      //   }
+      // ]
 
-            data.number = data.number.toFixed(0)
-
-            nowTime = (needNumber - data.real_number) * this.schedulingData[i].AdvaDevicRhythm
-            needNumber = needNumber - data.real_number
-            if (new Date(data.start) >= new Date(data.end)) {
-
-            } else {
-              this.schedulingData[i].gtArray.push(data)
-            }
-          }
-        }
-      }
+      console.log(this.schedulingData, 'schedulingData')
+      console.log(this.schedulingAllData, 'schedulingAllData')
     },
     // 鑾峰彇鎺掔▼鏃ユ湡鏈�澶у��
     getMaxPayDate() {
@@ -1733,7 +1796,7 @@
       }
     },
     // 璁惧浼樺厛   鏁版嵁鏍煎紡杞崲
-    eqpDataTransition2() {
+    eqpDataTransition2() { // 杩欓噷鏄師鍏堢殑鍐欐硶
       let needNumber = this.formBottom.needArrangeNumber // 闇�鎺掓暟閲�
       let flag1 = 0
       console.log(this.schedulingData, 33)

--
Gitblit v1.9.3