diff --git a/api/app/lib/controllers/calculability/index.js b/api/app/lib/controllers/calculability/index.js index 1ea5a64..7ff8337 100644 --- a/api/app/lib/controllers/calculability/index.js +++ b/api/app/lib/controllers/calculability/index.js @@ -8,7 +8,6 @@ async function getCalculability(ctx) { const { models } = ctx.fs.dc const query = ctx.query const sequelize = ctx.fs.dc.ORM; - //console.log('query2', query) const { eTime, sTime } = query const timer = (new Date(eTime) - new Date(sTime)) / 1000 //时间之间的秒数 //console.log('timer', timer) @@ -24,13 +23,17 @@ async function getCalculability(ctx) { }) let problemtime = 0 recordRes.rows.forEach((item) => { - problemtime += item.solvingTime - item.occurrenceTime + let diff = (item.solvingTime - item.occurrenceTime) / 1000; + problemtime += diff; }) - //console.log('problemtime', problemtime) - //console.log('recordRes', recordRes) + + console.log('recordRes', recordRes) //console.log(time, 'time1') - const abilty = timer / (timer + problemtime) + const abilty = (timer - problemtime) / timer + console.log('timer', timer, problemtime) //console.log('abc', abilty) + console.log('query2', query, problemtime, timer, abilty) + ctx.status = 200 ctx.body = abilty diff --git a/api/app/lib/controllers/maintenancePlan/index.js b/api/app/lib/controllers/maintenancePlan/index.js index f0117b1..4d80b96 100644 --- a/api/app/lib/controllers/maintenancePlan/index.js +++ b/api/app/lib/controllers/maintenancePlan/index.js @@ -25,39 +25,46 @@ async function getMaintenancePlan(ctx) { }) //console.log('res1', res) const arrayUserId = [] - res.rows.forEach((item) => { item.maintenancePlanExecuteUsers.forEach((item1) => { arrayUserId.push(item1.pepUserId) }) }) - const arrayUserIdCopy = [...new Set(arrayUserId)] - //(${ [...pepProjectIds].join(',') }, -1) - const userRes = await clickHouse.pepEmis.query(` - SELECT * FROM user - WHERE id IN (${[...arrayUserIdCopy].join(',')},-1) - `).toPromise() - //console.log('userRes', userRes) - //console.log('res.rows', res.rows) - const responseRes = res.rows.map((item) => { - return { - id: item.id, - missionName: item.missionName, - remark: item.remark, - reason: item.reason, - planFinishTime: item.planFinishTime, - actualFinishTime: item.actualFinishTime, - type: item.type, - state: item.state, - maintenancePlanExecuteUsers: - item.maintenancePlanExecuteUsers.map((item1) => { - return { - id: item1.id, - maintenancePlanId: item1.maintenancePlanId, - pepUserId: item1.pepUserId, - name: userRes.filter((ac) => { return ac.id == item1.pepUserId })[0].name - } - }) - } - }) - ctx.body = { count: resCount, responseRes } - //console.log('responseRes', responseRes) - ctx.status = 200 + if (res.rows.length > 0) { + res.rows.forEach((item) => { item.maintenancePlanExecuteUsers.forEach((item1) => { arrayUserId.push(item1.pepUserId) }) }) + const arrayUserIdCopy = [...new Set(arrayUserId)] + //(${ [...pepProjectIds].join(',') }, -1) + const userRes = await clickHouse.pepEmis.query(` + SELECT * FROM user + WHERE id IN (${[...arrayUserIdCopy].join(',')},-1)`).toPromise() + //console.log('userRes', userRes) + //console.log('res.rows', res.rows) + const responseRes = res.rows.map((item) => { + return { + id: item.id, + missionName: item.missionName, + remark: item.remark, + reason: item.reason, + planFinishTime: item.planFinishTime, + actualFinishTime: item.actualFinishTime, + type: item.type, + state: item.state, + maintenancePlanExecuteUsers: + item.maintenancePlanExecuteUsers.map((item1) => { + const nameArr = userRes.filter((ac) => { return ac.id == item1.pepUserId })[0] + return { + id: item1.id, + maintenancePlanId: item1.maintenancePlanId, + pepUserId: item1.pepUserId, + name: nameArr ? nameArr.name : '' + } + }) + } + }) + ctx.body = { count: resCount, responseRes } + //console.log('responseRes', responseRes) + ctx.status = 200 + } else { + ctx.body = { count: resCount, responseRes: [] } + ctx.status = 200 + } + + } catch (error) { ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) diff --git a/api/app/lib/controllers/record/index.js b/api/app/lib/controllers/record/index.js index 23f0f92..2d45570 100644 --- a/api/app/lib/controllers/record/index.js +++ b/api/app/lib/controllers/record/index.js @@ -54,11 +54,12 @@ async function getRecord(ctx) { type: item.type, maintenanceRecordExecuteUsers: item.maintenanceRecordExecuteUsers.map((item1) => { + const userArr = userRes.filter((ac) => { return ac.id == item1.pepUserId })[0] return { id: item1.id, maintenanceRecordId: item1.maintenanceRecordId, pepUserId: item1.pepUserId, - name: userRes.filter((ac) => { return ac.id == item1.pepUserId })[0].name + name: userArr ? userArr.name : '' } }) } diff --git a/web/client/src/sections/service/containers/cyclePlan.jsx b/web/client/src/sections/service/containers/cyclePlan.jsx index 7659fd2..553d184 100644 --- a/web/client/src/sections/service/containers/cyclePlan.jsx +++ b/web/client/src/sections/service/containers/cyclePlan.jsx @@ -1,6 +1,6 @@ import React, { useEffect,useState} from 'react'; import { connect } from 'react-redux'; -import { Button,Table,Popconfirm } from '@douyinfe/semi-ui'; +import { Button,Table,Popconfirm,Pagination } from '@douyinfe/semi-ui'; import Addmodal from '../components/cycAddmodal' import moment from 'moment' @@ -38,27 +38,27 @@ const Server = (props) => { }) } //配置分页 - const pagination={ - total:total, - defaultCurrent: 1, - pageSize:pageSize, - showSizeChanger: true, - currentPage:pageIndex, - showQuickJumper: true, - pageSizeOpts: ["5", "10", "15"], - showTotal: function () { - return `共有${total}条` - }, - onChange:(pageIndex,pageSize)=>{ - console.log('pageIndex1',pageIndex,pageSize) - setPageIndex(pageIndex) - setPageSize(pageSize) - const query={ - pageIndex,pageSize,type:'temp',msg:'获取周期性计划' - } - getCycPlan(query) - } -} +// const pagination={ +// total:total, +// defaultCurrent: 1, +// pageSize:pageSize, +// showSizeChanger: true, +// currentPage:pageIndex, +// showQuickJumper: true, +// pageSizeOpts: ["5", "10", "15"], +// showTotal: function () { +// return `共有${total}条` +// }, +// onChange:(pageIndex,pageSize)=>{ +// console.log('pageIndex1',pageIndex,pageSize) +// setPageIndex(pageIndex) +// setPageSize(pageSize) +// const query={ +// pageIndex,pageSize,type:'temp',msg:'获取周期性计划' +// } +// getCycPlan(query) +// } +// } //console.log('cycPlan',cycPlan) const columns = [ { @@ -119,8 +119,27 @@ const Server = (props) => {