From d0c6f505333de0fdb7548aad1a60131d99c83b42 Mon Sep 17 00:00:00 2001 From: zhaobing Date: Tue, 20 Jun 2023 13:25:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/controllers/calculability/index.js | 13 ++-- .../lib/controllers/maintenancePlan/index.js | 73 ++++++++++--------- api/app/lib/controllers/record/index.js | 3 +- .../sections/service/containers/cyclePlan.jsx | 65 +++++++++++------ .../service/containers/serviceRecord.jsx | 43 +++++------ .../service/containers/temporaryResponse.jsx | 65 +++++++++++------ 6 files changed, 156 insertions(+), 106 deletions(-) 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) => {
-
+
+
+ + 共{total}条信息 + + { + console.log('pageIndex1',pageIndex,pageSize) + setPageIndex(pageIndex) + setPageSize(pageSize) + const query={ + pageIndex,pageSize,type:'temp',msg:'获取周期性计划' + } + getCycPlan(query) + }}> +
{setAddVis(false);setRecordRow(null);getCycPlan()}} recordRow={recordRow} pepList={pepList}> diff --git a/web/client/src/sections/service/containers/serviceRecord.jsx b/web/client/src/sections/service/containers/serviceRecord.jsx index 9799921..5c39281 100644 --- a/web/client/src/sections/service/containers/serviceRecord.jsx +++ b/web/client/src/sections/service/containers/serviceRecord.jsx @@ -1,7 +1,7 @@ 'use strict'; import React, { useEffect,useState,useMemo } from 'react'; -import { Calendar,DatePicker,RadioGroup, Radio,Button,Table,Modal,Tooltip } from '@douyinfe/semi-ui'; +import { Calendar,DatePicker,RadioGroup, Radio,Button,Table,Modal,Tooltip,Pagination } from '@douyinfe/semi-ui'; import moment from 'moment' import { connect } from 'react-redux'; import RecordModal from '../components/recordModal' @@ -53,24 +53,7 @@ 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)=>{ - setPageIndex(pageIndex) - setPageSize(pageSize) - const query={ - startTime,endTime,pageIndex,pageSize - } - getRecordList(query) - } + } //console.log(recordList,'11111111') @@ -207,12 +190,30 @@ const addHandler=()=>{
- { +
{ return { background:'#000000', } }}/> - + +
+ + 共{total}条信息 + + { + setPageIndex(pageIndex) + setPageSize(pageSize) + const query={ + startTime,endTime,pageIndex,pageSize + } + getRecordList(query) + }}> +
{ setModalVis(false);getRecordList();setRecordRow(null)}} recordRow={recordRow} pepList={pepList}> diff --git a/web/client/src/sections/service/containers/temporaryResponse.jsx b/web/client/src/sections/service/containers/temporaryResponse.jsx index 4128345..4adef4d 100644 --- a/web/client/src/sections/service/containers/temporaryResponse.jsx +++ b/web/client/src/sections/service/containers/temporaryResponse.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 moment from 'moment' import TemporyModal from '../components/temporyModal' @@ -25,27 +25,27 @@ const SetControl = (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:'获取临时响应' - } - getResponse(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:'获取临时响应' +// } +// getResponse(query) +// } +// } useEffect(() => { getResponse() dispatch(install.getOrganizationDeps()).then((res) => {//获取项企(PEP)全部部门及其下用户 @@ -128,8 +128,27 @@ const SetControl = (props) => {
-
+
+
+ + 共{total}条信息 + + { + console.log('pageIndex1',pageIndex,pageSize) + setPageIndex(pageIndex) + setPageSize(pageSize) + const query={ + pageIndex,pageSize,type:'temp',msg:'获取临时响应' + } + getResponse(query) + }}> +
{setAddVis(false);getResponse();setRecordRow(null)}} recordRow={recordRow} pepList={pepList}>