|
@@ -8,7 +8,19 @@
|
|
|
* @version
|
|
|
*/
|
|
|
|
|
|
+const fs = require('fs');
|
|
|
+const path = require('path');
|
|
|
+var util = require('util');
|
|
|
+var logPath = path.join(__dirname, 'update_revise.log');
|
|
|
+var logFile = fs.createWriteStream(logPath, { flags: 'a' });
|
|
|
+
|
|
|
+console.log = function() {
|
|
|
+ logFile.write(util.format.apply(null, arguments) + '\n');
|
|
|
+ process.stdout.write(util.format.apply(null, arguments) + '\n');
|
|
|
+};
|
|
|
+
|
|
|
const audit = require('../app/const/audit');
|
|
|
+const measureType = require('../app/const/message_type');
|
|
|
|
|
|
const mysql = require('mysql');
|
|
|
const oss = require('ali-oss');
|
|
@@ -81,8 +93,8 @@ const saveReviseLedgerHis = async function (tender, revise) {
|
|
|
const billsHis = revise.bills_file;
|
|
|
const posHis = revise.pos_file;
|
|
|
|
|
|
- const result = await querySql('Insert Into zh_ledger_history(pid, tid, in_time, bills_file, pos_file, rid, rorder) Values(?, ?, ?, ?, ?, ?, ?)',
|
|
|
- [tender.project_id, tender.id, now, billsHis, posHis, revise.id, revise.corder]);
|
|
|
+ const result = await querySql('Insert Into zh_ledger_history(pid, tid, in_time, bills_file, pos_file, rid, rorder, valid) Values(?, ?, ?, ?, ?, ?, ?, ?)',
|
|
|
+ [tender.project_id, tender.id, now, billsHis, posHis, revise.id, revise.corder, revise.valid]);
|
|
|
|
|
|
if (!result) throw 'err';
|
|
|
return result.insertId;
|
|
@@ -99,13 +111,13 @@ const doCompleteTender = async function(t) {
|
|
|
}
|
|
|
if (r.bills_file) {
|
|
|
r.his_id = await saveReviseLedgerHis(t, r);
|
|
|
- his_id = r.his_id;
|
|
|
+ if (r.valid) his_id = r.his_id;
|
|
|
await querySql('Update zh_ledger_revise Set his_id = ? Where id = ?', [his_id, r.id]);
|
|
|
} else {
|
|
|
if (r.status !== 1) withoutHisRevise.push(r);
|
|
|
}
|
|
|
}
|
|
|
- if (!his_id) his_id = await saveLedgerHis(t);
|
|
|
+ if (!his_id || t.measure_type === measureType.gcl.value) his_id = await saveLedgerHis(t);
|
|
|
await querySql('Update zh_tender Set his_id = ? Where id = ?', [his_id, t.id]);
|
|
|
const stages = await querySql('Select * From zh_stage where tid = ? and status = ?', [t.id, audit.stage.status.checked]);
|
|
|
for (const s of stages) {
|
|
@@ -166,5 +178,6 @@ doComplete();
|
|
|
// }
|
|
|
// pool.end();
|
|
|
// };
|
|
|
-doCompeletTest();
|
|
|
+
|
|
|
+// doCompeletTest();
|
|
|
|