wenlele 1 year ago
parent
commit
47b60d0b36
  1. 12
      api/app/lib/controllers/firmwareUpgrade/index.js
  2. 35
      api/app/lib/models/device_model.js
  3. 39
      script/4.1/data/1.insert_into_device_model.sql
  4. 12
      script/4.1/schema/4.create_device_model.sql
  5. 11
      web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx
  6. 8
      web/client/src/sections/firmwareUpgrade/containers/firmwareLibrary.jsx

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

@ -17,12 +17,20 @@ const http = require('http');
//设备维护记录 //设备维护记录
async function getDeviceType (ctx) { async function getDeviceType (ctx) {
try { try {
// const { models } = ctx.fs.dc const { models } = ctx.fs.dc
// const sequelize = ctx.fs.dc.ORM // const sequelize = ctx.fs.dc.ORM
const { clickHouse } = ctx.app.fs const { clickHouse } = ctx.app.fs
const res = await models.DeviceModel.findAll({attributes:['model_name']})
let modelName=new Set()
modelName.add(-11)
for (let { dataValues: c } of res) {
modelName.add(c.model_name)
}
const inClause = `(${Array.from(modelName).map(item => `'${item}'`).join(',')})`;
console.log(inClause)
const rlst = await clickHouse.iot.query(` const rlst = await clickHouse.iot.query(`
SELECT id,model FROM DeviceMeta SELECT id,model FROM DeviceMeta
WHERE model in ('FS-YTSW','FS-YTDZ-GD','FS-iFWL-ZXSJ','ZSJ-iVW08','FS-Q90-NHB1-HC','FS-RTU-P4-SL','FS-RTU-SL','FS-V08','FS-M24','FS-LPWAN08','FS-RTU-SL','FS-RTU-P4-SL') WHERE model in ${inClause}
`).toPromise() `).toPromise()
ctx.body=rlst||[] ctx.body=rlst||[]
ctx.status=200 ctx.status=200

35
api/app/lib/models/device_model.js

@ -0,0 +1,35 @@
/* eslint-disable*/
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const DeviceModel = sequelize.define("deviceModel", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "device_model_pk"
},
modelName: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "model_name",
autoIncrement: false
},
}, {
tableName: "device_model",
comment: "",
indexes: []
});
dc.models.DeviceModel = DeviceModel;
return DeviceModel;
};

39
script/4.1/data/1.insert_into_device_model.sql

@ -0,0 +1,39 @@
insert into device_model ( model_name)
values ('FS-iZD08pro'),
('FS-YTSW'),
('FS-YTDZ-GD'),
('FS-iFWL-ZXSJ'),
('ZSJ-iVW08'),
('FS-Q90-NHB1-HC'),
('FS-RTU-P4-SL'),
('FS-RTU-SL'),
('FS-V08'),
( 'FS-M24'),
( 'FS-LPWAN08'),
( 'FS-RTU-SL'),
( 'FS-RTU-P4-SL')

12
script/4.1/schema/4.create_device_model.sql

@ -0,0 +1,12 @@
create table device_model
(
id serial
constraint device_model_pk
primary key,
model_name text
);
comment on table device_model is '设备类型表';
comment on column device_model.model_name is '类型名字';

11
web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx

