更新获取节点接口

master
pan 4 years ago
parent 65601fcede
commit 2fdb25579d
  1. 14
      routes/project/hazop.js
  2. 75
      routes/project/prepare.js

@ -16,11 +16,6 @@ router.get('/analyse/all', function (req, res, next) {
}]
})
Array.from(new Array(20).keys()).forEach(value => {
let t={t:`${JSON.stringify({node:Mock.Random.word(),id:Mock.Random.integer(1,10)})}`}
sst.si.push(t)
})
var data=Mock.mock({
...mock.ok(`HAZOP分析获取所有节点数据成功`),
@ -45,14 +40,7 @@ router.get('/analyse/all', function (req, res, next) {
r: `${col}${+row + 1}`,
s: 1,
t: 's',
v: (function (col){
switch (col){
case 'A':
return Mock.Random.integer(sst.si.length - 20, sst.si.length - 1)
default:
return Mock.Random.integer(0, sst.si.length - 21)
}
})(col)
v: Mock.Random.integer(0, sst.si.length - 1)
}
)
}

@ -24,19 +24,32 @@ router.get('/hdivide', function (req, res, next) {
})
router.get('/hdivide/all', function (req, res, next) {
var data=mock.page(req,'获取HAOZP节点划分成功',{
//节点id
id:/\d{3}/,
//节点
node:()=>Mock.Random.word(),
//节点编号
nodeId:/Node\d{3}/,
//节点描述
nodeDesc:()=>Mock.Random.sentence(3, 5),
var data=Mock.mock({
...mock.ok('获取所有HAOZP节点划分成功'),
...{
body:function (){
let obj={}
Array.from(new Array(20).keys()).forEach(value => {
obj[Mock.Random.integer(1,999)]=Mock.mock({
//节点
node:()=>Mock.Random.word(),
//节点编号
nodeId:/Node\d{3}/,
//节点描述
nodeDesc:()=>Mock.Random.sentence(3, 5),
//节点PID号
nodePid:/PID\d{3}/
})
})
return obj
}
}
})
res.json(data)
})
router.patch('/hdivide/:nodeId', function (req, res, next) {
var data=mock.ok(`节点${req.params.nodeId}更新成功`)
res.json(data)
@ -93,6 +106,50 @@ router.get('/sdivide/:nodeId', function (req, res, next) {
res.json(data)
})
router.get('/sdivide/:nodeId/all', function (req, res, next) {
var data=Mock.mock({
...mock.ok('获取所有HAOZP节点划分成功'),
...{
body:function (){
let obj={}
Array.from(new Array(20).keys()).forEach(value => {
obj[Mock.Random.integer(1,999)]=Mock.mock({
//sif_id
id:/\d{3}/,
//SIF名称
name:()=>Mock.Random.name(),
//SIF编号
sifId:/SIF\d{3}/,
//SIF描述
desc:()=>Mock.Random.sentence(3, 5),
//SIF连带动作
action:()=>Mock.Random.word(),
//需求模式
demandModel:()=>`${Mock.Random.integer(1,3)}`,
//SIL等级要求
level:()=>Mock.Random.integer(1,10),
//触发机构
impactMmechanism:()=>Mock.Random.word(),
//后果描述
consequence:()=>Mock.Random.sentence(3, 5),
//安全状态
status:()=>Mock.Random.word(),
//安全失效等级
loseEfficacy:()=>Mock.Random.integer(1,10),
//PID号
pid:/PID\d{3}/,
//备注
note:()=>Mock.Random.sentence(3, 5)
})
})
return obj
}
}
})
res.json(data)
})
router.patch('/sdivide/:nodeId/:id', function (req, res, next) {
var data=mock.ok(`节点:${req.params.nodeId},SIF:${req.params.id}更新成功`)
res.json(data)

Loading…
Cancel
Save