test_query.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // 计算变更令,正负变更数
  2. const defaultInfo = require('../app/const/tender_info');
  3. const BaseUtil = require('./baseUtils');
  4. const querySql = BaseUtil.querySql;
  5. const ZhCalc = BaseUtil.ZhCalc;
  6. const saveJSON = async function(obj, file) {
  7. let defineStr = JSON.stringify(obj, '', '\t');
  8. await BaseUtil.saveBufferFile(defineStr, file);
  9. };
  10. const loadReportArchiveData = async function() {
  11. //const tid = 4417, sOrder = 2;
  12. const tid = 3698, sOrder = 7;
  13. const stage = await querySql('SELECT * FROM zh_stage where tid = ? and `order` = ?', [tid, sOrder]);
  14. const rptArchive = await querySql('SELECT * FROM zh_rpt_archive where stage_id = ?', [stage[0].id]);
  15. for (const ra of rptArchive) {
  16. ra.content = ra.content ? JSON.parse(ra.content) : [];
  17. console.log(BaseUtil.getFileName('rptArchive.json'));
  18. await saveJSON(ra, BaseUtil.getFileName('rptArchive.json'));
  19. const roleContent = [];
  20. for (const c of ra.content) {
  21. console.log(c.rpt_id, stage[0].id);
  22. const rptRole = await querySql('SELECT * FROM zh_role_rpt_rel WHERE sid = ? and rpt_id = ?', [stage[0].id, c.rpt_id]);
  23. if (rptRole.length > 0) {
  24. if (rptRole[0].rel_content) roleContent.push(JSON.stringify(rptRole[0].rel_content));
  25. }
  26. }
  27. await saveJSON(roleContent, BaseUtil.getFileName('roleContent.json'));
  28. }
  29. const rptSign = await querySql('SELECT * FROM zh_rpt_archive_encryption where stage_id = ?', [stage[0].id]);
  30. for (const rs of rptSign) {
  31. rs.content = rs.content ? JSON.parse(rs.content) : [];
  32. console.log(BaseUtil.getFileName('rptSign.json'));
  33. await saveJSON(rs, BaseUtil.getFileName('rptSign.json'));
  34. }
  35. };
  36. const findRole = async function() {
  37. const role = await querySql('SELECT * FROM zh_role_rpt_rel');
  38. for (const r of role) {
  39. const roleContent = r.rel_content ? JSON.parse(r.rel_content) : [];
  40. for (const rc of roleContent) {
  41. if (rc.sign_date) console.log(rc.sign_date, rc.sign_date_format);
  42. }
  43. }
  44. };
  45. const doCompleteTest = async function() {
  46. try {
  47. // await loadReportArchiveData();
  48. // await findRole();
  49. } catch (err) {
  50. console.log(err);
  51. }
  52. BaseUtil.closePool();
  53. };
  54. doCompleteTest();