@ -33,6 +33,7 @@ const AddFirmwareModal = (props) => {
const okHandler= ()=>{ const okHandler= ()=>{
// console.log('fileObj',fileObj) // console.log('fileObj',fileObj)
api.current.validate().then(async (res)=>{ api.current.validate().then(async (res)=>{
console.log('x1112221',removeFlag,recordRow)
// console.log('ressss',res) // console.log('ressss',res)
// const query = { // const query = {
// version:res?.versionNo, // version:res?.versionNo,
@ -53,10 +54,11 @@ const AddFirmwareModal = (props) => {
request.post(crawapi+'/firmwareupgrade') request.post(crawapi+'/firmwareupgrade')
// .set('Content-Type','application/octet-stream') // .set('Content-Type','application/octet-stream')
// .attach('file',blobData,removeFlag?fileObj.name:recordRow?recordRow.firmwareName:fileObj.name) // .attach('file',blobData,removeFlag?fileObj.name:recordRow?recordRow.firmwareName:fileObj.name)
.field('filePath',removeFlag?`${domain}/`+fileUrl:recordRow?`${domain}/`+recordRow.filepath:`${domain}/`+fileUrl) .field('filePath',removeFlag?`${domain}/`+fileUrl : recordRow?recordRow.filepath : `${domain}/`+fileUrl)
.field('userId', userId||'') .field('userId', userId||'')
.field('firmwareName', res?.firmwareName||'') .field('firmwareName', res?.firmwareName||'')
.field('comment',res?.remark||'') .field('comment',res?.remark||'')
.field('md5Value',res?.md5Value||'')
.field('device_meta_name', options?.find(item=>item.value===res?.deviceName)?.label||'') .field('device_meta_name', options?.find(item=>item.value===res?.deviceName)?.label||'')
.query({ version:res?.versionNo,device_meta_id: res?.deviceName,token:'22767e1f-db8d-4a1d-87d4-56347cf21247'}) .query({ version:res?.versionNo,device_meta_id: res?.deviceName,token:'22767e1f-db8d-4a1d-87d4-56347cf21247'})
.end((err, response) => { .end((err, response) => {
@ -68,7 +70,7 @@ const AddFirmwareModal = (props) => {
setRemoveFlag(false) setRemoveFlag(false)
onCancel() onCancel()
}else{ }else{
console.error('Superagent request failed:'); console.error('Superagent request failed:',err);
Notification.error({ title: recordRow?'编辑固件包':'新增固件包', Notification.error({ title: recordRow?'编辑固件包':'新增固件包',
content: recordRow?'编辑失败':'新增失败', content: recordRow?'编辑失败':'新增失败',
duration: 3, duration: 3,
@ -108,11 +110,13 @@ const AddFirmwareModal = (props) => {
'deviceName':recordRow?.device_meta_id, 'deviceName':recordRow?.device_meta_id,
'versionNo':recordRow?.versionNo, 'versionNo':recordRow?.versionNo,
'files':recordRow?[{ url: `${domain}/${recordRow?.filepath}`, name: recordRow?.filepath.split('/')[recordRow?.filepath.split('/')?.length-1] }]:[], 'files':recordRow?[{ url: `${domain}/${recordRow?.filepath}`, name: recordRow?.filepath.split('/')[recordRow?.filepath.split('/')?.length-1] }]:[],
'remark':recordRow?.remark 'remark':recordRow?.remark,
'md5Value':recordRow?.md5Value,
}} getFormApi={formApi => api.current = formApi} labelCol={{ span: 7,offset:1}} wrapperCol={{span: 15,offset:1}} labelPosition='left' > }} getFormApi={formApi => api.current = formApi} labelCol={{ span: 7,offset:1}} wrapperCol={{span: 15,offset:1}} labelPosition='left' >
<Form.Input field='firmwareName' label='固件版本名称:' style={{with:'80%'}} rules={[{ required: true, message: '固件版本名称必填' }]}></Form.Input> <Form.Input field='firmwareName' label='固件版本名称:' style={{with:'80%'}} rules={[{ required: true, message: '固件版本名称必填' }]}></Form.Input>
<Form.Select disabled={recordRow?true:false} field='deviceName' label='设备型号:' placeholder='请选择设备型号' optionList={options} rules={[{ required: true, message: '设备型号必填' }]}></Form.Select> <Form.Select disabled={recordRow?true:false} field='deviceName' label='设备型号:' placeholder='请选择设备型号' optionList={options} rules={[{ required: true, message: '设备型号必填' }]}></Form.Select>
<Form.Input disabled={recordRow?true:false} field='versionNo' label='版本号:' rules={[{ required: true, message: '版本号必填' }]}></Form.Input> <Form.Input disabled={recordRow?true:false} field='versionNo' label='版本号:' rules={[{ required: true, message: '版本号必填' }]}></Form.Input>
<Form.Input field='md5Value' label='MD5码值:' rules={[{ required: true, message: 'MD5码值必填' }]}></Form.Input>
<Form.Upload limit={1} <Form.Upload limit={1}
// action={`/file/uploadLocal&token=` + user.token} // action={`/file/uploadLocal&token=` + user.token}
// action={`/file/uploadLocal&token=` + user.token} // action={`/file/uploadLocal&token=` + user.token}
@ -127,6 +131,7 @@ const AddFirmwareModal = (props) => {
onSuccess={(responseBody, file,all) => { onSuccess={(responseBody, file,all) => {
// console.log('file111',file) // console.log('file111',file)
setFileObj(file) setFileObj(file)
console.log('x1111',responseBody?.uploaded)
setFileUrl(responseBody?.uploaded) setFileUrl(responseBody?.uploaded)
setUploadData({ setUploadData({
name: file.name, name: file.name,

8
web/client/src/sections/firmwareUpgrade/containers/firmwareLibrary.jsx

@ -67,6 +67,13 @@ let columns=[{
title: '版本号', title: '版本号',
dataIndex: 'versionNo' dataIndex: 'versionNo'
}, },
{
title:'MD5码值',
dataIndex: 'md5Value',
render:(_,record)=>{
return <span>--</span>
}
},
{ {
title: '上传时间', title: '上传时间',
dataIndex: 'uploadTime' dataIndex: 'uploadTime'
@ -77,6 +84,7 @@ let columns=[{
return <span>{users?.find(item=>item.id==record.uploader)?.name||''}</span> return <span>{users?.find(item=>item.id==record.uploader)?.name||''}</span>
} }
}, },
{ {
title: '备注', title: '备注',
dataIndex: 'comment' dataIndex: 'comment'

Loading…
Cancel
Save