Browse Source

feat:修改数据保护

dev
zhaobing 2 years ago
parent
commit
d0c6f50533
  1. 13
      api/app/lib/controllers/calculability/index.js
  2. 73
      api/app/lib/controllers/maintenancePlan/index.js
  3. 3
      api/app/lib/controllers/record/index.js
  4. 65
      web/client/src/sections/service/containers/cyclePlan.jsx
  5. 43
      web/client/src/sections/service/containers/serviceRecord.jsx
  6. 65
      web/client/src/sections/service/containers/temporaryResponse.jsx

13
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

73
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}`)

3
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 : ''
}
})
}

65
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) => {
<Button theme='solid' type='secondary' style={{marginLeft:50}}>导入</Button>
</div>
<div>
<Table columns={columns} dataSource={cycPlan} pagination={pagination}></Table>
<Table columns={columns} dataSource={cycPlan} pagination={false}></Table>
</div>
<div style={{ display: 'flex',justifyContent:'flex-end' ,margin:'10px 0 0 0'}}>
<span style={{ lineHeight: "30px", fontSize: 13, color: 'rgba(0,90,189,0.8)' }}>
{total}条信息
</span>
<Pagination total={total}
showSizeChanger
pageSize={pageSize}
currentPage={pageIndex}
pageSizeOpts={[10, 20, 30]}
onChange={(pageIndex,pageSize)=>{
console.log('pageIndex1',pageIndex,pageSize)
setPageIndex(pageIndex)
setPageSize(pageSize)
const query={
pageIndex,pageSize,type:'temp',msg:'获取周期性计划'
}
getCycPlan(query)
}}></Pagination>
</div>
<Addmodal visible={addVis} onClose={()=>{setAddVis(false);setRecordRow(null);getCycPlan()}} recordRow={recordRow} pepList={pepList}></Addmodal>
</div>

43
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=()=>{
</div>
</div>
<div style={{marginTop:10}}>
<Table columns={columns} dataSource={recordList} pagination={pagination} onHeaderRow={()=>{
<Table columns={columns} dataSource={recordList} pagination={false} onHeaderRow={()=>{
return {
background:'#000000',
}
}}/>
</div>
</div>
<div style={{ display: 'flex',justifyContent:'flex-end' ,margin:'10px 0 0 0'}}>
<span style={{ lineHeight: "30px", fontSize: 13, color: 'rgba(0,90,189,0.8)' }}>
{total}条信息
</span>
<Pagination total={total}
showSizeChanger
pageSize={pageSize}
currentPage={pageIndex}
pageSizeOpts={[10, 20, 30]}
onChange={(pageIndex,pageSize)=>{
setPageIndex(pageIndex)
setPageSize(pageSize)
const query={
startTime,endTime,pageIndex,pageSize
}
getRecordList(query)
}}></Pagination>
</div>
<RecordModal visible={modalVis} onClose={() => { setModalVis(false);getRecordList();setRecordRow(null)}} recordRow={recordRow} pepList={pepList}></RecordModal>
</div>

65
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) => {
<Button theme='solid' type='secondary' onClick={()=>{setAddVis(true)}}>新增</Button>
</div>
<div>
<Table columns={columns} dataSource={response} pagination={pagination}></Table>
<Table columns={columns} dataSource={response} pagination={false}></Table>
</div>
<div style={{ display: 'flex',justifyContent:'flex-end' ,margin:'10px 0 0 0'}}>
<span style={{ lineHeight: "30px", fontSize: 13, color: 'rgba(0,90,189,0.8)' }}>
{total}条信息
</span>
<Pagination total={total}
showSizeChanger
pageSize={pageSize}
currentPage={pageIndex}
pageSizeOpts={[10, 20, 30]}
onChange={(pageIndex,pageSize)=>{
console.log('pageIndex1',pageIndex,pageSize)
setPageIndex(pageIndex)
setPageSize(pageSize)
const query={
pageIndex,pageSize,type:'temp',msg:'获取临时响应'
}
getResponse(query)
}}></Pagination>
</div>
<TemporyModal visible={addVis} onClose={()=>{setAddVis(false);getResponse();setRecordRow(null)}} recordRow={recordRow} pepList={pepList}></TemporyModal>
</div>

Loading…
Cancel
Save