CODE 1 year ago
parent
commit
6f4bb60c80
  1. 6
      api/app/lib/controllers/alarm/dataContinuity.js
  2. 2
      api/app/lib/controllers/firmwareUpgrade/index.js
  3. 103
      api/app/lib/models/alarm_data_continuity.js
  4. 5
      script/4.1/schema/1.update_alarm_data_continuity.sql
  5. 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 {
const { utils: { sendAppearToWeb }, clickHouse } = ctx.app.fs
const models = ctx.fs.dc.models;
const { type, file, } = ctx.request.body
const { type, file, fileUrl } = ctx.request.body
const now = moment().format()
if (!type) {
@ -24,7 +24,7 @@ async function postDataContinuity (ctx) {
}
await models.AlarmDataContinuity.create({
type, file, createTime: now
type, file, createTime: now, fileUrl
});
ctx.status = 204;
@ -183,7 +183,7 @@ async function dataContinuityList (ctx) {
let findOption = {
order: [['createTime', 'desc']],
where: {},
attributes: ['id', 'type', 'createTime'],
attributes: ['id', 'type', 'createTime', 'fileUrl'],
}
if (limit) {

2
api/app/lib/controllers/firmwareUpgrade/index.js

@ -279,7 +279,7 @@ async function getThingMessages(ctx){
try{
const {thingIds,device_meta_id,searchVal}=ctx.request.body
const res= await ctx.app.fs.craw.post(ApiTable.getThingMessages,{data:{thingIds,device_meta_id}})
const res= await ctx.app.fs.craw.post(ApiTable.getThingMessages,{query:{token:'22767e1f-db8d-4a1d-87d4-56347cf21247'},data:{thingIds,device_meta_id}})
// console.log('xxxxxx',res)
let rslt=[]
if(res){

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

@ -2,51 +2,60 @@
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const AlarmDataContinuity = sequelize.define("alarmDataContinuity", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "alarm_data_continuity_id_uindex"
},
file: {
type: DataTypes.TEXT,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "file",
autoIncrement: false
},
type: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "type",
autoIncrement: false
},
createTime: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "create_time",
autoIncrement: false
},
}, {
tableName: "alarm_data_continuity",
comment: "",
indexes: []
});
dc.models.AlarmDataContinuity = AlarmDataContinuity;
return AlarmDataContinuity;
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const AlarmDataContinuity = sequelize.define("alarmDataContinuity", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "alarm_data_continuity_id_uindex"
},
file: {
type: DataTypes.TEXT,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "file",
autoIncrement: false
},
type: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "type",
autoIncrement: false
},
createTime: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "create_time",
autoIncrement: false
},
fileUrl: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: null,
primaryKey: false,
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: '操作',
dataIndex: 'option',
render: (text, record, index) => {
return (
<Space>
<Button theme='borderless' type="primary" onClick={() => {
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'))
}
setLoading(false)
})
}}>
下载
</Button>
{
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()}`}>
下载
</a></Button>
: <Button theme='borderless' type="primary" onClick={() => {
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'))
}
setLoading(false)
})
}}>
下载
</Button>
}
<Button theme='borderless' type="primary" onClick={() => {
setCheckData(record);
setCheckVis(true);

Loading…
Cancel
Save