| | |
| | | <!--多排非页签形式--> |
| | | |
| | | <template> |
| | | <div> |
| | | <div class="body" :style="{height:mainHeight+'px'}"> |
| | |
| | | startdate: handleDatetime(new Date()), // 当前日期(今天) |
| | | enddate: row.AdvaScheEndDate // 要求交付时间 |
| | | }) |
| | | row.AdvaSchePiroQueNumber = row.AdvaSchePiroQue === '正常' ? 3 : row.AdvaSchePiroQue === '紧急' ? 2 : 1 |
| | | }) |
| | | |
| | | const res = await NewOnclickAdvancedSchedulingDevice(DATA) |
| | | // 如果Message有报错信息则终止执行后面逻辑 |
| | | if (res.rus.Message) { |
| | |
| | | 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()) |
| | | } |
| | | }) |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 将工单的优先级进行排序,先以时间排,再以优先级排 |
| | | 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() { |
| | |
| | | // 设备优先或者时间优先 对数据进行的格式转换 |
| | | 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() |
| | |
| | | }, |
| | | // 设备优先 数据格式转换 |
| | | 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] |
| | | // 代表当前工单下的产能是否可排 |
| | | 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,start,end都相等的情况 |
| | | 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 // 因为开始时间比结束时间大 需要跳过后面步骤 |
| | | } |
| | | // 这个是计算出来的数值,需要push到schedulingData中 |
| | | |
| | | // 这里除以一千是因为 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() { |
| | |
| | | } |
| | | }, |
| | | // 设备优先 数据格式转换 |
| | | eqpDataTransition2() { |
| | | eqpDataTransition2() { // 这里是原先的写法 |
| | | let needNumber = this.formBottom.needArrangeNumber // 需排数量 |
| | | let flag1 = 0 |
| | | console.log(this.schedulingData, 33) |