Browse Source

feat:修改数据保护

dev
zhaobing 2 years ago
parent
commit
d0c6f50533
  1. 13
      api/app/lib/controllers/calculability/index.js
  2. 13
      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. 41
      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 { models } = ctx.fs.dc
const query = ctx.query const query = ctx.query
const sequelize = ctx.fs.dc.ORM; const sequelize = ctx.fs.dc.ORM;
//console.log('query2', query)
const { eTime, sTime } = query const { eTime, sTime } = query
const timer = (new Date(eTime) - new Date(sTime)) / 1000 //时间之间的秒数 const timer = (new Date(eTime) - new Date(sTime)) / 1000 //时间之间的秒数
//console.log('timer', timer) //console.log('timer', timer)
@ -24,13 +23,17 @@ async function getCalculability(ctx) {
}) })
let problemtime = 0 let problemtime = 0
recordRes.rows.forEach((item) => { 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') //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('abc', abilty)
console.log('query2', query, problemtime, timer, abilty)
ctx.status = 200 ctx.status = 200
ctx.body = abilty ctx.body = abilty

13
api/app/lib/controllers/maintenancePlan/index.js

@ -25,13 +25,13 @@ async function getMaintenancePlan(ctx) {
}) })
//console.log('res1', res) //console.log('res1', res)
const arrayUserId = [] const arrayUserId = []
if (res.rows.length > 0) {
res.rows.forEach((item) => { item.maintenancePlanExecuteUsers.forEach((item1) => { arrayUserId.push(item1.pepUserId) }) }) res.rows.forEach((item) => { item.maintenancePlanExecuteUsers.forEach((item1) => { arrayUserId.push(item1.pepUserId) }) })
const arrayUserIdCopy = [...new Set(arrayUserId)] const arrayUserIdCopy = [...new Set(arrayUserId)]
//(${ [...pepProjectIds].join(',') }, -1) //(${ [...pepProjectIds].join(',') }, -1)
const userRes = await clickHouse.pepEmis.query(` const userRes = await clickHouse.pepEmis.query(`
SELECT * FROM user SELECT * FROM user
WHERE id IN (${[...arrayUserIdCopy].join(',')},-1) WHERE id IN (${[...arrayUserIdCopy].join(',')},-1)`).toPromise()
`).toPromise()
//console.log('userRes', userRes) //console.log('userRes', userRes)
//console.log('res.rows', res.rows) //console.log('res.rows', res.rows)
const responseRes = res.rows.map((item) => { const responseRes = res.rows.map((item) => {
@ -46,11 +46,12 @@ async function getMaintenancePlan(ctx) {
state: item.state, state: item.state,
maintenancePlanExecuteUsers: maintenancePlanExecuteUsers:
item.maintenancePlanExecuteUsers.map((item1) => { item.maintenancePlanExecuteUsers.map((item1) => {
const nameArr = userRes.filter((ac) => { return ac.id == item1.pepUserId })[0]
return { return {
id: item1.id, id: item1.id,
maintenancePlanId: item1.maintenancePlanId, maintenancePlanId: item1.maintenancePlanId,
pepUserId: item1.pepUserId, pepUserId: item1.pepUserId,
name: userRes.filter((ac) => { return ac.id == item1.pepUserId })[0].name name: nameArr ? nameArr.name : ''
} }
}) })
} }
@ -58,6 +59,12 @@ async function getMaintenancePlan(ctx) {
ctx.body = { count: resCount, responseRes } ctx.body = { count: resCount, responseRes }
//console.log('responseRes', responseRes) //console.log('responseRes', responseRes)
ctx.status = 200 ctx.status = 200
} else {
ctx.body = { count: resCount, responseRes: [] }
ctx.status = 200
}
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${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, type: item.type,
maintenanceRecordExecuteUsers: maintenanceRecordExecuteUsers:
item.maintenanceRecordExecuteUsers.map((item1) => { item.maintenanceRecordExecuteUsers.map((item1) => {
const userArr = userRes.filter((ac) => { return ac.id == item1.pepUserId })[0]
return { return {
id: item1.id, id: item1.id,
maintenanceRecordId: item1.maintenanceRecordId, maintenanceRecordId: item1.maintenanceRecordId,
pepUserId: item1.pepUserId, 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 React, { useEffect,useState} from 'react';
import { connect } from 'react-redux'; 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 Addmodal from '../components/cycAddmodal'
import moment from 'moment' import moment from 'moment'
@ -38,27 +38,27 @@ const Server = (props) => {
}) })
} }
// //
const pagination={ // const pagination={
total:total, // total:total,
defaultCurrent: 1, // defaultCurrent: 1,
pageSize:pageSize, // pageSize:pageSize,
showSizeChanger: true, // showSizeChanger: true,
currentPage:pageIndex, // currentPage:pageIndex,
showQuickJumper: true, // showQuickJumper: true,
pageSizeOpts: ["5", "10", "15"], // pageSizeOpts: ["5", "10", "15"],
showTotal: function () { // showTotal: function () {
return `共有${total}` // return `${total}`
}, // },
onChange:(pageIndex,pageSize)=>{ // onChange:(pageIndex,pageSize)=>{
console.log('pageIndex1',pageIndex,pageSize) // console.log('pageIndex1',pageIndex,pageSize)
setPageIndex(pageIndex) // setPageIndex(pageIndex)
setPageSize(pageSize) // setPageSize(pageSize)
const query={ // const query={
pageIndex,pageSize,type:'temp',msg:'获取周期性计划' // pageIndex,pageSize,type:'temp',msg:''
} // }
getCycPlan(query) // getCycPlan(query)
} // }
} // }
//console.log('cycPlan',cycPlan) //console.log('cycPlan',cycPlan)
const columns = [ const columns = [
{ {
@ -119,7 +119,26 @@ const Server = (props) => {
<Button theme='solid' type='secondary' style={{marginLeft:50}}>导入</Button> <Button theme='solid' type='secondary' style={{marginLeft:50}}>导入</Button>
</div> </div>
<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> </div>
<Addmodal visible={addVis} onClose={()=>{setAddVis(false);setRecordRow(null);getCycPlan()}} recordRow={recordRow} pepList={pepList}></Addmodal> <Addmodal visible={addVis} onClose={()=>{setAddVis(false);setRecordRow(null);getCycPlan()}} recordRow={recordRow} pepList={pepList}></Addmodal>
</div> </div>

41
web/client/src/sections/service/containers/serviceRecord.jsx

@ -1,7 +1,7 @@
'use strict'; 'use strict';
import React, { useEffect,useState,useMemo } from 'react'; 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 moment from 'moment'
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import RecordModal from '../components/recordModal' import RecordModal from '../components/recordModal'
@ -53,24 +53,7 @@ const Server = (props) => {
const pagination={ 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') //console.log(recordList,'11111111')
@ -207,11 +190,29 @@ const addHandler=()=>{
</div> </div>
</div> </div>
<div style={{marginTop:10}}> <div style={{marginTop:10}}>
<Table columns={columns} dataSource={recordList} pagination={pagination} onHeaderRow={()=>{ <Table columns={columns} dataSource={recordList} pagination={false} onHeaderRow={()=>{
return { return {
background:'#000000', background:'#000000',
} }
}}/> }}/>
</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> </div>
<RecordModal visible={modalVis} onClose={() => { setModalVis(false);getRecordList();setRecordRow(null)}} recordRow={recordRow} pepList={pepList}></RecordModal> <RecordModal visible={modalVis} onClose={() => { setModalVis(false);getRecordList();setRecordRow(null)}} recordRow={recordRow} pepList={pepList}></RecordModal>
</div> </div>

65
web/client/src/sections/service/containers/temporaryResponse.jsx

@ -1,6 +1,6 @@
import React, { useEffect,useState } from 'react' import React, { useEffect,useState } from 'react'
import { connect } from 'react-redux' 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 moment from 'moment'
import TemporyModal from '../components/temporyModal' import TemporyModal from '../components/temporyModal'
@ -25,27 +25,27 @@ const SetControl = (props) => {
}) })
} }
// //
const pagination={ // const pagination={
total:total, // total:total,
defaultCurrent: 1, // defaultCurrent: 1,
pageSize:pageSize, // pageSize:pageSize,
showSizeChanger: true, // showSizeChanger: true,
currentPage:pageIndex, // currentPage:pageIndex,
showQuickJumper: true, // showQuickJumper: true,
pageSizeOpts: ["5", "10", "15"], // pageSizeOpts: ["5", "10", "15"],
showTotal: function () { // showTotal: function () {
return `共有${total}` // return `${total}`
}, // },
onChange:(pageIndex,pageSize)=>{ // onChange:(pageIndex,pageSize)=>{
console.log('pageIndex1',pageIndex,pageSize) // console.log('pageIndex1',pageIndex,pageSize)
setPageIndex(pageIndex) // setPageIndex(pageIndex)
setPageSize(pageSize) // setPageSize(pageSize)
const query={ // const query={
pageIndex,pageSize,type:'temp',msg:'获取临时响应' // pageIndex,pageSize,type:'temp',msg:''
} // }
getResponse(query) // getResponse(query)
} // }
} // }
useEffect(() => { useEffect(() => {
getResponse() getResponse()
dispatch(install.getOrganizationDeps()).then((res) => {//(PEP) dispatch(install.getOrganizationDeps()).then((res) => {//(PEP)
@ -128,7 +128,26 @@ const SetControl = (props) => {
<Button theme='solid' type='secondary' onClick={()=>{setAddVis(true)}}>新增</Button> <Button theme='solid' type='secondary' onClick={()=>{setAddVis(true)}}>新增</Button>
</div> </div>
<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> </div>
<TemporyModal visible={addVis} onClose={()=>{setAddVis(false);getResponse();setRecordRow(null)}} recordRow={recordRow} pepList={pepList}></TemporyModal> <TemporyModal visible={addVis} onClose={()=>{setAddVis(false);getResponse();setRecordRow(null)}} recordRow={recordRow} pepList={pepList}></TemporyModal>
</div> </div>

Loading…
Cancel
Save