123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- // /cncc/action/report JSON数据导入程序
- // 2022-09-29T07:53:58.254Z 由 JsonImportGen.js 自动生成,请勿手动修改
-
- // 输入输出参数格式化
- input = INPUT;
- try {
- input = decodeURIComponent(input);
- } catch(e) {}
- try {
- input = base64.decode(input);
- } catch(e) {}
- try {
- input = JSON.parse(input);
- input = JSON.parse(input);
- } catch(e) {}
- output = {};
- istesting = false;
- function teststore() {
- // 输入JSON临时存入DFS
- dir = "/opt/cncc/action/report";
- dtm = new Date().toJSON().replace(/[\-\:\.TZ ]/mg, "");
- fn = dir + "/" + dtm;
- if (input.id) {
- fn += "." + input.id;
- } else {
- fn += "_" + _.random(0, 1000000);
- }
- fn += ".json";
- dfs.write(fn, JSON.stringify(input, " ", 4));
- output.filename = fn;
- // 刪除旧交件
- files = dfs.readdir(dir);
- dt = Date.now() - 1000 * 3600 * 24 * 10;
- for (i = 0; i < files.length; i++) {
- if (files[i].mtime < dt) {
- dfs.remove(files[i].fullname);
- }
- }
- // 留最后10个
- files.sort(function(a,b){ return a.mtime-b.mtime; });
- for (i = 0; i < files.length-10; i++) {
- dfs.remove(files[i].fullname);
- }
- }
- // 主执行阶段
- try {
- if (istesting) {
- teststore();
- }
- // 数据合法性检查
- if (!input.id) {
- throw ("输入参数必须为对象,且指定属性id");
- }
- if (!input.idUnique) {
- throw ("输入参数必须为对象,且指定属性idUnique");
- }
- // mql定义
- mql = `insert into /cncc/action/report (
- j_accept_group_dep_id,
- j_accept_group_dep_name,
- j_accept_user_dep_id,
- j_accept_user_dep_name,
- j_accept_user_group,
- j_accept_user_group_id,
- j_accept_user_id,
- j_accept_user_real_name,
- j_close_time,
- j_countersign_dep_id_list,
- j_countersign_dep_name_list,
- j_countersign_role_id_list,
- j_countersign_role_name_list,
- j_create_time,
- j_create_user_dep_id,
- j_create_user_dep_name,
- j_create_user_id,
- j_create_user_real_name,
- j_current_process_user_id,
- j_current_process_user_real_name,
- j_data_center_id_list,
- j_data_center_name_list,
- j_expected_end_time,
- j_expected_start_time,
- j_id_unique,
- j_is_countersign,
- j_is_valid,
- j_participator_report_content_handle,
- j_process_current_user_list,
- j_process_definition_key,
- j_process_instance_id,
- j_process_status_name_list,
- j_regulation_type,
- j_report_content,
- j_report_source,
- j_report_status,
- j_report_summary,
- j_report_type,
- j_report_user_contact,
- j_reportcol,
- j_update_time,
- jid
- ) values (
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?,
- ?
- )`;
- // 执行mql
- ret = odb.mql(mql,
- JSON.stringify(input.acceptGroupDepId, " ", 4), // null
- JSON.stringify(input.acceptGroupDepName, " ", 4), // null
- JSON.stringify(input.acceptUserDepId, " ", 4), // null
- ""+input.acceptUserDepName, // 支付系统事业部>运维系统部
- JSON.stringify(input.acceptUserGroup, " ", 4), // null
- JSON.stringify(input.acceptUserGroupId, " ", 4), // null
- input.acceptUserId, // 605
- ""+input.acceptUserRealName, // 杨春雷
- input.closeTime, // null
- JSON.stringify(input.countersignDepIdList, " ", 4), // null
- JSON.stringify(input.countersignDepNameList, " ", 4), // null
- ""+input.countersignRoleIdList, //
- ""+input.countersignRoleNameList, //
- input.createTime, // 2022-09-27 09:00:43
- input.createUserDepId, // 92
- ""+input.createUserDepName, // 支付系统事业部>运维系统部
- input.createUserId, // 605
- ""+input.createUserRealName, // 杨春雷
- JSON.stringify(input.currentProcessUserId, " ", 4), // null
- JSON.stringify(input.currentProcessUserRealName, " ", 4), // null
- ""+input.dataCenterIdList, // 261
- ""+input.dataCenterNameList, // 北京NPC
- input.expectedEndTime, // 2022-09-28 00:00:00
- input.expectedStartTime, // 2022-09-27 00:00:00
- ""+input.idUnique, // RX1000007047
- input.isCountersign, // 0
- input.isValid, // 1
- JSON.stringify(input.participatorReportContentHandle, " ", 4), // null
- ""+input.processCurrentUserList, // 杨春雷
- JSON.stringify(input.processDefinitionKey, " ", 4), // null
- ""+input.processInstanceId, // 1539041
- ""+input.processStatusNameList, // 创建人提出报备
- ""+input.regulationType, // 支付系统
- ""+input.reportContent, // 报备内容
- JSON.stringify(input.reportSource, " ", 4), // null
- ""+input.reportStatus, //
- ""+input.reportSummary, // 报备摘要
- ""+input.reportType, // 参与者
- JSON.stringify(input.reportUserContact, " ", 4), // null
- JSON.stringify(input.reportcol, " ", 4), // null
- input.updateTime, // 2022-09-27 09:01:28
- input.id // 1000007047
- );
- // 打印完成信息
- output.info={
- id: input.id,
- idUnique: input.idUnique
- };
- log.info(output.info);
- } catch(e) {
- if (typeof(e) == "object") {
- output.error = e;
- } else if (typeof(e) == "string") {
- output.error = "插库错误:" + e;
- } else {
- output.error = JSON.stringify(e);
- }
- log.error(output.error);
- }
- // 返回输出信息
- OUTPUT = output;
|