|
@@ -15,6 +15,7 @@ const auditConst = require('../const/audit');
|
|
const signConst = require('../const/sign');
|
|
const signConst = require('../const/sign');
|
|
const shenpiConst = require('../const/shenpi');
|
|
const shenpiConst = require('../const/shenpi');
|
|
const accountGroup = require('../const/account_group').group;
|
|
const accountGroup = require('../const/account_group').group;
|
|
|
|
+const sendToWormhole = require('stream-wormhole');
|
|
|
|
|
|
module.exports = app => {
|
|
module.exports = app => {
|
|
class ReportArchiveController extends app.BaseController {
|
|
class ReportArchiveController extends app.BaseController {
|
|
@@ -73,7 +74,7 @@ module.exports = app => {
|
|
if (archiveEncryptions.length > 0) {
|
|
if (archiveEncryptions.length > 0) {
|
|
archiveEncryptionList = JSON.parse(archiveEncryptions[0].content);
|
|
archiveEncryptionList = JSON.parse(archiveEncryptions[0].content);
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
|
|
+ } else if (stageList.length > 0 && stageList[0].status === auditConst.stage.status.checked) {
|
|
// console.log('stageList[0].id: ' + stageList[0].id);
|
|
// console.log('stageList[0].id: ' + stageList[0].id);
|
|
let archives = [];
|
|
let archives = [];
|
|
for (let sidx = stageList.length - 1; sidx >= 0; sidx--) {
|
|
for (let sidx = stageList.length - 1; sidx >= 0; sidx--) {
|
|
@@ -83,6 +84,8 @@ module.exports = app => {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ ctx.stage = ctx.stage ? ctx.stage : stageList[stageList.length - 1];
|
|
// const archives = await ctx.service.rptArchive.getPrjStgArchive(tender.data.project_id, stageList[stageList.length - 1].id);
|
|
// const archives = await ctx.service.rptArchive.getPrjStgArchive(tender.data.project_id, stageList[stageList.length - 1].id);
|
|
const archiveEncryptions = await ctx.service.rptArchiveEncryption.getPrjStgArchiveEncryption(tender.data.project_id, ctx.stage.id);
|
|
const archiveEncryptions = await ctx.service.rptArchiveEncryption.getPrjStgArchiveEncryption(tender.data.project_id, ctx.stage.id);
|
|
// stage_id = stageList[0].id;
|
|
// stage_id = stageList[0].id;
|
|
@@ -124,7 +127,7 @@ module.exports = app => {
|
|
stg_order: stage_order,
|
|
stg_order: stage_order,
|
|
stg_times: stage_times,
|
|
stg_times: stage_times,
|
|
stg_status: stage_status,
|
|
stg_status: stage_status,
|
|
- stage_list: JSON.stringify(stageList),
|
|
|
|
|
|
+ stage_list: stageList.length > 0 && stageList[0].status === auditConst.stage.status.checked ? JSON.stringify(stageList) : JSON.stringify([]),
|
|
tenderMenu,
|
|
tenderMenu,
|
|
measureType,
|
|
measureType,
|
|
jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.report.main),
|
|
jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.report.main),
|
|
@@ -526,6 +529,7 @@ module.exports = app => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
const archiveEncryptions = await ctx.service.rptArchiveEncryption.getPrjStgArchiveEncryption(tender.data.project_id, ctx.stage.id);
|
|
const archiveEncryptions = await ctx.service.rptArchiveEncryption.getPrjStgArchiveEncryption(tender.data.project_id, ctx.stage.id);
|
|
// stage_id = stageList[0].id;
|
|
// stage_id = stageList[0].id;
|
|
// stage_order = stageList[0].order;
|
|
// stage_order = stageList[0].order;
|
|
@@ -588,6 +592,13 @@ module.exports = app => {
|
|
let signData;
|
|
let signData;
|
|
const netcaSignApi = signConst.path.api;
|
|
const netcaSignApi = signConst.path.api;
|
|
switch (data.type) {
|
|
switch (data.type) {
|
|
|
|
+ case 'getPdfBase64':
|
|
|
|
+ const pdfResult = await ctx.oss.get(data.path);
|
|
|
|
+ if (pdfResult.res.status !== 200) {
|
|
|
|
+ throw '该文件不存在';
|
|
|
|
+ }
|
|
|
|
+ response.data = Buffer.from(pdfResult.content, 'binary').toString('base64');
|
|
|
|
+ break;
|
|
case 'pdfIsExist':
|
|
case 'pdfIsExist':
|
|
const pdfMsg = await ctx.oss.head('archive/sign/' + data.uuid + '.PDF');
|
|
const pdfMsg = await ctx.oss.head('archive/sign/' + data.uuid + '.PDF');
|
|
response.data = pdfMsg.res.status === 200;
|
|
response.data = pdfMsg.res.status === 200;
|
|
@@ -612,10 +623,10 @@ module.exports = app => {
|
|
// console.log(result3);
|
|
// console.log(result3);
|
|
if (result3.code === 0) {
|
|
if (result3.code === 0) {
|
|
// const result3 = await ctx.helper.sendMoreRequest(netcaSignApi + result2.data);
|
|
// const result3 = await ctx.helper.sendMoreRequest(netcaSignApi + result2.data);
|
|
- const oss_reuslt = await ctx.oss.put('archive/sign/' + data.requestJson.fileName + '.PDF', result3.data);
|
|
|
|
- if (oss_reuslt && oss_reuslt.res && oss_reuslt.res.status === 200) {
|
|
|
|
|
|
+ const oss_result = await ctx.oss.put('archive/sign/' + data.requestJson.fileName + '.PDF', result3.data);
|
|
|
|
+ if (oss_result && oss_result.res && oss_result.res.status === 200) {
|
|
if (data.end) {
|
|
if (data.end) {
|
|
- const versionId = oss_reuslt.res.headers['x-oss-version-id'];
|
|
|
|
|
|
+ const versionId = oss_result.res.headers['x-oss-version-id'];
|
|
// 记录签名和保存
|
|
// 记录签名和保存
|
|
await ctx.service.netcasignLog.add(data.requestJson.fileName, data.role, ctx.session.sessionUser.accountId, versionId);
|
|
await ctx.service.netcasignLog.add(data.requestJson.fileName, data.role, ctx.session.sessionUser.accountId, versionId);
|
|
const signLogList = await ctx.service.netcasignLog.getLogList(ctx.tender.id);
|
|
const signLogList = await ctx.service.netcasignLog.getLogList(ctx.tender.id);
|
|
@@ -655,6 +666,33 @@ module.exports = app => {
|
|
|
|
|
|
ctx.body = response;
|
|
ctx.body = response;
|
|
}
|
|
}
|
|
|
|
+ /**
|
|
|
|
+ * 网证通电子签名报表上传
|
|
|
|
+ *
|
|
|
|
+ * @param {object} ctx - egg全局变量
|
|
|
|
+ * @return {void}
|
|
|
|
+ */
|
|
|
|
+ async signFile(ctx) {
|
|
|
|
+ const stream = await ctx.getFileStream();
|
|
|
|
+ try {
|
|
|
|
+ const uuid = stream.fields.uuid;
|
|
|
|
+ const role = stream.fields.role;
|
|
|
|
+ const oss_result = await ctx.oss.put('archive/sign/' + uuid + '.PDF', stream);
|
|
|
|
+ if (!(oss_result && oss_result.url && oss_result.res.status === 200)) {
|
|
|
|
+ throw '上传文件失败';
|
|
|
|
+ }
|
|
|
|
+ const versionId = oss_result.res.headers['x-oss-version-id'];
|
|
|
|
+ // 记录签名和保存
|
|
|
|
+ await ctx.service.netcasignLog.add(uuid, role, ctx.session.sessionUser.accountId, versionId);
|
|
|
|
+ const signLogList = await ctx.service.netcasignLog.getLogList(ctx.tender.id);
|
|
|
|
+ ctx.body = { err: 0, msg: '', data: signLogList };
|
|
|
|
+ } catch (err) {
|
|
|
|
+ // 必须将上传的文件流消费掉,要不然浏览器响应会卡死
|
|
|
|
+ await sendToWormhole(stream);
|
|
|
|
+ this.log(err);
|
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
async roundNetcaSign(ctx, postData2, round = 3) {
|
|
async roundNetcaSign(ctx, postData2, round = 3) {
|
|
let response = {
|
|
let response = {
|