Browse Source

数据监测下载修改

dev
wenlele 1 year ago
parent
commit
c4e4936231
  1. 6
      api/app/lib/controllers/alarm/dataContinuity.js
  2. 103
      api/app/lib/models/alarm_data_continuity.js
  3. 5
      script/4.1/schema/1.update_alarm_data_continuity.sql
  4. 27
      web/client/src/sections/data/containers/dataQuery.jsx

6
api/app/lib/controllers/alarm/dataContinuity.js

@ -9,7 +9,7 @@ async function postDataContinuity (ctx) {
try { try {
const { utils: { sendAppearToWeb }, clickHouse } = ctx.app.fs const { utils: { sendAppearToWeb }, clickHouse } = ctx.app.fs
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { type, file, } = ctx.request.body const { type, file, fileUrl } = ctx.request.body
const now = moment().format() const now = moment().format()
if (!type) { if (!type) {
@ -24,7 +24,7 @@ async function postDataContinuity (ctx) {
} }
await models.AlarmDataContinuity.create({ await models.AlarmDataContinuity.create({
type, file, createTime: now type, file, createTime: now, fileUrl
}); });
ctx.status = 204; ctx.status = 204;
@ -183,7 +183,7 @@ async function dataContinuityList (ctx) {
let findOption = { let findOption = {
order: [['createTime', 'desc']], order: [['createTime', 'desc']],
where: {}, where: {},
attributes: ['id', 'type', 'createTime'], attributes: ['id', 'type', 'createTime', 'fileUrl'],
} }
if (limit) { if (limit) {

103
api/app/lib/models/alarm_data_continuity.js

@ -2,51 +2,60 @@
'use strict'; 'use strict';
module.exports = dc => { module.exports = dc => {
const DataTypes = dc.ORM; const DataTypes = dc.ORM;
const sequelize = dc.orm; const sequelize = dc.orm;
const AlarmDataContinuity = sequelize.define("alarmDataContinuity", { const AlarmDataContinuity = sequelize.define("alarmDataContinuity", {
id: { id: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
allowNull: false, allowNull: false,
defaultValue: null, defaultValue: null,
comment: null, comment: null,
primaryKey: true, primaryKey: true,
field: "id", field: "id",
autoIncrement: true, autoIncrement: true,
unique: "alarm_data_continuity_id_uindex" unique: "alarm_data_continuity_id_uindex"
}, },
file: { file: {
type: DataTypes.TEXT, type: DataTypes.TEXT,
allowNull: false, allowNull: false,
defaultValue: null, defaultValue: null,
comment: null, comment: null,
primaryKey: false, primaryKey: false,
field: "file", field: "file",
autoIncrement: false autoIncrement: false
}, },
type: { type: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
allowNull: false, allowNull: false,
defaultValue: null, defaultValue: null,
comment: null, comment: null,
primaryKey: false, primaryKey: false,
field: "type", field: "type",
autoIncrement: false autoIncrement: false
}, },
createTime: { createTime: {
type: DataTypes.DATE, type: DataTypes.DATE,
allowNull: false, allowNull: false,
defaultValue: null, defaultValue: null,
comment: null, comment: null,
primaryKey: false, primaryKey: false,
field: "create_time", field: "create_time",
autoIncrement: false autoIncrement: false
}, },
}, { fileUrl: {
tableName: "alarm_data_continuity", type: DataTypes.STRING,
comment: "", allowNull: true,
indexes: [] defaultValue: null,
}); comment: null,
dc.models.AlarmDataContinuity = AlarmDataContinuity; primaryKey: false,
return AlarmDataContinuity; field: "file_url",
autoIncrement: false
},
}, {
tableName: "alarm_data_continuity",
comment: "",
indexes: []
});
dc.models.AlarmDataContinuity = AlarmDataContinuity;
return AlarmDataContinuity;
}; };

5
script/4.1/schema/1.update_alarm_data_continuity.sql

@ -0,0 +1,5 @@
alter table alarm_data_continuity
add file_url varchar;
comment on column alarm_data_continuity.file_url is '文件地址';

27
web/client/src/sections/data/containers/dataQuery.jsx

@ -121,18 +121,25 @@ const DataQuery = (props) => {
title: '操作', title: '操作',
dataIndex: 'option', dataIndex: 'option',
render: (text, record, index) => { render: (text, record, index) => {
return ( return (
<Space> <Space>
<Button theme='borderless' type="primary" onClick={() => { {
dispatch(sectionData.getContinuityDetail(record.id)).then(res => { record?.fileUrl ? <Button theme='borderless' type='primary' style={{ marginRight: 8 }} ><a href={`/_file-server/${record.fileUrl + '?filename=' + (record?.alarmDataContinuityType?.name || dataContinuityType?.find(d => d.typeNumber == record.type)?.name) + moment(record.createTime).format('YYYY-MM-DD HH:mm:ss') + '.' + record?.fileUrl?.split('.').pop()}`}>
if (res.success) { 下载
downloadWord(res.payload?.data?.file || '', (record?.alarmDataContinuityType?.name || dataContinuityType?.find(d => d.typeNumber == record.type)?.name) + moment(record.createTime).format('YYYY-MM-DD HH:mm:ss')) </a></Button>
} : <Button theme='borderless' type="primary" onClick={() => {
setLoading(false) dispatch(sectionData.getContinuityDetail(record.id)).then(res => {
}) if (res.success) {
}}> downloadWord(res.payload?.data?.file || '', (record?.alarmDataContinuityType?.name || dataContinuityType?.find(d => d.typeNumber == record.type)?.name) + moment(record.createTime).format('YYYY-MM-DD HH:mm:ss'))
下载 }
</Button> setLoading(false)
})
}}>
下载
</Button>
}
<Button theme='borderless' type="primary" onClick={() => { <Button theme='borderless' type="primary" onClick={() => {
setCheckData(record); setCheckData(record);
setCheckVis(true); setCheckVis(true);

Loading…
Cancel
Save