From 0e266fab5326d307bc1041dfb42ece47a8e8a927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhaobing=E2=80=99?= Date: Wed, 27 Dec 2023 08:50:30 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9E=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E5=9E=8B=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/firmwareUpgrade/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/app/lib/controllers/firmwareUpgrade/index.js b/api/app/lib/controllers/firmwareUpgrade/index.js index eebd2ee..334c204 100644 --- a/api/app/lib/controllers/firmwareUpgrade/index.js +++ b/api/app/lib/controllers/firmwareUpgrade/index.js @@ -22,7 +22,7 @@ async function getDeviceType (ctx) { const { clickHouse } = ctx.app.fs const rlst = await clickHouse.iot.query(` 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 ('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','FS-iZD08pro') `).toPromise() ctx.body=rlst||[] ctx.status=200 From 396c9bf084a66e721eaba1ae61734798f4fce7b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhaobing=E2=80=99?= Date: Wed, 27 Dec 2023 09:36:05 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat:=E5=9B=BA=E4=BB=B6=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=8F=AF=E9=85=8D=E7=BD=AE=EF=BC=88?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=95=B0=E6=8D=AE=E5=BA=93=E8=A1=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/controllers/firmwareUpgrade/index.js | 12 +++++- api/app/lib/models/device_model.js | 35 +++++++++++++++++ .../4.1/data/1.insert_into_device_model.sql | 39 +++++++++++++++++++ script/4.1/schema/4.create_device_model.sql | 12 ++++++ 4 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 api/app/lib/models/device_model.js create mode 100644 script/4.1/data/1.insert_into_device_model.sql create mode 100644 script/4.1/schema/4.create_device_model.sql diff --git a/api/app/lib/controllers/firmwareUpgrade/index.js b/api/app/lib/controllers/firmwareUpgrade/index.js index 334c204..fba4fd6 100644 --- a/api/app/lib/controllers/firmwareUpgrade/index.js +++ b/api/app/lib/controllers/firmwareUpgrade/index.js @@ -17,12 +17,20 @@ const http = require('http'); //设备维护记录 async function getDeviceType (ctx) { try { - // const { models } = ctx.fs.dc + const { models } = ctx.fs.dc // const sequelize = ctx.fs.dc.ORM 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(` 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','FS-iZD08pro') + WHERE model in ${inClause} `).toPromise() ctx.body=rlst||[] ctx.status=200 diff --git a/api/app/lib/models/device_model.js b/api/app/lib/models/device_model.js new file mode 100644 index 0000000..80b5b24 --- /dev/null +++ b/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; +}; \ No newline at end of file diff --git a/script/4.1/data/1.insert_into_device_model.sql b/script/4.1/data/1.insert_into_device_model.sql new file mode 100644 index 0000000..19afb23 --- /dev/null +++ b/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') + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/script/4.1/schema/4.create_device_model.sql b/script/4.1/schema/4.create_device_model.sql new file mode 100644 index 0000000..352e429 --- /dev/null +++ b/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 '类型名字'; \ No newline at end of file From 2204f737be7958a75bd8e1f1a95a06cddfac2177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhaobing=E2=80=99?= Date: Wed, 27 Dec 2023 15:03:03 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat:=E5=9B=BA=E4=BB=B6=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E6=96=B0=E5=A2=9Emd5=E7=A0=81=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../firmwareUpgrade/components/addFirmwareModal.jsx | 5 ++++- .../firmwareUpgrade/containers/firmwareLibrary.jsx | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx b/web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx index 2d63471..479f7ac 100644 --- a/web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx +++ b/web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx @@ -57,6 +57,7 @@ const AddFirmwareModal = (props) => { .field('userId', userId||'') .field('firmwareName', res?.firmwareName||'') .field('comment',res?.remark||'') + .field('md5Value',res?.md5||'') .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'}) .end((err, response) => { @@ -108,11 +109,13 @@ const AddFirmwareModal = (props) => { 'deviceName':recordRow?.device_meta_id, 'versionNo':recordRow?.versionNo, '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' > + { + return -- + } +}, { title: '上传时间', dataIndex: 'uploadTime' @@ -77,6 +84,7 @@ let columns=[{ return {users?.find(item=>item.id==record.uploader)?.name||''} } }, + { title: '备注', dataIndex: 'comment' From d904c27d956344815d1fb980dce25f8e4f724e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhaobing=E2=80=99?= Date: Wed, 27 Dec 2023 16:01:36 +0800 Subject: [PATCH 4/5] feat:fix bugs --- .../sections/firmwareUpgrade/components/addFirmwareModal.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx b/web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx index 479f7ac..30206ac 100644 --- a/web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx +++ b/web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx @@ -57,7 +57,7 @@ const AddFirmwareModal = (props) => { .field('userId', userId||'') .field('firmwareName', res?.firmwareName||'') .field('comment',res?.remark||'') - .field('md5Value',res?.md5||'') + .field('md5Value',res?.md5Value||'') .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'}) .end((err, response) => { @@ -69,7 +69,7 @@ const AddFirmwareModal = (props) => { setRemoveFlag(false) onCancel() }else{ - console.error('Superagent request failed:'); + console.error('Superagent request failed:',err); Notification.error({ title: recordRow?'编辑固件包':'新增固件包', content: recordRow?'编辑失败':'新增失败', duration: 3, From 6ad67428900d4111089aca8a57f1b7b2ced379b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhaobing=E2=80=99?= Date: Wed, 27 Dec 2023 17:11:01 +0800 Subject: [PATCH 5/5] feat:fix bugs --- .../sections/firmwareUpgrade/components/addFirmwareModal.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx b/web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx index 30206ac..2bec96f 100644 --- a/web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx +++ b/web/client/src/sections/firmwareUpgrade/components/addFirmwareModal.jsx @@ -33,6 +33,7 @@ const AddFirmwareModal = (props) => { const okHandler= ()=>{ // console.log('fileObj',fileObj) api.current.validate().then(async (res)=>{ + console.log('x1112221',removeFlag,recordRow) // console.log('ressss',res) // const query = { // version:res?.versionNo, @@ -53,7 +54,7 @@ const AddFirmwareModal = (props) => { request.post(crawapi+'/firmwareupgrade') // .set('Content-Type','application/octet-stream') // .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('firmwareName', res?.firmwareName||'') .field('comment',res?.remark||'') @@ -130,6 +131,7 @@ const AddFirmwareModal = (props) => { onSuccess={(responseBody, file,all) => { // console.log('file111',file) setFileObj(file) + console.log('x1111',responseBody?.uploaded) setFileUrl(responseBody?.uploaded) setUploadData({ name: file.name,