| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 | 
							- // 计算变更令,正负变更数
 
- const defaultInfo = require('../app/const/tender_info');
 
- const BaseUtil = require('./baseUtils');
 
- const querySql = BaseUtil.querySql;
 
- const ZhCalc = BaseUtil.ZhCalc;
 
- const saveJSON = async function(obj, file) {
 
-     let defineStr = JSON.stringify(obj, '', '\t');
 
-     await BaseUtil.saveBufferFile(defineStr, file);
 
- };
 
- const loadReportArchiveData = async function() {
 
-     //const tid = 4417, sOrder = 2;
 
-     const tid = 3698, sOrder = 7;
 
-     // const tid = 5161, sOrder = 11;
 
-     const stage = await querySql('SELECT * FROM zh_stage where tid = ? and `order` = ?', [tid, sOrder]);
 
-     const rptArchive = await querySql('SELECT * FROM zh_rpt_archive where stage_id = ?', [stage[0].id]);
 
-     for (const ra of rptArchive) {
 
-         ra.content = ra.content ? JSON.parse(ra.content) : [];
 
-         console.log(BaseUtil.getFileName('rptArchive.json'));
 
-         await saveJSON(ra, BaseUtil.getFileName('rptArchive.json'));
 
-         // for (const c of ra.content) {
 
-         //     console.log(c.rpt_id, stage[0].id);
 
-         //     const rptRole = await querySql('SELECT * FROM zh_role_rpt_rel WHERE sid = ? and rpt_id = ?', [stage[0].id, c.rpt_id]);
 
-         //     if (rptRole.length > 0) {
 
-         //         if (rptRole[0].rel_content) roleContent.push(JSON.parse(rptRole[0].rel_content));
 
-         //     }
 
-         // }
 
-         // await saveJSON(roleContent, BaseUtil.getFileName('roleContent.json'));
 
-         if (rptArchive.indexOf(ra) === 0) {
 
-             const rptTpl = await querySql('SELECT * FROM zh_rpt_tpl where id = ?', [ra.content[0].rpt_id]);
 
-             rptTpl[0].rpt_content = rptTpl[0].rpt_content ? JSON.parse(rptTpl[0].rpt_content) : {};
 
-             console.log('rptTpl.json');
 
-             await saveJSON(rptTpl[0], BaseUtil.getFileName('rptTpl.json'));
 
-         }
 
-     }
 
-     const roleContent = [];
 
-     const rptRole = await querySql('SELECT * FROM zh_role_rpt_rel WHERE sid = ?', [stage[0].id]);
 
-     for (const rp of rptRole) {
 
-         if (rp.rel_content) roleContent.push(JSON.parse(rp.rel_content));
 
-     }
 
-     await saveJSON(roleContent, BaseUtil.getFileName('roleContent.json'));
 
-     const rptSign = await querySql('SELECT * FROM zh_rpt_archive_encryption where stage_id = ?', [stage[0].id]);
 
-     for (const rs of rptSign) {
 
-         rs.content = rs.content ? JSON.parse(rs.content) : [];
 
-         console.log(BaseUtil.getFileName('rptSign.json'));
 
-         await saveJSON(rs, BaseUtil.getFileName('rptSign.json'));
 
-     }
 
- };
 
- const findRole = async function() {
 
-     const role = await querySql('SELECT * FROM zh_role_rpt_rel');
 
-     for (const r of role) {
 
-         const roleContent = r.rel_content ? JSON.parse(r.rel_content) : [];
 
-         for (const rc of roleContent) {
 
-             if (rc.sign_date) console.log(rc.sign_date, rc.sign_date_format);
 
-         }
 
-     }
 
- };
 
- const doCompleteTest = async function() {
 
-     try {
 
-         await loadReportArchiveData();
 
-         // await findRole();
 
-     } catch (err) {
 
-         console.log(err);
 
-     }
 
-     BaseUtil.closePool();
 
- };
 
- doCompleteTest();
 
 
  |