You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

229 lines
7.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#define _CRT_SECURE_NO_WARNINGS
#include "epm_handler_common.h"
#include <tc\preferences.h>
#include <tc\tc_macros.h>
#include <fclasses/tc_date.h>
#include <epm\epm.h>
#include <epm/signoff.h>
#include <epm/epm_task_template_itk.h>
#include <ae/ae.h>
#include <tccore\item.h>
#include <tccore\aom.h>
#include <ict/ict_userservice.h>
#include <tccore\aom_prop.h>
#include <tccore\item.h>
#include <tccore//grm.h>
#include <tccore/grmtype.h>
#include <string>
#include <sa/user.h>
#include <map>
#include <vector>
#include<iostream>
#include <tc\preferences.h>
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","adoEOF")rename("BOF","adoBOF")
using namespace std;
#define DOFREE(obj) \
{ \
if(obj) \
{ \
MEM_free(obj); \
obj = NULL; \
} \
}
int Send_Order_Process(void *returnValue){
printf("==================订单评审流程 START =======================\n");
//获取传递过来的参数
tag_t process = NULLTAG, tmp_select_signoff_task = NULLTAG, template_tag = NULLTAG;
int cnt_task = 0, signoff_cnt = 0;
tag_t * tasks = NULLTAG, * signoffs = NULLTAG;
char * processUser = NULL, * arctic = NULL;
char tmp_sub_task_name[WSO_name_size_c+1] = {'\0'};
ITKCALL(USERARG_get_tag_argument(&process));
//ITKCALL(USERARG_get_tag_argument(&itemRevision));
//ITKCALL(USERARG_get_string_argument(&processTemplate));
ITKCALL(USERARG_get_string_argument(&processUser));
//车型
ITKCALL(USERARG_get_string_argument(&arctic));
////发起流程
////查找模板EPM_find_template模板名称模板类型返回流程模板
//ITKCALL( EPM_find_template( processTemplate, PROCESS_TEMPLATE, &template_tag) );
//printf("获取流程模板成功!================\n");
//获取首选项的值
//printf("==================获取首选项的值 =======================\n");
//PREF_ask_char_values(processUser, &valueNum, &values);//获得首选项
//EPM_ask_tasks参数流程任务状态返回任务数任务,已开始的任务
ITKCALL( EPM_ask_tasks(process,EPM_started, &cnt_task, &tasks ));
//EPM_assign_responsible_party将责任方分配给给定的任务。责任方可以是用户也可以是资源池,参数:任务,责任人
printf("流程任务数:%d+++++++++++++++++++++++++++\n",cnt_task);
for( int k = 0; k < cnt_task; k++ )
{
//流程节点的名称
ITKCALL( EPM_ask_name( tasks[k] , tmp_sub_task_name ));
printf("流程节点名称:%s+++++++++++++++++++++++++++\n",tmp_sub_task_name);
////流程节点的类型
/*ITKCALL( AOM_ask_value_string( tasks[k] , "object_type" , &sub_task_object_type ));
printf("流程节点类型%s=====================\n",sub_task_object_type);*/
//if(strcmp(tmp_sub_task_name,nodeUsers[0]) == 0)
//{
//根据任务名称获取任务
ITKCALL( EPM_ask_sub_task( tasks[k] , EPM_select_signoff_team_task , &tmp_select_signoff_task ));
/*if(strstr(nodeUsers[1],",") != NULL)
{
char ** userIds = new char *[64];
int userIdNum = 0;
split(nodeUsers[1], ",", userIds, &userIdNum);
for (int l = 0; l < userIdNum; l++)
{
tag_t user = NULLTAG;
ITKCALL( SA_find_user(userIds[l],&user));
ITKCALL( EPM_create_adhoc_signoff( tmp_select_signoff_task , user , &signoff_cnt , &signoffs ) );
}
userIds = NULL;
}
else
{
tag_t user = NULLTAG;
ITKCALL( SA_find_user(nodeUsers[1],&user));
ITKCALL( EPM_create_adhoc_signoff( tmp_select_signoff_task , user , &signoff_cnt , &signoffs ) );
}*/
tag_t user = NULLTAG;
if(strcmp(tmp_sub_task_name,"评审") == 0){
ITKCALL( SA_find_user(processUser,&user));
ITKCALL( EPM_create_adhoc_signoff( tmp_select_signoff_task , user , &signoff_cnt , &signoffs ) );
ITKCALL( EPM_set_adhoc_signoff_selection_done( tmp_select_signoff_task , true ) );
ITKCALL(EPM_trigger_action(tmp_select_signoff_task,EPM_complete_action, ""));
}
DOFREE( signoffs );
//}
}
//DOFREE( values );
DOFREE( processUser );
DOFREE( arctic );
DOFREE( tasks );
printf("==================订单评审流程 END =======================\n");
return ITK_ok;
}
int JL_Auto_Order_Process(EPM_action_message_t msg){
//订单评审流程结束之后按钮发起bom搭建才能够点击
int ifail = ITK_ok;
tag_t rootTask = NULLTAG,*attachments;
int attachments_num = 0;
char *object_type = NULL;
EPM_ask_root_task(msg.task, &rootTask);
//获取任务目标对象
EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments);
::CoInitialize(NULL); //初始化OLE/COM库环境
HRESULT hr = NULL;
_ConnectionPtr m_pConnection; // 数据库
_RecordsetPtr m_pRecordset; // 命令
_CommandPtr m_pCommand; // 记录
char* server_address;
int valueNum=0;
PREF_ask_char_value("TC11_SqlServer_Link_ITK", valueNum, &server_address);
hr = m_pConnection.CreateInstance(_uuidof(Connection));//创建连接对象实例
if (SUCCEEDED(hr))
{
m_pConnection->ConnectionString = (server_address);
//m_pConnection->ConnectionString = ("Provider = SQLOLEDB.1; Persist Security Info = False; User ID =infodba; Password=infodba; Initial Catalog = TCTEST2; Data Source = 10.110.81.13");
//m_pConnection->ConnectionString = ("Provider = SQLOLEDB.1; Persist Security Info = False; User ID =lw; Password=lw590; Initial Catalog = HZPC; Data Source = 192.168.200.6");
//printf("\n==========================================================\n");
hr = m_pConnection->Open("", "", "", adConnectUnspecified);//打开数据库
if (FAILED(hr))
{
printf("Open Failed!");
return 1;
}
else
{
for (int i = 0; i < attachments_num; i++)
{
char *uid_value;
AOM_ask_value_string(attachments[i], "object_type", &object_type);
printf("类型为:%s\n",object_type);
if(strstr(object_type,"OrderRevision") == NULL || strstr(object_type,"Master") != NULL){
continue;
}
ITK__convert_tag_to_uid(attachments[i],&uid_value);
printf("UID为%s\n",uid_value);
char* updateSql = (char*)calloc(1024, sizeof(char));
sprintf(updateSql,"update GD_CONTROLSTYPE_TABLE set ENABLED = 'true' where ORDER_TAGU = '%s'and CONTROL_NAME = 'btnbom_4'; update GD_CONTROLSTYPE_TABLE set BACKGROUND = 'GREEN' where ORDER_TAGU = '%s'and CONTROL_NAME = 'label_36'; ",uid_value,uid_value);
printf("写入语句为:%s\n",updateSql);
m_pConnection->Execute(_bstr_t(updateSql), 0, adCmdText);
updateSql = NULL;
DOFREE(uid_value);
//if(strstr(release_value,"Gd6_D") !=NULL && strstr(revision,"D00") == NULL){
// //向焊装排产系统数据库表写入发布的零件号、件名、版本、发布日期、发布时间等信息
// //修改数据库
// printf("开始写入\n");
// //开始写入
// AOM_ask_value_string(attachments[i],"object_name",&item_name);
// AOM_ask_value_string(attachments[i],"item_id",&item_id);
// date_t date = NULLDATE;
// char *date_string = NULL;
// AOM_ask_value_date(attachments[i],"date_released",&date);
// DATE_date_to_string(date,"%Y-%m-%d %H:%M",&date_string);
// printf("创建时间为:%s\n",date_string);
// //printf("%s\n",date.year);
// //printf("%s\n",date.month);
// //printf("%s\n",date.day);
// //printf("%s\n",date.hour);
// //printf("%s\n",date.minute);
// //printf("%s\n",date.second);
// char* insertSql = (char*)calloc(1024, sizeof(char));
// //sprintf(insertSql,"insert into AAA(PARTNO,PARTNAME,VerNO,REL_date) values('%s','%s','%s','%s')",item_id,item_name,revision,date_string);
// sprintf(insertSql,"insert into PLM_GetPartVerNO(PARTNO,PARTNAME,VerNO,REL_date) values('%s','%s','%s','%s')",item_id,item_name,revision,date_string);
// printf("写入语句为:%s\n",insertSql);
// m_pConnection->Execute(_bstr_t(insertSql), 0, adCmdText);
// insertSql = NULL;
// DOFREE(release_name);
// DOFREE(date_string);
//}
}
}
}
else
{
printf("Create instance of connection failed!");
return 1;
}
DOFREE(server_address);
DOFREE(object_type);
return ifail;
}