diff --git a/app.js b/app.js index b17c851..6dae199 100644 --- a/app.js +++ b/app.js @@ -3,7 +3,7 @@ const moment = require('moment'); const path = require('path') const chalk = require('chalk') const PNG16Convertor = require('./app/microprogram/PNG16Convertor.js'); -const child_process = require('child_process'); +// const child_process = require('child_process'); module.exports = app => { app.beforeStart(async () => { // 应用会等待这个函数执行完成才启动 @@ -15,21 +15,21 @@ module.exports = app => { // } catch (error) { // throw new Error('初始化数据失败', error); // } - ['DICOM', 'SCP_STORE'].forEach(element => { - try { - ctx.service.util.createDirectory(path.join(__dirname, `app/public/${element}`)) - } catch (error) { - console.error(error) - } - }); + // ['DICOM', 'SCP_STORE'].forEach(element => { + // try { + // ctx.service.util.createDirectory(path.join(__dirname, `app/public/${element}`)) + // } catch (error) { + // console.error(error) + // } + // }); // child_process.exec(CMD, (error, stderr, stdout) => { // }) - // try { - // await ctx.service.util.storesPython() - // } catch (error) { - // console.error(error) - // } + try { + await ctx.service.util.storesPython() + } catch (error) { + console.error(error) + } moment.locale('zh-cn') diff --git a/app/controller/pacs.js b/app/controller/pacs.js index 70f93b0..908191a 100644 --- a/app/controller/pacs.js +++ b/app/controller/pacs.js @@ -4,13 +4,13 @@ const BaseController = require("./base"); const fs = require("fs"); const path = require("path"); -function getObjectMkdir (url) { +function getObjectMkdir(url) { let index = url.lastIndexOf("/") - let a = url.substring(0,index); + let a = url.substring(0, index); return a } -function getObjectName (url) { +function getObjectName(url) { var value = url var str = value.split("/"); //https://进行分割, var name = str[str.length - 1] @@ -18,7 +18,7 @@ function getObjectName (url) { } function parseDicomFile(file, uploadQueues, path) { - return new Promise(function(resolve, reject) { + return new Promise(function (resolve, reject) { try { var data = dicomParser.parseDicom(file) var studyUid = data.string('x0020000d') @@ -26,7 +26,7 @@ function parseDicomFile(file, uploadQueues, path) { while ( studyIndex < uploadQueues.length && uploadQueues[studyIndex].dicomInfo.studyUid !== studyUid - ) { + ) { ++studyIndex } if (studyIndex >= uploadQueues.length) { @@ -40,7 +40,7 @@ function parseDicomFile(file, uploadQueues, path) { if (time) { time = `${time.substring(0, 2)}:${time.substring(2, 4)}:${time.substring(4, 6)}` } - if(date){ + if (date) { studyTime = time ? `${date} ${time}` : `${date} 00:00:00` } uploadQueues.push({ @@ -85,7 +85,7 @@ function parseDicomFile(file, uploadQueues, path) { while ( instanceIndex < fileList.length && fileList[instanceIndex].instanceUid !== instanceUid - ) { + ) { ++instanceIndex } if (instanceIndex >= fileList.length) { @@ -97,7 +97,7 @@ function parseDicomFile(file, uploadQueues, path) { var seriesUid = data.string('x0020000e') var seriesList = uploadQueues[studyIndex].seriesList - var seriesItem = seriesList.find(function(item) { + var seriesItem = seriesList.find(function (item) { return item.seriesUid === seriesUid }) if (!seriesItem) { @@ -111,7 +111,7 @@ function parseDicomFile(file, uploadQueues, path) { seriesList.push(seriesItem) } var instanceList = seriesItem.instanceList - var instanceItem = instanceList.find(function(item) { + var instanceItem = instanceList.find(function (item) { return item.instanceUid === instanceUid }) if (!instanceItem) { @@ -139,12 +139,12 @@ class PacsController extends BaseController { super(props); } //获取pacs位置 - async getPACS(){ - try{ + async getPACS() { + try { console.log(this.ctx.request.query) let pacs = await this.ctx.model.Pacs.find(this.ctx.request.query).select("_id aet host port mode description") return this.success(pacs) - }catch (error) { + } catch (error) { return this.error(error) } } @@ -156,11 +156,13 @@ class PacsController extends BaseController { TaskCode: 'string', }) let config = await this.service.config.getConfig(); + console.log(config, 'config') let a = await this.ctx.service.pacs.findFromPacs(this.ctx.request.body, config) + console.log(a, 'a') if (a) { - let $in = a.map(v => {return v.SeriesInstanceUID}) + let $in = a.map(v => { return v.SeriesInstanceUID }) console.log($in) - let list = await this.ctx.model.Series.find({SeriesInstanceUID: {$in: $in}}) + let list = await this.ctx.model.Series.find({ SeriesInstanceUID: { $in: $in } }) // let list = await this.ctx.model.Pacs.find({}) console.log(list) let newA = a.map(v => { @@ -196,7 +198,7 @@ class PacsController extends BaseController { TaskCode: 'string', seriesList: 'array' }) - let {pacs_id, seriesList,trialId,siteId,subjectId,subjectVisitId, userName, userId, task_id, trialCode, subjectCode, TaskCode} = this.ctx.request.body + let { pacs_id, seriesList, trialId, siteId, subjectId, subjectVisitId, userName, userId, task_id, trialCode, subjectCode, TaskCode } = this.ctx.request.body let config = await this.service.config.getConfig(); for (let i = 0; i < seriesList.length; i++) { let series = seriesList[i] @@ -210,7 +212,7 @@ class PacsController extends BaseController { userName: userName, userId: userId } - }, {upsert: true, new: true}) + }, { upsert: true, new: true }) } let directoryPath = config.ossPacsPath + `/${trialCode}/${subjectCode}/${TaskCode}/${userId}/` let pathList = fs.readdirSync(directoryPath) @@ -220,7 +222,7 @@ class PacsController extends BaseController { let file = fs.readFileSync(item) await parseDicomFile(file, uploadQueues, item) } - console.log(uploadQueues) + console.log(uploadQueues, 'uploadQueues') const Authorization = this.ctx.get('Authorization'); let arr = [] for (let i = 0; i < uploadQueues.length; ++i) { @@ -235,7 +237,7 @@ class PacsController extends BaseController { visitTaskId: task_id, Authorization: Authorization, } - arr.push(this.ctx.service.pacs.archiveStudy(uploadQueues, i ,info, config)) + arr.push(this.ctx.service.pacs.archiveStudy(uploadQueues, i, info, config)) } let a = await Promise.all(arr) // 获取 @@ -245,7 +247,7 @@ class PacsController extends BaseController { } } async pushImage() { - try{ + try { this.ctx.validate({ pacs_id: 'string', imagesList: 'array', @@ -257,10 +259,12 @@ class PacsController extends BaseController { let { pacs_id, imagesList, task_id, trialCode, subjectCode, TaskCode } = this.ctx.request.body - let pacs = await this.ctx.model.Pacs.findOne({_id: pacs_id}) - let config = await this.service.config.getConfig(); - let downloadErrorList = [], downloadsuccessList = [] + let pacs = await this.ctx.model.Pacs.findOne({ _id: pacs_id }) + // let config = await this.service.config.getConfig(); + let config = {} + let downloadErrorList = [], downloadsuccessList = [] let studyList = [] + config.ossPacsPath = path.join(__dirname, "../public/DICOM") for (let i = 0; i < imagesList.length; i++) { let image = imagesList[i] fs.mkdirSync(config.ossPacsPath + getObjectMkdir(`/${trialCode}/${subjectCode}/${TaskCode}/initial_data/1`), { recursive: true }); @@ -273,7 +277,7 @@ class PacsController extends BaseController { status: '下载中', downloadCount: imagesList.length } - }, {upsert: true, new: true}) + }, { upsert: true, new: true }) if (!~studyList.indexOf(`${config.ossPacsPath}/${trialCode}/${subjectCode}/${TaskCode}/initial_data`)) { studyList.push(`${config.ossPacsPath}/${trialCode}/${subjectCode}/${TaskCode}/initial_data`) } @@ -285,7 +289,7 @@ class PacsController extends BaseController { $set: { status: '下载完成', } - }, {upsert: true, new: true}) + }, { upsert: true, new: true }) // 开始推送 for (let i = 0; i < studyList.length; i++) { let study = studyList[i] @@ -296,7 +300,7 @@ class PacsController extends BaseController { $set: { status: '推送中', } - }, {upsert: true, new: true}) + }, { upsert: true, new: true }) } await this.ctx.model.Status.findOneAndUpdate({ task_id: task_id @@ -304,15 +308,15 @@ class PacsController extends BaseController { $set: { status: '推送完成', } - }, {upsert: true, new: true}) - return this.success({downloadErrorList, downloadsuccessList}) - }catch (error) { + }, { upsert: true, new: true }) + return this.success({ downloadErrorList, downloadsuccessList }) + } catch (error) { return this.error(error) } } //新增pacs位置 - async addPACS(){ + async addPACS() { try { this.ctx.validate({ trialId: 'string', @@ -321,15 +325,15 @@ class PacsController extends BaseController { aet: 'string', }) let { - host,port,aet,trialId + host, port, aet, trialId } = this.ctx.request.body let para = this.ctx.request.body let pacs = await this.ctx.model.Pacs.findOne({ - host,port,aet,trialId + host, port, aet, trialId }) - if(pacs){ - return this.error("PACS位置已存在",60001) - }else{ + if (pacs) { + return this.error("PACS位置已存在", 60001) + } else { pacs = this.ctx.model.Pacs(para) let result = await pacs.save() return this.success(result) @@ -346,7 +350,7 @@ class PacsController extends BaseController { aet: 'string', }) let { - _id, host,port,aet,mode, trialId, description + _id, host, port, aet, mode, trialId, description } = this.ctx.request.body let para = this.ctx.request.body let result @@ -361,11 +365,11 @@ class PacsController extends BaseController { mode: mode, description: description } - }, {upsert: true, new: true}) + }, { upsert: true, new: true }) return this.success(result) } //删除pacs位置 - async delPACS(){ + async delPACS() { try { this.ctx.validate({ pacs_id: { @@ -377,11 +381,11 @@ class PacsController extends BaseController { pacs_id } = this.ctx.request.body let pacs = await this.ctx.model.Pacs.findOne({ - _id:pacs_id + _id: pacs_id }); if (!pacs) throw '未找到该PACS' await this.ctx.model.Pacs.deleteOne({ - _id:pacs_id + _id: pacs_id }); return this.success() } catch (e) { @@ -393,7 +397,7 @@ class PacsController extends BaseController { async testConnection() { try { this.ctx.validate({ - pacs_ids:"array" + pacs_ids: "array" }) } catch (error) { return this.error(error) @@ -401,7 +405,7 @@ class PacsController extends BaseController { try { let { pacs_ids } = this.ctx.request.body - if(!pacs_ids.length) return this.error("参数为空") + if (!pacs_ids.length) return this.error("参数为空") let result = await this.ctx.service.pacs.testConnection(pacs_ids) return this.success(result) } catch (error) { @@ -412,54 +416,54 @@ class PacsController extends BaseController { return this.error(msg) } } - async wxFindFromPacs () { - try { - let { - PatientID - } = this.ctx.request.body - if (!PatientID) { - throw 'PatientID必填' - } - let result = await this.ctx.service.pacs.findFromPacs({PatientID: PatientID}) - if (result.length > 0) { - let item = result[0] - let isHas = await this.ctx.model.Dcmtemp.findOne({StudyInstanceUID: item.StudyInstanceUID}) - if (isHas) { - this.ctx.model.Dcmtemp.findOneAndUpdate({ - _id: isHas._id - }, { - $set: { - host: item.host, - port: item.port, - aet: item.aet, - done: 0, - NumberOfStudyRelatedInstances: item.NumberOfStudyRelatedInstances, - StudyInstanceUID: item.StudyInstanceUID, - status: 0 - } - }).exec() - } else { - let params = { - host: item.host, - port: item.port, - aet: item.aet, - done: 0, - NumberOfStudyRelatedInstances: item.NumberOfStudyRelatedInstances, - StudyInstanceUID: item.StudyInstanceUID, - status: 0 + async wxFindFromPacs() { + try { + let { + PatientID + } = this.ctx.request.body + if (!PatientID) { + throw 'PatientID必填' } - let m = new this.ctx.model.Dcmtemp(params) - m.save() - } + let result = await this.ctx.service.pacs.findFromPacs({ PatientID: PatientID }) + if (result.length > 0) { + let item = result[0] + let isHas = await this.ctx.model.Dcmtemp.findOne({ StudyInstanceUID: item.StudyInstanceUID }) + if (isHas) { + this.ctx.model.Dcmtemp.findOneAndUpdate({ + _id: isHas._id + }, { + $set: { + host: item.host, + port: item.port, + aet: item.aet, + done: 0, + NumberOfStudyRelatedInstances: item.NumberOfStudyRelatedInstances, + StudyInstanceUID: item.StudyInstanceUID, + status: 0 + } + }).exec() + } else { + let params = { + host: item.host, + port: item.port, + aet: item.aet, + done: 0, + NumberOfStudyRelatedInstances: item.NumberOfStudyRelatedInstances, + StudyInstanceUID: item.StudyInstanceUID, + status: 0 + } + let m = new this.ctx.model.Dcmtemp(params) + m.save() + } + } + return this.success(result) + } catch (error) { + let msg = error + if (error.message) { + msg = error.message.split('\n') + } + return this.error(msg) } - return this.success(result) - } catch (error) { - let msg = error - if (error.message) { - msg = error.message.split('\n') - } - return this.error(msg) - } } //查询 @@ -477,16 +481,16 @@ class PacsController extends BaseController { } //获取下载进度 - async percent(){ + async percent() { try { this.ctx.validate({ - task_ids:"array" + task_ids: "array" }) } catch (error) { return this.error(error) } let { task_ids } = this.ctx.request.body - let result = await this.ctx.model.Status.find({task_id: {$in: task_ids}}) + let result = await this.ctx.model.Status.find({ task_id: { $in: task_ids } }) return this.success(result) } //下载 @@ -502,35 +506,35 @@ class PacsController extends BaseController { let { para } = this.ctx.request.body try { for (let i = 0; i < para.length; i++) { - let item = para[i] - let isHas = await this.ctx.model.Dcmtemp.findOne({StudyInstanceUID: item.StudyInstanceUID}) - if (isHas) { - this.ctx.model.Dcmtemp.findOneAndUpdate({ - _id: isHas._id - }, { - $set: { - host: item.host, - port: item.port, - aet: item.aet, - done: 0, - NumberOfStudyRelatedInstances: item.NumberOfStudyRelatedInstances, - StudyInstanceUID: item.StudyInstanceUID, - status: 0 - } - }).exec() - } else { - let params = { - host: item.host, - port: item.port, - aet: item.aet, - done: 0, - NumberOfStudyRelatedInstances: item.NumberOfStudyRelatedInstances, - StudyInstanceUID: item.StudyInstanceUID, - status: 0 + let item = para[i] + let isHas = await this.ctx.model.Dcmtemp.findOne({ StudyInstanceUID: item.StudyInstanceUID }) + if (isHas) { + this.ctx.model.Dcmtemp.findOneAndUpdate({ + _id: isHas._id + }, { + $set: { + host: item.host, + port: item.port, + aet: item.aet, + done: 0, + NumberOfStudyRelatedInstances: item.NumberOfStudyRelatedInstances, + StudyInstanceUID: item.StudyInstanceUID, + status: 0 + } + }).exec() + } else { + let params = { + host: item.host, + port: item.port, + aet: item.aet, + done: 0, + NumberOfStudyRelatedInstances: item.NumberOfStudyRelatedInstances, + StudyInstanceUID: item.StudyInstanceUID, + status: 0 + } + let m = new this.ctx.model.Dcmtemp(params) + m.save() } - let m = new this.ctx.model.Dcmtemp(params) - m.save() - } } return this.success() } catch (error) { @@ -539,8 +543,8 @@ class PacsController extends BaseController { } //study抽取report - async getLocalPort () { - return this.success({port: this.config.site.PACS_SCP_PORT, aet: this.config.site.PACS_SCP_AET}) + async getLocalPort() { + return this.success({ port: this.config.site.PACS_SCP_PORT, aet: this.config.site.PACS_SCP_AET }) } } module.exports = PacsController; diff --git a/app/service/oss.js b/app/service/oss.js index 80b387b..56a9a8a 100644 --- a/app/service/oss.js +++ b/app/service/oss.js @@ -2,6 +2,7 @@ const Service = require("egg").Service; const OSS = require('ali-oss'); +const http = require('http'); function fileToBlob(file) { // 创建 FileReader 对象 let reader = new FileReader(); @@ -32,26 +33,33 @@ class ImageService extends Service { */ async downloadImage(path, osPath, config) { try { - const client = new OSS({ - region: config.region, - accessKeyId: config.accessKeyId, - accessKeySecret: config.accessKeySecret, - bucket: config.bucket - }); - const result = await client.get(path, osPath); - return result + let client = await this.getClient() + if (client) { + const result = await client.get(path, osPath); + return result + } + return false + // const client = new OSS({ + // region: config.region, + // accessKeyId: config.accessKeyId, + // accessKeySecret: config.accessKeySecret, + // bucket: config.bucket + // }); + } catch (e) { console.log(e) } } - async dcmUpload (name, file, config){ - const client = new OSS({ - region: config.region, - accessKeyId: config.accessKeyId, - accessKeySecret: config.accessKeySecret, - bucket: config.bucket - }); + dcmUpload(name, file, config) { + + // const client = new OSS({ + // region: config.region, + // accessKeyId: config.accessKeyId, + // accessKeySecret: config.accessKeySecret, + // bucket: config.bucket + // }); return new Promise(async resolve => { + let client = await this.getClient() try { let res = await client.put(name, file) resolve({ @@ -63,5 +71,54 @@ class ImageService extends Service { } }) } + async getClient() { + if (this.ctx.state.ossConfig && this.isCredentialsExpired(this.ctx.state.ossConfig.expiration)) return new OSS(this.ctx.state.ossConfig) + let config = null + let res = await this.getOssConfig() + if (res && res.IsSuccess) { + config = res.Result[res.Result.ObjectStoreUse] + config.bucket = config.bucketName + config.basePath = config.viewEndpoint; + config.stsToken = config.securityToken + config.timeout = 10 * 60 * 1000 + this.ctx.state.config = config + return new OSS(config) + } + return false + } + getOssConfig() { + return new Promise((res, rej) => { + const Authorization = this.ctx.get('Authorization'); + let options = { + hostname: '106.14.89.110', + port: 30000, + path: "/user/GetObjectStoreToken", + method: "GET", + headers: { + Authorization: Authorization + } + } + const req = http.request(options, r => { + let data = ''; + r.on('data', chunk => { + data += chunk + }) + r.on('end', () => { + res(JSON.parse(data)) + }) + }) + req.end() + }) + } + isCredentialsExpired(credentials) { + if (!credentials) { + return true; + } + const expireDate = new Date(credentials); + const now = new Date(); + // 如果有效期不足五分钟,视为过期。 + return expireDate.getTime() - now.getTime() <= 300000; + + } } module.exports = ImageService; diff --git a/app/service/pacs.js b/app/service/pacs.js index 56b7c23..ae12245 100644 --- a/app/service/pacs.js +++ b/app/service/pacs.js @@ -3,13 +3,14 @@ const child_process = require('child_process'); const fs = require('fs'); const readline = require('readline'); const path = require('path'); -const axios = require('axios') +// const axios = require('axios') +const http = require('http'); const request = require('request'); var querystring = require('querystring'); -function getObjectMkdir (url) { +function getObjectMkdir(url) { let index = url.lastIndexOf("/") - let path = url.substring(0,index); + let path = url.substring(0, index); return path } @@ -61,24 +62,24 @@ class PacsService extends Service { } //测试连接 - async testConnection(pacs_ids){ + async testConnection(pacs_ids) { let result = [] let PACS_SCP_AET = this.config.site.PACS_SCP_AET - for(let i=0;i { try { - let CMD = `dcmsend -v +sd -aec ${pacs.aet} -aet ${config.aet} ${pacs.host} ${pacs.port} ${study}` + // let CMD = `dcmsend -v +sd -aec ${pacs.aet} -aet ${config.aet} ${pacs.host} ${pacs.port} ${study}` + let CMD = `dcmsend -v +sd -aec ${pacs.aet} -aet AET ${pacs.host} ${pacs.port} ${study}` console.log(CMD) child_process.exec(CMD, { timeout: 300000, @@ -201,7 +204,7 @@ class PacsService extends Service { }) } //^^ - async findscu(para,obj) { + async findscu(para, obj) { return new Promise((resolve, reject) => { let CMD = `findscu ${para}` console.log(CMD) @@ -214,13 +217,13 @@ class PacsService extends Service { reject(error) } else if (stderr) { let str = stderr.toString().replace(/\u0000/g, "") - console.log('stderr',str) - let resp = await this.parseFindResult(str,obj) + console.log('stderr', str) + let resp = await this.parseFindResult(str, obj) resolve(resp) } else if (stdout) { let str = stdout.toString().replace(/\u0000/g, "") console.log('stdout', str) - let resp = await this.parseFindResult(str,obj) + let resp = await this.parseFindResult(str, obj) resolve(resp) } else { resolve() @@ -267,7 +270,7 @@ class PacsService extends Service { } //^^ //整理查询结果 - async parseFindResult(str,obj) { + async parseFindResult(str, obj) { let result = [] let dict = await this.parseQRDist() console.log(dict) @@ -305,7 +308,7 @@ class PacsService extends Service { console.log('result', result) return result } - async setDcmTempState (dcmtempList, para, state, done) { + async setDcmTempState(dcmtempList, para, state, done) { try { if (dcmtempList) { let dcmtempId = dcmtempList._id @@ -339,9 +342,9 @@ class PacsService extends Service { //下载 async movescu(body, series, config) { return new Promise(async (resolve, reject) => { - try{ - let {pacs_id, seriesList, userName, userId, task_id, trialCode, subjectCode, TaskCode} = body - let pacs = await this.ctx.model.Pacs.findOne({_id: pacs_id}).select("aet host port") + try { + let { pacs_id, seriesList, userName, userId, task_id, trialCode, subjectCode, TaskCode } = body + let pacs = await this.ctx.model.Pacs.findOne({ _id: pacs_id }).select("aet host port") if (!pacs) throw "pacs位置不存在" fs.mkdirSync(config.ossPacsPath + getObjectMkdir(`/${trialCode}/${subjectCode}/${TaskCode}/${userId}/1`), { recursive: true }); let directoryPath = config.ossPacsPath + `/${trialCode}/${subjectCode}/${TaskCode}/${userId}/` @@ -354,10 +357,10 @@ class PacsService extends Service { movescu.stderr.on('data', (data) => { console.log(`move======pending: ${data}`); }) - movescu.on('close', async (code, data)=> { + movescu.on('close', async (code, data) => { resolve() }); - }catch(e){ + } catch (e) { console.log(e) } }) @@ -365,14 +368,14 @@ class PacsService extends Service { //^^ //读取文件夹子文件个数 - async readNum(fileName){ + async readNum(fileName) { let filePath = `${this.config.site.PACS_SCP_STORE}/${fileName}` return new Promise((resolve, reject) => { - fs.readdir(filePath,(err,files)=>{ - if(err){ + fs.readdir(filePath, (err, files) => { + if (err) { //未下载 resolve(-1) - }else{ + } else { resolve(files.length) } }) @@ -380,17 +383,17 @@ class PacsService extends Service { } //保存patient - async dicomInfoSave(filesName,user_id){ + async dicomInfoSave(filesName, user_id) { let filesPath = `${this.config.site.PACS_SCP_STORE}/${filesName}` - fs.readdir(filesPath,(err,files)=>{ - if(err){ + fs.readdir(filesPath, (err, files) => { + if (err) { - }else{ - for(let i=0;i<1;i++){ + } else { + for (let i = 0; i < 1; i++) { let fileName = files[i] let filePath = `${filesPath}/${fileName}` let fileData = fs.readFileSync(filePath) - this.setStudy(fileData,user_id) + this.setStudy(fileData, user_id) } } }) @@ -452,33 +455,75 @@ class PacsService extends Service { } addOrUpdateArchiveStudy(data, Authorization, config) { return new Promise((resolve, reject) => { - axios({ - method: 'post', - data: data, + let options = { + hostname: '106.14.89.110', + port: 30000, + path: "/Study/preArchiveDicomStudy", + method: "POST", headers: { Authorization: Authorization - }, - url: config.eiscPath + '/api/Study/preArchiveDicomStudy' - }).then(res => { - console.log(res.data) - resolve(res.data) + } + } + const req = http.request(options, r => { + let data = ''; + r.on('data', chunk => { + data += chunk + }) + r.on('end', () => { + resolve(JSON.parse(data)) + }) + }) + req.write(data) + req.end() + // axios({ + // method: 'post', + // data: data, + // headers: { + // Authorization: Authorization + // }, + // url: config.eiscPath + '/api/Study/preArchiveDicomStudy' + // }).then(res => { + // console.log(res.data) + // resolve(res.data) + // }) }) } preArchiveDicomStudy(info, config) { info.IsDicomReUpload = true return new Promise((resolve, reject) => { - axios({ - method: 'post', - data: info, + let options = { + hostname: '106.14.89.110', + port: 30000, + path: "/Study/preArchiveDicomStudy", + method: "POST", headers: { Authorization: info.Authorization - }, - url: config.eiscPath + '/api/Study/preArchiveDicomStudy' - }).then(res => { - console.log(res.data) - resolve(res.data) + } + } + const req = http.request(options, r => { + let data = ''; + r.on('data', chunk => { + data += chunk + }) + r.on('end', () => { + resolve(JSON.parse(data)) + }) + }) + req.write(info) + req.end() + // axios({ + // method: 'post', + // data: info, + // headers: { + // Authorization: info.Authorization + // }, + // url: config.eiscPath + '/api/Study/preArchiveDicomStudy' + // }).then(res => { + // console.log(res.data) + // resolve(res.data) + // }) }) } archiveStudy(uploadQueues, index, info, config) { @@ -634,9 +679,9 @@ class PacsService extends Service { let serie = await this.ctx.model.Series.findOne({ SeriesInstanceUID: SeriesInstanceUID }) - .populate({ - path: "images_ids", - }) + .populate({ + path: "images_ids", + }) let num = 1; if (serie && serie.images_ids) { for (let i = 0; i < serie.images_ids.length; i++) { diff --git a/config/config.default.js b/config/config.default.js index 28dbe4c..45d6ccd 100644 --- a/config/config.default.js +++ b/config/config.default.js @@ -1,5 +1,5 @@ 'use strict'; -const { url } = require('inspector'); +// const { url } = require('inspector'); const path = require('path'); module.exports = appInfo => { const config = exports = {}; @@ -76,6 +76,7 @@ module.exports = appInfo => { config.logger = { // level: 'ERROR', + dir: path.join(process.cwd(), 'logs'), consoleLevel: 'DEBUG', appLogName: `${appInfo.name}-api.log`, //应用相关日志, coreLogName: "web.log", //框架内核、插件日志。 @@ -126,7 +127,7 @@ module.exports = appInfo => { config.jwt = { secret: "6YPhrbCSKLejwZ5F", - exp:1000*24*60*60 //存在时间 单位位秒 + exp: 1000 * 24 * 60 * 60 //存在时间 单位位秒 }; config.regexp = { @@ -146,7 +147,20 @@ module.exports = appInfo => { config.initData = {} - config.png16 = { - }; + + config.static = { + prefix: '/', + dir: process.cwd() + '/public' + } + config.rundir = process.cwd() + '/run' + config.development = { + enable: false, // 禁用 egg-development 插件 + } + config.watcher = { // 关闭文件监听 + enable: false, + } + + config.png16 = { + }; return config; }; diff --git a/package.json b/package.json index adf78c4..270b14d 100644 --- a/package.json +++ b/package.json @@ -42,8 +42,21 @@ "cov": "egg-bin cov", "lint": "eslint .", "ci": "npm run lint && npm run cov", + "build": "pkg . --targets node14-win-x64 --out-path ./dist --debug", "autod": "autod" }, + "bin": "index.js", + "pkg": { + "assets": [ + "./config/*.js", + "./app.js", + "./init.js", + "./app/**/*.js", + "./node_modules/nanoid/**/*", + "./node_modules/js-md5/**/*", + "./node_modules/egg-security/**/*" + ] + }, "ci": { "version": "8" },