|
@@ -199,6 +199,7 @@ module.exports = app => {
|
|
|
// 获取收方单列表
|
|
|
const sfData = await ctx.service.stageShoufang.getAllDataByCondition({ where: { sid: ctx.stage.id }, orders: [['id', 'desc']] });
|
|
|
for (const sf of sfData) {
|
|
|
+ sf.qrcode = ctx.app.config.fujianOssPath + sf.qrcode;
|
|
|
sf.filenum = await ctx.service.stageShoufangAtt.count({ sfid: sf.id });
|
|
|
}
|
|
|
renderData.sfData = sfData;
|
|
@@ -754,11 +755,13 @@ module.exports = app => {
|
|
|
if (!stream.filename) throw '未发现上传文件!';
|
|
|
|
|
|
const fileInfo = path.parse(stream.filename);
|
|
|
- const dirName = path.join('app', 'public', 'upload', this.ctx.tender.id.toString(), 'im');
|
|
|
- const fileName = `${ctx.session.sessionUser.accountId}_${create_time}_${index}${fileInfo.ext}`;
|
|
|
+ // const dirName = path.join('app', 'public', 'upload', this.ctx.tender.id.toString(), 'im');
|
|
|
+ // const fileName = `${ctx.session.sessionUser.accountId}_${create_time}_${index}${fileInfo.ext}`;
|
|
|
+ const filepath = `app/public/upload/${this.ctx.tender.id}/im/${ctx.session.sessionUser.accountId}_${create_time}_${index}${fileInfo.ext}`;
|
|
|
|
|
|
// 保存文件
|
|
|
- await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, dirName, fileName));
|
|
|
+ // await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, dirName, fileName));
|
|
|
+ await ctx.app.fujianOss.put(filepath, stream);
|
|
|
await sendToWormhole(stream);
|
|
|
|
|
|
// 插入到stage_pay对应的附件列表中
|
|
@@ -767,7 +770,7 @@ module.exports = app => {
|
|
|
filename: fileInfo.name,
|
|
|
fileext: fileInfo.ext,
|
|
|
filesize: Array.isArray(parts.field.size) ? parts.field.size[index] : parts.field.size,
|
|
|
- filepath: path.join(dirName, fileName),
|
|
|
+ filepath,
|
|
|
uid: ctx.session.sessionUser.accountId,
|
|
|
in_time: moment(create_time * 1000).format('YYYY-MM-DD'),
|
|
|
renew: ctx.stage.status === auditConst.status.checked,
|
|
@@ -813,7 +816,7 @@ module.exports = app => {
|
|
|
const fileInfo = await ctx.service.stageDetailAtt.getFiles(uuid, file_id);
|
|
|
if (!fileInfo) throw '文件不存在';
|
|
|
|
|
|
- const fileName = path.join(this.app.baseDir, fileInfo.filepath);
|
|
|
+ // const fileName = path.join(this.app.baseDir, fileInfo.filepath);
|
|
|
// 解决中文无法下载问题
|
|
|
const userAgent = (ctx.request.header['user-agent'] || '').toLowerCase();
|
|
|
let disposition = '';
|
|
@@ -830,7 +833,8 @@ module.exports = app => {
|
|
|
'Content-Disposition': disposition,
|
|
|
'Content-Length': fileInfo.filesize,
|
|
|
});
|
|
|
- ctx.body = await fs.createReadStream(fileName);
|
|
|
+ // ctx.body = await fs.createReadStream(fileName);
|
|
|
+ ctx.body = await ctx.helper.ossFileGet(fileInfo.filepath);
|
|
|
} catch (err) {
|
|
|
ctx.log(err);
|
|
|
ctx.postError(err, '下载文件失败');
|
|
@@ -1450,7 +1454,8 @@ module.exports = app => {
|
|
|
const fileInfo = path.parse(stream.filename);
|
|
|
const create_time = Date.parse(new Date()) / 1000;
|
|
|
const filepath = `app/public/upload/${this.ctx.tender.id}/stage/fujian_${create_time + index.toString() + fileInfo.ext}`;
|
|
|
- await ctx.helper.saveStreamFile(stream, path.resolve(this.app.baseDir, filepath));
|
|
|
+ // await ctx.helper.saveStreamFile(stream, path.resolve(this.app.baseDir, filepath));
|
|
|
+ await ctx.app.fujianOss.put(filepath, stream);
|
|
|
// console.log(await fs.existsSync(path.resolve(this.app.baseDir, 'app', filepath)));
|
|
|
// const fileInfo = path.parse(stream.filename);
|
|
|
// const fileName = 'stage' + create_time + '_' + index + fileInfo.ext;
|
|
@@ -1509,7 +1514,7 @@ module.exports = app => {
|
|
|
try {
|
|
|
const fileInfo = await ctx.service.stageAtt.getDataById(id);
|
|
|
if (fileInfo !== undefined && fileInfo !== '') {
|
|
|
- const fileName = path.join(this.app.baseDir, fileInfo.filepath);
|
|
|
+ // const fileName = path.join(this.app.baseDir, fileInfo.filepath);
|
|
|
// 解决中文无法下载问题
|
|
|
const userAgent = (ctx.request.header['user-agent'] || '').toLowerCase();
|
|
|
let disposition = '';
|
|
@@ -1526,7 +1531,8 @@ module.exports = app => {
|
|
|
'Content-Disposition': disposition,
|
|
|
'Content-Length': fileInfo.filesize,
|
|
|
});
|
|
|
- ctx.body = await fs.createReadStream(fileName);
|
|
|
+ // ctx.body = await fs.createReadStream(fileName);
|
|
|
+ ctx.body = await ctx.helper.ossFileGet(fileInfo.filepath);
|
|
|
} else {
|
|
|
throw '不存在该文件';
|
|
|
}
|
|
@@ -1553,7 +1559,8 @@ module.exports = app => {
|
|
|
if (!ctx.helper.canPreview(fileInfo.fileext)) {
|
|
|
filepath = `/tender/${ctx.tender.id}/measure/stage/${ctx.params.order}/download/file/${fileInfo.id}`;
|
|
|
} else {
|
|
|
- filepath = filepath.replace(/^app|\/app/, '');
|
|
|
+ // filepath = filepath.replace(/^app|\/app/, '');
|
|
|
+ filepath = ctx.app.config.fujianOssPath + filepath;
|
|
|
}
|
|
|
fileInfo.filepath && (responseData.data = { filepath });
|
|
|
}
|
|
@@ -1591,7 +1598,8 @@ module.exports = app => {
|
|
|
}
|
|
|
if (fileInfo !== undefined && fileInfo !== '') {
|
|
|
// 先删除文件
|
|
|
- await fs.unlinkSync(path.join(this.app.baseDir, fileInfo.filepath));
|
|
|
+ // await fs.unlinkSync(path.join(this.app.baseDir, fileInfo.filepath));
|
|
|
+ await ctx.app.fujianOss.delete(fileInfo.filepath);
|
|
|
// 再删除数据库
|
|
|
await ctx.service.stageAtt.deleteById(data.id);
|
|
|
responseData.data = '';
|
|
@@ -1636,7 +1644,8 @@ module.exports = app => {
|
|
|
const fileName = 'fujian_' + create_time + fileInfo.ext;
|
|
|
|
|
|
// 保存文件
|
|
|
- await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, dirName, fileName));
|
|
|
+ // await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, dirName, fileName));
|
|
|
+ await ctx.app.fujianOss.put(path.join(dirName, fileName), stream);
|
|
|
// 保存数据到att表
|
|
|
fileData = {
|
|
|
filesize: stream.fields.size,
|
|
@@ -1749,15 +1758,19 @@ module.exports = app => {
|
|
|
throw '请选择上传的文件!';
|
|
|
}
|
|
|
const fileInfo = path.parse(stream.filename);
|
|
|
- const dirName = 'app/public/upload/pay/' + moment().format('YYYYMMDD');
|
|
|
- const fileName = 'pay' + create_time + '_' + index + fileInfo.ext;
|
|
|
+ // const dirName = 'app/public/upload/pay/' + moment().format('YYYYMMDD');
|
|
|
+ // const dirName = 'app/public/upload/' + this.ctx.tender.id + '/pay';
|
|
|
+ // const dirName = `app/public/upload/${this.ctx.tender.id}/pay`;
|
|
|
+ // const fileName = 'pay' + create_time + '_' + index + fileInfo.ext;
|
|
|
+ const filepath = `app/public/upload/${this.ctx.tender.id}/pay/fujian_${create_time + index.toString() + fileInfo.ext}`;
|
|
|
|
|
|
// 判断文件夹是否存在,不存在则直接创建文件夹
|
|
|
- if (!fs.existsSync(path.join(this.app.baseDir, dirName))) {
|
|
|
- await fs.mkdirSync(path.join(this.app.baseDir, dirName));
|
|
|
- }
|
|
|
+ // if (!fs.existsSync(path.join(this.app.baseDir, dirName))) {
|
|
|
+ // await fs.mkdirSync(path.join(this.app.baseDir, dirName));
|
|
|
+ // }
|
|
|
// 保存文件
|
|
|
- await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, dirName, fileName));
|
|
|
+ // await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, dirName, fileName));
|
|
|
+ await ctx.app.fujianOss.put(filepath, stream);
|
|
|
await sendToWormhole(stream);
|
|
|
// 插入到stage_pay对应的附件列表中
|
|
|
const attData = {
|
|
@@ -1768,7 +1781,7 @@ module.exports = app => {
|
|
|
filename: fileInfo.name,
|
|
|
fileext: fileInfo.ext,
|
|
|
filesize: Array.isArray(parts.field.size) ? parts.field.size[index] : parts.field.size,
|
|
|
- filepath: path.join(dirName, fileName),
|
|
|
+ filepath,
|
|
|
in_time: moment(create_time * 1000).format('YYYY-MM-DD'),
|
|
|
renew: this.ctx.stage.status === auditConst.status.checked,
|
|
|
};
|
|
@@ -1802,7 +1815,7 @@ module.exports = app => {
|
|
|
const fileInfo = await ctx.service.payAtt.getDataById(id);
|
|
|
if (!fileInfo) throw '不存在该文件';
|
|
|
|
|
|
- const fileName = path.join(this.app.baseDir, fileInfo.filepath);
|
|
|
+ // const fileName = path.join(this.app.baseDir, fileInfo.filepath);
|
|
|
// 解决中文无法下载问题
|
|
|
const userAgent = (ctx.request.header['user-agent'] || '').toLowerCase();
|
|
|
let disposition = '';
|
|
@@ -1819,7 +1832,8 @@ module.exports = app => {
|
|
|
'Content-Disposition': disposition,
|
|
|
'Content-Length': fileInfo.filesize,
|
|
|
});
|
|
|
- ctx.body = await fs.createReadStream(fileName);
|
|
|
+ // ctx.body = await fs.createReadStream(fileName);
|
|
|
+ ctx.body = await ctx.helper.ossFileGet(fileInfo.filepath);
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
this.setMessage(err.toString(), this.messageType.ERROR);
|
|
@@ -1836,11 +1850,11 @@ module.exports = app => {
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
const fileInfo = await ctx.service.payAtt.getDataById(data.id);
|
|
|
if (!fileInfo) throw '不存在该文件';
|
|
|
-
|
|
|
+ await ctx.app.fujianOss.delete(fileInfo.filepath);
|
|
|
const result = await ctx.service.payAtt.delFiles(data.id);
|
|
|
- if (fs.existsSync(path.join(ctx.app.baseDir, fileInfo.filepath))) {
|
|
|
- await fs.unlinkSync(path.join(ctx.app.baseDir, fileInfo.filepath));
|
|
|
- }
|
|
|
+ // if (fs.existsSync(path.join(ctx.app.baseDir, fileInfo.filepath))) {
|
|
|
+ // await fs.unlinkSync(path.join(ctx.app.baseDir, fileInfo.filepath));
|
|
|
+ // }
|
|
|
ctx.body = { err: 0, msg: '', data: result };
|
|
|
} catch (err) {
|
|
|
ctx.log(err);
|
|
@@ -1958,7 +1972,9 @@ module.exports = app => {
|
|
|
}
|
|
|
const result = await ctx.service.stageShoufang.add(data.postData);
|
|
|
// responseData.data.cooperationConfirm = await ctx.service.cooperationConfirm.getValidData(ctx.tender.id, ctx.stage.id, ctx.stage.times, ctx.session.sessionUser.accountId);
|
|
|
- responseData.data = await ctx.service.stageShoufang.getDataById(result.insertId);
|
|
|
+ const info = await ctx.service.stageShoufang.getDataById(result.insertId);
|
|
|
+ info.qrcode = ctx.app.config.fujianOssPath + info.qrcode;
|
|
|
+ responseData.data = info;
|
|
|
break;
|
|
|
case 'del':
|
|
|
// 判断收方单是否已存在
|