|
|
@ -15,6 +15,7 @@ router.get('/analyse/:id', function (req, res, next) { |
|
|
|
t:/\d{3}/ |
|
|
|
t:/\d{3}/ |
|
|
|
}] |
|
|
|
}] |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
sst.si.push({t:`<span style="color:${Mock.Random.color()}">${Mock.Random.word()}</span><span style="color:${Mock.Random.color()}">${Mock.Random.word()}</span>`}) |
|
|
|
|
|
|
|
|
|
|
|
var data=Mock.mock({ |
|
|
|
var data=Mock.mock({ |
|
|
|
...mock.ok(`HAZOP分析获取节点${req.params.id}数据成功`), |
|
|
|
...mock.ok(`HAZOP分析获取节点${req.params.id}数据成功`), |
|
|
@ -23,7 +24,7 @@ router.get('/analyse/:id', function (req, res, next) { |
|
|
|
sst, |
|
|
|
sst, |
|
|
|
sheetData:{ |
|
|
|
sheetData:{ |
|
|
|
row:function (){ |
|
|
|
row:function (){ |
|
|
|
let rowCount=20 |
|
|
|
let rowCount=50 |
|
|
|
let colCount=18 |
|
|
|
let colCount=18 |
|
|
|
let rows=Array.from(new Array(rowCount).keys()) |
|
|
|
let rows=Array.from(new Array(rowCount).keys()) |
|
|
|
let cols=Array.from(new Array(colCount).keys()) |
|
|
|
let cols=Array.from(new Array(colCount).keys()) |
|
|
@ -34,12 +35,21 @@ router.get('/analyse/:id', function (req, res, next) { |
|
|
|
c:[] |
|
|
|
c:[] |
|
|
|
} |
|
|
|
} |
|
|
|
for(let col in cols){ |
|
|
|
for(let col in cols){ |
|
|
|
|
|
|
|
col=String.fromCharCode(+col+"A".charCodeAt()) |
|
|
|
rows[row].c.push({ |
|
|
|
rows[row].c.push({ |
|
|
|
r:`${String.fromCharCode(+col+"A".charCodeAt())}${+row+1}`, |
|
|
|
r: `${col}${+row + 1}`, |
|
|
|
s:1, |
|
|
|
s: 1, |
|
|
|
t:'s', |
|
|
|
t: 's', |
|
|
|
v:Mock.Random.integer(0,sst.si.length-1) |
|
|
|
v: (function (col) { |
|
|
|
}) |
|
|
|
switch (col) { |
|
|
|
|
|
|
|
case 'C': |
|
|
|
|
|
|
|
return sst.si.length - 1 |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
return Mock.Random.integer(0, sst.si.length - 2) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
})(col) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return rows |
|
|
|
return rows |
|
|
@ -55,13 +65,98 @@ router.get('/analyse/:id', function (req, res, next) { |
|
|
|
res.json(data) |
|
|
|
res.json(data) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取当前项目使用矩阵
|
|
|
|
|
|
|
|
router.get('/analyse/matrix/:name', function (req, res, next) { |
|
|
|
|
|
|
|
var data=Mock.mock({ |
|
|
|
|
|
|
|
...mock.ok('获取矩阵详情成功'), |
|
|
|
|
|
|
|
...{ |
|
|
|
|
|
|
|
body:{ |
|
|
|
|
|
|
|
id:()=>Mock.Random.natural(1,1000), |
|
|
|
|
|
|
|
"useProjectId|0-2":[/\d{3}/], |
|
|
|
|
|
|
|
info:{ |
|
|
|
|
|
|
|
name:`matrix${Mock.Random.natural(5,8)}`, |
|
|
|
|
|
|
|
desc:`matrix${Mock.Random.natural(5,8)}`, |
|
|
|
|
|
|
|
x:()=>Mock.Random.natural(5,8), |
|
|
|
|
|
|
|
y:()=>Mock.Random.natural(5,8), |
|
|
|
|
|
|
|
explain:()=>Mock.Random.sentence(3, 5) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
severity:function (){ |
|
|
|
|
|
|
|
const severity=[] |
|
|
|
|
|
|
|
for(let i in Array.from(new Array(this.info.y).keys())){ |
|
|
|
|
|
|
|
severity.push({ |
|
|
|
|
|
|
|
//等级
|
|
|
|
|
|
|
|
level:Mock.Random.natural(1,9), |
|
|
|
|
|
|
|
//严重程度
|
|
|
|
|
|
|
|
severity:Mock.Random.natural(1,9), |
|
|
|
|
|
|
|
//人员
|
|
|
|
|
|
|
|
personnel:Mock.Random.word(), |
|
|
|
|
|
|
|
//财产
|
|
|
|
|
|
|
|
property:Mock.Random.word(), |
|
|
|
|
|
|
|
//环境
|
|
|
|
|
|
|
|
environment:Mock.Random.word(), |
|
|
|
|
|
|
|
//声誉
|
|
|
|
|
|
|
|
prestige:Mock.Random.word() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return severity |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
possibility:function (){ |
|
|
|
|
|
|
|
const possibility=[] |
|
|
|
|
|
|
|
for(let i in Array.from(new Array(this.info.x).keys())){ |
|
|
|
|
|
|
|
possibility.push({ |
|
|
|
|
|
|
|
//等级
|
|
|
|
|
|
|
|
level:Mock.Random.natural(1,this.info.x), |
|
|
|
|
|
|
|
//概率值
|
|
|
|
|
|
|
|
probability:Mock.Random.natural(1,100)/100, |
|
|
|
|
|
|
|
//描述
|
|
|
|
|
|
|
|
desc:Mock.Random.sentence(3, 5) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return possibility |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
'level|3-5':[{ |
|
|
|
|
|
|
|
id:/\d{3}/, |
|
|
|
|
|
|
|
//Code
|
|
|
|
|
|
|
|
code:/\d{1}/, |
|
|
|
|
|
|
|
//颜色
|
|
|
|
|
|
|
|
color:()=>Mock.Random.color(), |
|
|
|
|
|
|
|
//描述
|
|
|
|
|
|
|
|
desc:()=>Mock.Random.sentence(3, 5), |
|
|
|
|
|
|
|
//风险等级
|
|
|
|
|
|
|
|
level:/\d{1}/, |
|
|
|
|
|
|
|
//应采取措施
|
|
|
|
|
|
|
|
measure:()=>Mock.Random.sentence(3, 5), |
|
|
|
|
|
|
|
//实施期限
|
|
|
|
|
|
|
|
date:()=>Mock.Random.sentence(3, 5), |
|
|
|
|
|
|
|
//备注
|
|
|
|
|
|
|
|
note:()=>Mock.Random.sentence(3, 5) |
|
|
|
|
|
|
|
}], |
|
|
|
|
|
|
|
matrix:function (){ |
|
|
|
|
|
|
|
const matrix=[] |
|
|
|
|
|
|
|
for(let i in Array.from(new Array(this.info.y).keys())){ |
|
|
|
|
|
|
|
const child=[] |
|
|
|
|
|
|
|
for(let j in Array.from(new Array(this.info.x).keys())){ |
|
|
|
|
|
|
|
child.push(this.level[Mock.Random.natural(0,this.level.length-1)]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
matrix.push(child) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return matrix |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
res.json(data) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
route.addContextMenu(router,'analyse/:id','HAZOP分析') |
|
|
|
route.addContextMenu(router,'analyse/:id','HAZOP分析') |
|
|
|
|
|
|
|
|
|
|
|
//HAZOP偏差知识库
|
|
|
|
//HAZOP偏差知识库
|
|
|
|
router.get('/analyse/repository/:know', function (req, res, next) { |
|
|
|
router.get('/analyse/repository/:know', function (req, res, next) { |
|
|
|
var data=mock.page(req,`查询${req.params.know}知识库成功`,{ |
|
|
|
var data=mock.page(req,`查询${req.params.know}知识库成功`,{ |
|
|
|
//选项值
|
|
|
|
//选项值
|
|
|
|
key: ()=>Mock.Random.integer(1,5), |
|
|
|
key: ()=>Mock.Random.word(), |
|
|
|
//描述
|
|
|
|
//描述
|
|
|
|
value: ()=>Mock.Random.word() |
|
|
|
value: ()=>Mock.Random.word() |
|
|
|
}) |
|
|
|
}) |
|
|
|