|
|
#include "BH_task_dateset.h"
|
|
|
|
|
|
#include <epm/epm.h>
|
|
|
#include <epm/epm_toolkit_tc_utils.h>
|
|
|
#include <ict/ict_userservice.h>
|
|
|
#include <tccore/item.h>
|
|
|
#include <ae/ae.h>
|
|
|
#include <tc/folder.h>
|
|
|
#include <tccore/aom.h>
|
|
|
#include <sa/sa.h>
|
|
|
#include <tccore/aom_prop.h>
|
|
|
#include <property/prop_errors.h>
|
|
|
#include <tccore/workspaceobject.h>
|
|
|
#include <tc/preferences.h>
|
|
|
#include <tccore//grm.h>
|
|
|
#include <tccore/grmtype.h>
|
|
|
#include <sa/am.h>
|
|
|
#include <cfm/cfm.h>
|
|
|
#include <bom/bom.h>
|
|
|
#include <tccore/uom.h>
|
|
|
#include <ps/ps.h>
|
|
|
#include <epm/signoff.h>
|
|
|
#include <fclasses/tc_date.h>
|
|
|
#include <ics/ics.h>
|
|
|
#include <ics/ics2.h>
|
|
|
#include <io.h>
|
|
|
#include <ae/dataset.h>
|
|
|
|
|
|
#include "common_itk_util.h"
|
|
|
|
|
|
/**
|
|
|
* @headerfile standard c & cpp header files
|
|
|
*/
|
|
|
#include <stdio.h>
|
|
|
#include <ctype.h>
|
|
|
#include <string.h>
|
|
|
#include <string>
|
|
|
#include <vector>
|
|
|
#include <map>
|
|
|
#include <fstream>
|
|
|
#include <iostream>
|
|
|
#include <algorithm>
|
|
|
#include <time.h>
|
|
|
#include <curl\curl.h>
|
|
|
|
|
|
/**
|
|
|
* @headerfile user's header files
|
|
|
*/
|
|
|
#include "handler_common.h"
|
|
|
#include "error_handling.h"
|
|
|
#include "common_itk_util.h"
|
|
|
#include "string_helper.h"
|
|
|
#include "ocilib.h"
|
|
|
//#include "ado.h"
|
|
|
|
|
|
extern "C" int POM_AM__set_application_bypass(logical bypass);
|
|
|
|
|
|
/*
|
|
|
* 获取当前yyyy-MM-dd HH-mm-ss格式的日期
|
|
|
*/
|
|
|
void get_current_time(char* updatetime) {
|
|
|
// 获取当前时间的秒数
|
|
|
time_t rawtime;
|
|
|
time(&rawtime);
|
|
|
|
|
|
// 将秒数转换为本地时间结构体
|
|
|
struct tm* timeinfo;
|
|
|
timeinfo = localtime(&rawtime);
|
|
|
|
|
|
// 格式化时间为字符串
|
|
|
sprintf(updatetime, "%04d-%02d-%02d %02d:%02d:%02d",
|
|
|
timeinfo->tm_year + 1900, // 年份从1900年开始计算
|
|
|
timeinfo->tm_mon + 1, // 月份从0开始计算
|
|
|
timeinfo->tm_mday, // 日
|
|
|
timeinfo->tm_hour, // 小时
|
|
|
timeinfo->tm_min, // 分钟
|
|
|
timeinfo->tm_sec); // 秒
|
|
|
}
|
|
|
|
|
|
|
|
|
/*
|
|
|
* 用于在流程handler完成后向SpringBoot程序发送请求
|
|
|
* 已测通
|
|
|
*/
|
|
|
int sendRequestToSpring() {
|
|
|
WriteLog("<待开始>start sendRequestToSpring:开始向springboot程序发送请求");
|
|
|
int ifail = ITK_ok;
|
|
|
|
|
|
CURL* curl;
|
|
|
CURLcode res;
|
|
|
curl = curl_easy_init();
|
|
|
if (curl) {
|
|
|
WriteLog("初始化curl完成,开始组织请求结构···");
|
|
|
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, "http://localhost:8080/part");
|
|
|
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
|
|
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "http");
|
|
|
struct curl_slist* headers = NULL;
|
|
|
headers = curl_slist_append(headers, "User-Agent: Apifox/1.0.0 (https://apifox.com)");
|
|
|
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
|
|
|
curl_easy_perform(curl);
|
|
|
curl_easy_cleanup(curl);
|
|
|
}
|
|
|
//WriteLog("<已完成>向springboot程序发送请求,返回结果:"+res);
|
|
|
WriteLog("<已完成>向springboot程序发送请求!");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
|
|
|
/// 新增handler,用于:将《物料自动下发》任务信息存到异步任务数据库表中
|
|
|
int BH_Part_Capp(EPM_action_message_t msg) {
|
|
|
char* log_file = NULL;
|
|
|
|
|
|
printf("创建BH_Part_Capp日志文件\n");
|
|
|
char* TO_SRM = (char*)malloc(sizeof("TO_SRM"));
|
|
|
strcpy(TO_SRM, "TO_SRM");
|
|
|
CreateLogFile(TO_SRM, &log_file);
|
|
|
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
int ifail = ITK_ok;
|
|
|
tag_t rootTask = NULLTAG;
|
|
|
int attachmentCount = 0;
|
|
|
tag_t* attachmentTags = NULL,
|
|
|
attachmentTag = NULLTAG;
|
|
|
char* url = (char*)MEM_alloc(1028 * sizeof(char));
|
|
|
char* username = (char*)MEM_alloc(1028 * sizeof(char));
|
|
|
char* password = (char*)MEM_alloc(1028 * sizeof(char));
|
|
|
|
|
|
char** referList; int num;
|
|
|
ITKCALL(ifail = PREF_ask_char_values("BH_CAPP_Oracle", &num, &referList));
|
|
|
if (num < 4) {
|
|
|
WriteLog("提示:配置首选项BH_CAPP_Oracle数量异常,请检查首选项配置是否正确!\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
string url_str = referList[0];
|
|
|
url_str.append("/").append(referList[1]);
|
|
|
|
|
|
tc_strcpy(url, url_str.c_str());
|
|
|
tc_strcpy(username, referList[2]);
|
|
|
tc_strcpy(password, referList[3]);
|
|
|
WriteLog("提示:获取到首选项BH_CAPP_Oracle中的数据库信息:\n >>>url==%s\n>>>username=%s\n>>>password=%s", url, referList[2],password);
|
|
|
|
|
|
/*用户,密码,ip+sid服务名*/
|
|
|
if (ConnServer(username,password,url)){
|
|
|
WriteLog("提示:Oracle数据表访问失败\n");
|
|
|
return ifail;
|
|
|
}else{
|
|
|
//TODO 2.获取任务信息
|
|
|
WriteLog("提示:Oracle数据表访问成功\n");
|
|
|
char* tasksource = NULL;
|
|
|
char* username = NULL;
|
|
|
char* userid = NULL;
|
|
|
char* flowid = NULL;
|
|
|
char* status = "未开始";//当前为:未开始
|
|
|
char* starttime = (char*)MEM_alloc(1028 * sizeof(char));
|
|
|
//获取用户名称、id,审批流程id
|
|
|
tag_t user;
|
|
|
ITKCALL(ifail = POM_get_user(&username, &user));
|
|
|
ITKCALL(ifail = POM_get_user_id(&userid));
|
|
|
char taskpuid[56] = "\0";
|
|
|
ITK__convert_tag_to_uid(msg.task, &flowid);
|
|
|
get_current_time(starttime);
|
|
|
|
|
|
//TODO 3.将任务信息存到数据库表中
|
|
|
char sql2[1024] = "\0";
|
|
|
sprintf(sql2, "insert into WHBH_CAPP_TASK(tasksource,username,userid,flowid,status,starttime) values('%s','%s','%s','%s','%s','%s')", "工作流程", username, userid, flowid, status, starttime);
|
|
|
WriteLog("提示:sql2==%s\n", sql2);
|
|
|
|
|
|
if (ExecuteSQLNoInputParam(sql2) == -1)
|
|
|
{
|
|
|
WriteLog("提示:数据插入 失败, %s \n", sql2);
|
|
|
return 1;
|
|
|
}else {
|
|
|
WriteLog("提示:开始插入数据》》》, %s \n", sql2);
|
|
|
ExecuteSQLNoInputParam("commit");
|
|
|
WriteLog("提示:WHBH_CAPP_TASK表插入任务信息成功\n");
|
|
|
//数据插入成功后,向springboot程序发送一条请求
|
|
|
sendRequestToSpring();
|
|
|
}
|
|
|
|
|
|
MEM_free(flowid);
|
|
|
MEM_free(userid);
|
|
|
MEM_free(username);
|
|
|
}
|
|
|
MEM_free(referList);
|
|
|
DisConnServer();
|
|
|
CloseLog();
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 变更自动下发流程handler
|
|
|
*/
|
|
|
int BH_Change_Capp(EPM_action_message_t msg) {
|
|
|
char* log_file = NULL;
|
|
|
printf("创建BH_Change_Capp日志文件\n");
|
|
|
char* TO_SRM = (char*)malloc(sizeof("TO_SRM"));
|
|
|
strcpy(TO_SRM, "TO_SRM");
|
|
|
CreateLogFile(TO_SRM, &log_file);
|
|
|
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
int ifail = ITK_ok;
|
|
|
|
|
|
char* url = (char*)MEM_alloc(1028 * sizeof(char));
|
|
|
char* oracle_username = (char*)MEM_alloc(1028 * sizeof(char));
|
|
|
char* oracle_password = (char*)MEM_alloc(1028 * sizeof(char));
|
|
|
|
|
|
char** referList; int num;
|
|
|
ITKCALL(ifail = PREF_ask_char_values("BH_CAPP_Oracle", &num, &referList));
|
|
|
if (num < 4) {
|
|
|
WriteLog("提示:配置首选项BH_CAPP_Oracle数量异常,请检查首选项配置是否正确!\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
string url_str = referList[0];
|
|
|
url_str.append("/").append(referList[1]);
|
|
|
|
|
|
tc_strcpy(url, url_str.c_str());
|
|
|
tc_strcpy(oracle_username, referList[2]);
|
|
|
tc_strcpy(oracle_password, referList[3]);
|
|
|
WriteLog("提示:获取到首选项BH_CAPP_Oracle中的数据库信息:\n >>>url==%s\n>>>username=%s\n>>>password=%s", url, referList[2], oracle_password);
|
|
|
|
|
|
/*用户,密码,ip+sid服务名*/
|
|
|
if (ConnServer(oracle_username, oracle_password, url)) {
|
|
|
WriteLog("提示:Oracle数据表访问失败\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
else {
|
|
|
// TODO 2.组织任务信息
|
|
|
WriteLog("提示:数据库连接成功,开始获取任务信息\n");
|
|
|
char* tasksource = NULL;
|
|
|
char* username = NULL;
|
|
|
char* userid = NULL;
|
|
|
char* status = NULL;//当前为:未开始
|
|
|
char* MSG = NULL;
|
|
|
tag_t rootTask = NULLTAG;
|
|
|
//获取用户名称、id,审批流程id
|
|
|
tag_t user;
|
|
|
POM_get_user(&username, &user);
|
|
|
POM_get_user_id(&userid);
|
|
|
char taskpuid[56] = "\0";
|
|
|
int attachmentCount = 0;
|
|
|
tag_t* attachmentTags = NULL,
|
|
|
attachmentTag = NULLTAG;;
|
|
|
|
|
|
|
|
|
//--------获取流程下的更改通知单,将更改通知单的item_id存到msg中,exe通过更改通知单id获取更改通知单对象
|
|
|
//获取流程任务的根任务
|
|
|
ITKCALL(ifail = EPM_ask_root_task(msg.task, &rootTask));
|
|
|
//获取流程目标/引用下关联的对象
|
|
|
ITKCALL(ifail = EPM_ask_attachments(rootTask, EPM_target_attachment, &attachmentCount, &attachmentTags));
|
|
|
//遍历流程下获取的对象:版本?更改通知单
|
|
|
if (attachmentCount > 0)
|
|
|
{
|
|
|
for (int i = 0; i < attachmentCount; i++)
|
|
|
{
|
|
|
char* object_type = NULL;
|
|
|
attachmentTag = attachmentTags[i];//流程下的对象
|
|
|
ITKCALL(ifail = AOM_ask_value_string(attachmentTag, "object_type", &object_type));
|
|
|
WriteLog("提示:流程下的attachmentTags[%d]对象的object_type==%s\n", i, object_type);
|
|
|
//判断流程下的对象类型是否为:更改通知单
|
|
|
if (stricmp(object_type, "ChangeNoticeRevision") == 0)
|
|
|
{//开始组织当前对象的数据保存到task
|
|
|
tasksource = "工作流程";
|
|
|
//char* flowid = NULL;
|
|
|
status = "未开始";//当前为:未开始
|
|
|
char* starttime = (char*)MEM_alloc(1028 * sizeof(char));
|
|
|
char* msgV = NULL;
|
|
|
get_current_time(starttime);
|
|
|
|
|
|
ITKCALL(ifail = AOM_ask_value_string(attachmentTag, "item_id", &msgV));
|
|
|
char sql2[1024] = "\0";
|
|
|
sprintf(sql2, "insert into WHBH_CAPP_TASK(tasksource,username,userid,msg,status,starttime) values('%s','%s','%s','%s','%s','%s')", tasksource, username, userid, msgV, status, starttime);
|
|
|
WriteLog("提示:sql2==%s\n", sql2);
|
|
|
|
|
|
if (ExecuteSQLNoInputParam(sql2) == -1)
|
|
|
{
|
|
|
WriteLog("提示:数据插入 失败, %s \n", sql2);
|
|
|
return 1;
|
|
|
}
|
|
|
else {
|
|
|
WriteLog("提示:开始插入数据》》》, %s \n", sql2);
|
|
|
ExecuteSQLNoInputParam("commit");
|
|
|
WriteLog("提示:WHBH_CAPP_TASK表插入任务信息成功\n");
|
|
|
//数据插入成功后,向springboot程序发送一条请求
|
|
|
sendRequestToSpring();
|
|
|
}
|
|
|
MEM_free(msgV);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
WriteLog("提示:流程下的attachmentTags[%d]对象的object_type==%s 非变更通知单,无法下发!\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
MEM_free(object_type);
|
|
|
}
|
|
|
}
|
|
|
MEM_free(attachmentTags);
|
|
|
MEM_free(userid);
|
|
|
MEM_free(username);
|
|
|
MEM_free(referList);
|
|
|
MEM_free(oracle_password);
|
|
|
MEM_free(oracle_username);
|
|
|
MEM_free(url);
|
|
|
}
|
|
|
DisConnServer();
|
|
|
CloseLog();
|
|
|
return ifail;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// 新增handler,用于:将《图纸自动下发》任务数据存到异步任务数据库表中
|
|
|
int BH_Design_Capp(EPM_action_message_t msg) {
|
|
|
char* log_file = NULL;
|
|
|
|
|
|
printf("创建BH_Design_Capp日志文件\n");
|
|
|
char* TO_SRM = (char*)malloc(sizeof("TO_SRM"));
|
|
|
strcpy(TO_SRM, "TO_SRM");
|
|
|
CreateLogFile(TO_SRM, &log_file);
|
|
|
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
int ifail = ITK_ok;
|
|
|
|
|
|
char* url = (char*)MEM_alloc(1028 * sizeof(char));
|
|
|
char* username = (char*)MEM_alloc(1028 * sizeof(char));
|
|
|
char* password = (char*)MEM_alloc(1028 * sizeof(char));
|
|
|
|
|
|
|
|
|
//sendRequestToSpring();
|
|
|
char** referList; int num;
|
|
|
ITKCALL(ifail = PREF_ask_char_values("BH_CAPP_Oracle", &num, &referList));
|
|
|
if (num < 4) {
|
|
|
WriteLog("提示:配置首选项BH_CAPP_Oracle数量异常,请检查首选项配置是否正确!\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
string url_str = referList[0];
|
|
|
url_str.append("/").append(referList[1]);
|
|
|
|
|
|
tc_strcpy(url, url_str.c_str());
|
|
|
tc_strcpy(username, referList[2]);
|
|
|
tc_strcpy(password, referList[3]);
|
|
|
WriteLog("提示:获取到首选项BH_CAPP_Oracle中的数据库信息:\n >>>url==%s\n>>>username=%s\n>>>password=%s", url, referList[2], password);
|
|
|
|
|
|
|
|
|
// TODO 1.连接数据库
|
|
|
//if (ConnServer("infodba", "infodba", "localhost/TC12")) {
|
|
|
if (ConnServer(username, password, url)) {
|
|
|
WriteLog("提示:Oracle数据表访问失败\n");
|
|
|
return ifail;
|
|
|
}else{
|
|
|
// TODO 2.组织任务信息
|
|
|
WriteLog("提示:数据库连接成功,开始获取任务信息\n");
|
|
|
char* tasksource = NULL;
|
|
|
char* username = NULL;
|
|
|
char* userid = NULL;
|
|
|
char* flowid = NULL;
|
|
|
char* status = "未开始";//当前为:未开始
|
|
|
//获取用户名称、id,审批流程id
|
|
|
tag_t user;
|
|
|
POM_get_user(&username, &user);
|
|
|
POM_get_user_id(&userid);
|
|
|
char taskpuid[56] = "\0";
|
|
|
char* starttime = (char*)MEM_alloc(1028 * sizeof(char));
|
|
|
ITK__convert_tag_to_uid(msg.task, &flowid);
|
|
|
|
|
|
get_current_time(starttime);
|
|
|
|
|
|
// TODO 3.将任务信息存到数据库表中
|
|
|
char sql2[1024] = "\0";
|
|
|
sprintf(sql2, "insert into WHBH_CAPP_TASK(tasksource,username,userid,flowid,status,starttime) values('%s','%s','%s','%s','%s','%s')", "工作流程", username, userid, flowid, status, starttime);
|
|
|
WriteLog("提示:sql2==%s\n", sql2);
|
|
|
if (ExecuteSQLNoInputParam(sql2) == -1)
|
|
|
{
|
|
|
WriteLog("提示:数据插入 失败, %s \n", sql2);
|
|
|
return 1;
|
|
|
}
|
|
|
else {
|
|
|
ExecuteSQLNoInputParam("commit");
|
|
|
WriteLog("提示:WHBH_CAPP_TASK表插入任务信息成功\n");
|
|
|
//数据插入成功后,向springboot程序发送一条请求
|
|
|
sendRequestToSpring();
|
|
|
}
|
|
|
MEM_free(flowid);
|
|
|
MEM_free(userid);
|
|
|
MEM_free(username);
|
|
|
}
|
|
|
DisConnServer();
|
|
|
CloseLog();
|
|
|
return ifail;
|
|
|
} |