增加lopa接口

master
pan 4 years ago
parent 2fdb25579d
commit 1774693c36
  1. 3
      app.js
  2. 13
      routes/project/hazop.js
  3. 81
      routes/project/lopa.js

@ -13,6 +13,7 @@ var projectDetailRouter=require('./routes/project/project')
var infoRouter=require('./routes/project/info') var infoRouter=require('./routes/project/info')
var prepareRouter=require('./routes/project/prepare') var prepareRouter=require('./routes/project/prepare')
var hazopRouter=require('./routes/project/hazop') var hazopRouter=require('./routes/project/hazop')
var lopaRouter=require('./routes/project/lopa')
const server = require("inspector"); const server = require("inspector");
var app = express(); var app = express();
@ -36,7 +37,7 @@ app.use(cors({
app.use('/', indexRouter); app.use('/', indexRouter);
app.use('/api/account',accountRouter) app.use('/api/account',accountRouter)
app.use('/api/main',mainRouter,projectRouter,dataRouter) app.use('/api/main',mainRouter,projectRouter,dataRouter)
app.use('/api/project',projectDetailRouter,infoRouter,prepareRouter,hazopRouter) app.use('/api/project',projectDetailRouter,infoRouter,prepareRouter,hazopRouter,lopaRouter)
// catch 404 and forward to error handler // catch 404 and forward to error handler
app.use(function(req, res, next) { app.use(function(req, res, next) {

@ -195,15 +195,16 @@ router.get('/analyse/matrix/:name', function (req, res, next) {
res.json(data) res.json(data)
}) })
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}知识库成功`,{
//选项值 //id
key: ()=>Mock.Random.word(), value:/\d{3}/,
//描述 //描述
value: ()=>Mock.Random.word() label: ()=>Mock.Random.word(),
data:function(){
return this.label
}
}) })
res.json(data) res.json(data)
}) })

@ -0,0 +1,81 @@
var express = require('express');
var router = express.Router();
var mock = require('../../public/javascripts/mock')
var Mock = require("mockjs")
var multipart = require('connect-multiparty');
var multipartMiddleware = multipart();
var moment = require("moment")
var util=require("../../public/javascripts/util")
var route=require('../../public/javascripts/route')
//LOPA知识库
router.get('/lopa/repository/:know', function (req, res, next) {
var data=mock.page(req,`查询${req.params.know}知识库成功`,{...{
//id
value:/\d{3}/,
//描述
label: ()=>Mock.Random.word()
},...(function(col){switch (col){
case "initialEventDescription":
return {
initialEventDescription:function (){
return this.label
},
initialEventProbability:()=>Mock.Random.float(0,1)
}
}})(req.params.know)})
res.json(data)
})
//lopa
router.get('/lopa/:id/:sif', function (req, res, next) {
var sst=Mock.mock({
"si|1-100":[{
t:/\d{3}/
}]
})
var data=Mock.mock({
...mock.ok(`LOPA获取节点${req.params.id},${req.params.sif}数据成功`),
...{
body:{
sst,
sheetData:{
row:function (){
let rowCount=50
let colCount=21
let rows=Array.from(new Array(rowCount).keys())
let cols=Array.from(new Array(colCount).keys())
for(let row in rows){
rows[+row]={
r:+row+1,
spans:`1:${colCount}`,
c:[]
}
for(let col in cols){
col=String.fromCharCode(+col+"A".charCodeAt())
rows[row].c.push({
r: `${col}${+row + 1}`,
s: 1,
t: 's',
v: Mock.Random.integer(0, sst.si.length - 1)
}
)
}
}
return rows
}
},
mergeCells:{
mergeCell:[],
count:0
}
}
}
})
res.json(data)
})
module.exports=router
Loading…
Cancel
Save