|
|
#include "yb_send_to_erp.h"
|
|
|
#include "tccore\iman_msg.h"
|
|
|
#include <libxl.h>
|
|
|
#include <sstream>
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
#define ITK_err 919012
|
|
|
|
|
|
using namespace libxl;
|
|
|
|
|
|
|
|
|
extern "C" int POM_AM__set_application_bypass(logical bypass);
|
|
|
|
|
|
|
|
|
int len(char* p)
|
|
|
{
|
|
|
int i = 0;
|
|
|
while (*p++)i++;
|
|
|
return i;
|
|
|
}
|
|
|
TCHAR* charToTchar(const char* szWord) {
|
|
|
//TCHAR tszWord[1024] = {0};
|
|
|
//#ifdef UNICODE
|
|
|
//MultiByteToWideChar(CP_ACP, 0, szWord, -1, tszWord, 1024);
|
|
|
//#else
|
|
|
//strcpy(tszWord, szWord);
|
|
|
//#endif
|
|
|
//return tszWord;
|
|
|
|
|
|
//char *CStr = "string to convert";
|
|
|
|
|
|
/*size_t len = strlen(szWord) + 1;
|
|
|
|
|
|
size_t converted = 0;
|
|
|
|
|
|
wchar_t *WStr;
|
|
|
|
|
|
WStr = (wchar_t*)malloc(len*sizeof(wchar_t));
|
|
|
|
|
|
mbstowcs_s(&converted, WStr, len, szWord, _TRUNCATE);*/
|
|
|
|
|
|
|
|
|
int iSize;
|
|
|
wchar_t* pwszUnicode;
|
|
|
|
|
|
//返回接受字符串所需缓冲区的大小,已经包含字符结尾符'\0'
|
|
|
iSize = MultiByteToWideChar(CP_ACP, 0, szWord, -1, NULL, 0); //iSize =wcslen(pwsUnicode)+1=6
|
|
|
pwszUnicode = (wchar_t*)malloc(iSize * sizeof(wchar_t)); //不需要 pwszUnicode = (wchar_t *)malloc((iSize+1)*sizeof(wchar_t))
|
|
|
MultiByteToWideChar(CP_ACP, 0, szWord, -1, pwszUnicode, iSize);
|
|
|
|
|
|
return pwszUnicode;
|
|
|
}
|
|
|
string WStringToString(const wstring& ws)
|
|
|
{
|
|
|
string curLocale = setlocale(LC_ALL, NULL); // curLocale = "C";
|
|
|
setlocale(LC_ALL, "chs");
|
|
|
const wchar_t* _Source = ws.c_str();
|
|
|
//cout<<ws.size()<<"--单元格长度--"<<endl;
|
|
|
size_t _Dsize = 2 * ws.size() + 1;
|
|
|
char* _Dest = new char[_Dsize];
|
|
|
memset(_Dest, 0, _Dsize);//memset内存赋值函数(参数1:目标起始地址,参数2:要赋的值,参数3:要赋值的字节数)
|
|
|
wcstombs(_Dest, _Source, _Dsize);
|
|
|
string result = _Dest;
|
|
|
delete[]_Dest;
|
|
|
setlocale(LC_ALL, curLocale.c_str());
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
bool IsCellEmpty(int cellType)
|
|
|
{
|
|
|
if ((cellType == CELLTYPE_BLANK) || (cellType == CELLTYPE_EMPTY)) {
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
string& replace_all(string& str, const string& old_value, const string& new_value)
|
|
|
{
|
|
|
if (strstr(str.c_str(), old_value.c_str()) != NULL) {
|
|
|
vector<string> type_vec;
|
|
|
Split(str.c_str(), old_value.c_str(), type_vec);
|
|
|
char new_str[512] = "\0";
|
|
|
for (int i = 0; i < type_vec.size(); i++)
|
|
|
{
|
|
|
strcat(new_str, type_vec[i].c_str());
|
|
|
if (i < type_vec.size() - 1) {
|
|
|
strcat(new_str, new_value.c_str());
|
|
|
}
|
|
|
}
|
|
|
string new_value(new_str);
|
|
|
str = new_value.c_str();
|
|
|
}
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
wstring StringToWString(const string& s)
|
|
|
{
|
|
|
setlocale(LC_ALL, "chs");
|
|
|
const char* _Source = s.c_str();
|
|
|
size_t _Dsize = s.size() + 1;
|
|
|
wchar_t* _Dest = new wchar_t[_Dsize];
|
|
|
wmemset(_Dest, 0, _Dsize);
|
|
|
mbstowcs(_Dest, _Source, _Dsize);
|
|
|
wstring result = _Dest;
|
|
|
delete[]_Dest;
|
|
|
setlocale(LC_ALL, "C");
|
|
|
return result;
|
|
|
}
|
|
|
double stringToDouble(string num)
|
|
|
{
|
|
|
bool minus = false; //标记是否是负数
|
|
|
string real = num; //real表示num的绝对值
|
|
|
if (num.at(0) == '-')
|
|
|
{
|
|
|
minus = true;
|
|
|
real = num.substr(1, num.size() - 1);
|
|
|
}
|
|
|
|
|
|
char c;
|
|
|
int i = 0;
|
|
|
double result = 0.0, dec = 10.0;
|
|
|
bool isDec = false; //标记是否有小数
|
|
|
unsigned long size = real.size();
|
|
|
while (i < size)
|
|
|
{
|
|
|
c = real.at(i);
|
|
|
if (c == '.')
|
|
|
{//包含小数
|
|
|
isDec = true;
|
|
|
i++;
|
|
|
continue;
|
|
|
}
|
|
|
if (!isDec)
|
|
|
{
|
|
|
result = result * 10 + c - '0';
|
|
|
}
|
|
|
else
|
|
|
{//识别小数点之后都进入这个分支
|
|
|
result = result + (c - '0') / dec;
|
|
|
dec *= 10;
|
|
|
}
|
|
|
i++;
|
|
|
}
|
|
|
|
|
|
if (minus == true) {
|
|
|
result = -result;
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
string DoubleToStringByStdToString(double value)
|
|
|
{
|
|
|
ostringstream stream;
|
|
|
stream << value;
|
|
|
return stream.str();
|
|
|
//const string& new_val = to_string(value);
|
|
|
//return new_val;
|
|
|
}
|
|
|
string doubleToString(const double& dbNum)
|
|
|
{
|
|
|
char* chCode;
|
|
|
chCode = new(std::nothrow)char[20];
|
|
|
sprintf(chCode, "%.2lf", dbNum); // .2 是控制输出精度的,两位小数
|
|
|
string strCode(chCode);
|
|
|
delete[]chCode;
|
|
|
return strCode;
|
|
|
}
|
|
|
|
|
|
int char2int(const char* str) {
|
|
|
const char* p = str;
|
|
|
bool neg = false;
|
|
|
int res = 0;
|
|
|
if (*str == '-' || *str == '+') {
|
|
|
str++;
|
|
|
}
|
|
|
|
|
|
while (*str != 0) {
|
|
|
if (*str < '0' || *str > '9') {
|
|
|
break;
|
|
|
}
|
|
|
res = res * 10 + *str - '0';
|
|
|
str++;
|
|
|
}
|
|
|
|
|
|
if (*p == '-') {
|
|
|
res = -res;
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
void split(char* src, const char* separator, char** dest, int* num) {
|
|
|
/*
|
|
|
src 源字符串的首地址(buf的地址)
|
|
|
separator 指定的分割字符
|
|
|
dest 接收子字符串的数组
|
|
|
num 分割后子字符串的个数
|
|
|
*/
|
|
|
char* pNext;
|
|
|
int count = 0;
|
|
|
if (src == NULL || strlen(src) == 0) //如果传入的地址为空或长度为0,直接终止
|
|
|
return;
|
|
|
if (separator == NULL || strlen(separator) == 0) //如未指定分割的字符串,直接终止
|
|
|
return;
|
|
|
pNext = (char*)strtok(src, separator); //必须使用(char *)进行强制类型转换(虽然不写有的编译器中不会出现指针错误)
|
|
|
while (pNext != NULL) {
|
|
|
*dest++ = pNext;
|
|
|
++count;
|
|
|
pNext = (char*)strtok(NULL, separator); //必须使用(char *)进行强制类型转换
|
|
|
}
|
|
|
*num = count;
|
|
|
}
|
|
|
|
|
|
int Connor_set_bypass(void* returnValue)
|
|
|
{
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
int Connor_close_bypass(void* returnValue)
|
|
|
{
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* bypass
|
|
|
*/
|
|
|
int Connor_bypass(EPM_action_message_t msg) {
|
|
|
ECHO("==================bypass START =======================\n");
|
|
|
int ifail = ITK_ok, arg_cnt;
|
|
|
char* argflag = NULL, * argvalue = NULL, * arg = NULL;
|
|
|
int i = 0, j = 0;
|
|
|
BOOL bypass = FALSE;
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
ECHO("参数个数为:%d\n", arg_cnt);
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
if (arg_cnt > 0)
|
|
|
{
|
|
|
for (i = 0; i < arg_cnt; i++)
|
|
|
{
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
|
|
|
if (stricmp(argflag, "bypass") == 0)
|
|
|
{
|
|
|
if (stricmp(argvalue, "true") == 0) {
|
|
|
bypass = TRUE;
|
|
|
}
|
|
|
else if (stricmp(argvalue, "false") == 0) {
|
|
|
bypass = FALSE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
if (argflag != NULL) {
|
|
|
MEM_free(argflag);
|
|
|
argflag = NULL;
|
|
|
}
|
|
|
if (argvalue != NULL) {
|
|
|
MEM_free(argvalue);
|
|
|
argvalue = NULL;
|
|
|
}
|
|
|
}
|
|
|
printf("bypass=%d /n", bypass);
|
|
|
POM_AM__set_application_bypass(bypass);
|
|
|
ECHO("==================bypass END =======================\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
//获取外购件分类属性
|
|
|
//获取外购件分类属性
|
|
|
int get_classValue(tag_t target, EPR_PRAT& item) {
|
|
|
printf("===================================\n");
|
|
|
printf("获取分类属性 开始\n");
|
|
|
printf("===================================\n");
|
|
|
tag_t ico_tag;
|
|
|
char* value;
|
|
|
char* classId;
|
|
|
//char* name;
|
|
|
//ITKCALL(AOM_ask_value_string(target, "object_name", &name));
|
|
|
char* uid;
|
|
|
ITK__convert_tag_to_uid(target, &uid);
|
|
|
ICS_ask_classification_object(target, &ico_tag);
|
|
|
ICS_ico_ask_class(ico_tag, &classId);
|
|
|
if (strcmp("", classId) == 0) {
|
|
|
return 1;
|
|
|
}
|
|
|
item.class_id.assign(classId);
|
|
|
printf(">> classId: %s\n", classId);
|
|
|
|
|
|
int attr_cnt = 0, * attr_ids = NULL;
|
|
|
tag_t* attr_tags = NULL;
|
|
|
char** attr_names = NULL;
|
|
|
int theAttributeCount = 0;
|
|
|
tag_t* attr;
|
|
|
int* attrIDs;
|
|
|
map<string, string> valueMap;
|
|
|
map<string, string>::iterator iter;
|
|
|
|
|
|
int num = 0;
|
|
|
char** names;
|
|
|
char** values;
|
|
|
ICS_ask_attributes_of_classification_obj(ico_tag, &num, &names, &values);
|
|
|
for (int i = 0; i < num; i++)
|
|
|
{
|
|
|
printf(">> name: %s value: %s\n", names[i], values[i]);
|
|
|
valueMap[names[i]] = values[i];
|
|
|
|
|
|
}
|
|
|
//ICS_class_ask_attributes(classId, &theAttributeCount, &attr, &attrIDs);
|
|
|
////ICS_ico_ask_all_attributes(ico_tag, &theAttributeCount, &theAttributeIds, &theAttributeValCounts, &theAttributeValues);
|
|
|
//char* format = NULL;
|
|
|
//for (int j = 0; j < theAttributeCount; j++) {
|
|
|
|
|
|
// char attrID[64] = "";
|
|
|
// sprintf(attrID, "%d", attrIDs[j]);
|
|
|
// printf(">> attrID: %s\n", attrID);
|
|
|
// ICS_ask_attribute_value(ico_tag, attrID, &value);
|
|
|
// printf(">> value: %s\n", value);
|
|
|
// char search[64] = "\0";
|
|
|
// sprintf(search, "-400 = %d", attrIDs[j]);
|
|
|
// ITKCALL(ICS_attribute_search(search, -400, ICS_SEARCH_CASE_INSENSITIVE, &attr_cnt, &attr_tags, &attr_ids, &attr_names));
|
|
|
// ITKCALL(ICS_attribute_ask_property(attr_ids[0], "FORMAT1", &format));
|
|
|
// printf(">> Format: %s\n", format);
|
|
|
// if (format != NULL && strcmp("", format) != 0 && strcmp(" ", format) != 0) {
|
|
|
// char* key_lov_name;
|
|
|
// int options = 0;
|
|
|
// int n_lov_entries = 0;
|
|
|
// char** lov_keys;
|
|
|
// char** lov_values;
|
|
|
// logical* deprecated_staus;
|
|
|
// char* owning_site;
|
|
|
// int n_shared_sites = 0;
|
|
|
// char** shared_sites;
|
|
|
// ICS_keylov_get_keylov(format, &key_lov_name, &options, &n_lov_entries, &lov_keys, &lov_values, &deprecated_staus,
|
|
|
// &owning_site, &n_shared_sites, &shared_sites);
|
|
|
// printf(">> 下拉值数量: %d\n", n_lov_entries);
|
|
|
// printf(">> 下拉值为: %s\n", value);
|
|
|
// string key = attr_names[0];
|
|
|
// if (n_lov_entries == 0) {
|
|
|
// string val = value;
|
|
|
// valueMap[key] = val;
|
|
|
// //valueMap.insert(map < string, string >::value_type(key, val));
|
|
|
// }else {
|
|
|
// for (int q = 0; q < n_lov_entries; q++) {
|
|
|
// if (strcmp(value, lov_keys[q]) == 0) {
|
|
|
// string val = lov_keys[q];
|
|
|
// valueMap[key] = val;
|
|
|
// break;
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
///* if (key_lov_name != NULL) {
|
|
|
// DOFREE(key_lov_name);
|
|
|
// DOFREE(lov_keys);
|
|
|
// DOFREE(lov_values);
|
|
|
// DOFREE(deprecated_staus);
|
|
|
// DOFREE(owning_site);
|
|
|
// DOFREE(shared_sites);
|
|
|
// }*/
|
|
|
// }
|
|
|
// DOFREE(attr_tags);
|
|
|
// DOFREE(attr_ids);
|
|
|
// DOFREE(attr_names);
|
|
|
// DOFREE(value);
|
|
|
// DOFREE(format);
|
|
|
//}
|
|
|
int c_sql_value_count = 0;
|
|
|
char** c_sql_values;
|
|
|
ITKCALL(PREF_ask_char_values("HS2_SQL_Connect2", &c_sql_value_count, &c_sql_values));
|
|
|
if (c_sql_value_count != 3)
|
|
|
{
|
|
|
WriteLog("首选项 DFL2_SQL_Connect2 配置错误 数量%d ", c_sql_value_count);
|
|
|
CloseLog();
|
|
|
return 0;
|
|
|
}
|
|
|
if (ConnServer(c_sql_values[1], c_sql_values[2], c_sql_values[0]))//"tc11","infodba","//172.16.50.40/tc11" "TC12","infodba","172.16.68.13/tc1"
|
|
|
{
|
|
|
printf("提示:中间数据表访问失败\n");
|
|
|
return 1;
|
|
|
}
|
|
|
else {
|
|
|
printf("提示:中间数据表访问成功\n");
|
|
|
char sql[1024] = "\0";
|
|
|
sprintf(sql, "select * from AHMC_ERP_RULE where PCID= '%s'", classId);
|
|
|
printf("提示:获取拼接规则 开始\n");
|
|
|
printf("提示:sql==%s\n", sql);
|
|
|
int outputColumn = 0, outputValueCount = 0;
|
|
|
char*** outputValue = NULL;
|
|
|
if (QuerySQLNoInputParam(sql, &outputColumn, &outputValueCount, &outputValue) == -1)
|
|
|
{
|
|
|
printf("提示:获取拼接规则 失败, %s \n", sql);
|
|
|
return 1;
|
|
|
}
|
|
|
printf("outputValueCount=%d\n", outputValueCount);
|
|
|
printf("outputColumn=%d\n", outputColumn);
|
|
|
//free(sql);
|
|
|
char* name_split = NULL;
|
|
|
char* spec_split = NULL;
|
|
|
char* bz_split = NULL;
|
|
|
char* unit_split = NULL;
|
|
|
char* code_split = NULL;
|
|
|
char names[2048] = { 0 };
|
|
|
char specs[2048] = { 0 };
|
|
|
char bzs[2048] = { 0 };
|
|
|
char units[2048] = { 0 };
|
|
|
char code[2048] = { 0 };
|
|
|
if (outputValueCount > 0) {
|
|
|
name_split = outputValue[0][1];
|
|
|
spec_split = outputValue[0][2];
|
|
|
bz_split = outputValue[0][3];
|
|
|
unit_split = outputValue[0][4];
|
|
|
code_split = outputValue[0][5];
|
|
|
printf("名称拼接====%s\n", name_split);
|
|
|
printf("规格拼接====%s\n", spec_split);
|
|
|
printf("客户包装拼接====%s\n", bz_split);
|
|
|
printf("单位拼接====%s\n", unit_split);
|
|
|
printf("客户代号拼接====%s\n", code_split);
|
|
|
vector<string> type_vec1;
|
|
|
vector<string> type_vec2;
|
|
|
vector<string> type_vec3;
|
|
|
vector<string> rev_vec;
|
|
|
char* rev_val;
|
|
|
if (strcmp("", name_split) != 0 && strcmp(" ", name_split) != 0) {
|
|
|
if (strstr(name_split, "/") != NULL) {
|
|
|
Split(name_split, "/", type_vec1);
|
|
|
for (int i = 0; i < type_vec1.size(); i++)
|
|
|
{
|
|
|
//map<string, string>::iterator iter;
|
|
|
string val_str = "";
|
|
|
if (strstr(type_vec1[i].c_str(), "rev.") != NULL) {
|
|
|
Split(type_vec1[i], ".", rev_vec);
|
|
|
ITKCALL(AOM_ask_value_string(target, rev_vec[1].c_str(), &rev_val));
|
|
|
val_str = rev_val;
|
|
|
rev_vec.clear();
|
|
|
if (rev_val != NULL) {
|
|
|
DOFREE(rev_val);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
iter = valueMap.find(type_vec1[i]);
|
|
|
val_str = (iter->second).c_str();
|
|
|
|
|
|
}
|
|
|
if (strcmp("", val_str.c_str()) != 0 && (" ", val_str.c_str()) != 0) {
|
|
|
if (strcmp("", names) != 0 && strcmp(" ", names) != 0) {
|
|
|
strcat(names, "/");
|
|
|
}
|
|
|
strcat(names, val_str.c_str());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
//map<string, string>::iterator iter;
|
|
|
string val_str = "";
|
|
|
if (strstr(name_split, "rev.") != NULL) {
|
|
|
Split(name_split, ".", rev_vec);
|
|
|
ITKCALL(AOM_ask_value_string(target, rev_vec[1].c_str(), &rev_val));
|
|
|
val_str = rev_val;
|
|
|
rev_vec.clear();
|
|
|
if (rev_val != NULL) {
|
|
|
DOFREE(rev_val);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
iter = valueMap.find(name_split);
|
|
|
val_str = (iter->second).c_str();
|
|
|
|
|
|
}
|
|
|
strcat(names, val_str.c_str());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (strcmp("", spec_split) != 0 && strcmp(" ", spec_split) != 0) {
|
|
|
if (strstr(spec_split, "/") != NULL) {
|
|
|
Split(spec_split, "/", type_vec2);
|
|
|
for (int i = 0; i < type_vec2.size(); i++)
|
|
|
{
|
|
|
//map<string, string>::iterator iter;
|
|
|
string val_str = "";
|
|
|
if (strstr(type_vec2[i].c_str(), "rev.") != NULL) {
|
|
|
Split(type_vec2[i], ".", rev_vec);
|
|
|
ITKCALL(AOM_ask_value_string(target, rev_vec[1].c_str(), &rev_val));
|
|
|
val_str = rev_val;
|
|
|
rev_vec.clear();
|
|
|
if (rev_val != NULL) {
|
|
|
DOFREE(rev_val);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
iter = valueMap.find(type_vec2[i]);
|
|
|
val_str = (iter->second).c_str();
|
|
|
|
|
|
}
|
|
|
if (strcmp("", val_str.c_str()) != 0 && (" ", val_str.c_str()) != 0) {
|
|
|
if (strcmp("", specs) != 0 && strcmp(" ", specs) != 0) {
|
|
|
strcat(specs, "/");
|
|
|
}
|
|
|
strcat(specs, val_str.c_str());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
//map<string, string>::iterator iter;
|
|
|
string val_str = "";
|
|
|
if (strstr(spec_split, "rev.") != NULL) {
|
|
|
Split(spec_split, ".", rev_vec);
|
|
|
ITKCALL(AOM_ask_value_string(target, rev_vec[1].c_str(), &rev_val));
|
|
|
val_str = rev_val;
|
|
|
rev_vec.clear();
|
|
|
if (rev_val != NULL) {
|
|
|
DOFREE(rev_val);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
iter = valueMap.find(spec_split);
|
|
|
val_str = (iter->second).c_str();
|
|
|
|
|
|
}
|
|
|
strcat(specs, val_str.c_str());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (strcmp("", bz_split) != 0 && strcmp(" ", bz_split) != 0) {
|
|
|
if (strstr(bz_split, "/") != NULL) {
|
|
|
Split(bz_split, "/", type_vec3);
|
|
|
for (int i = 0; i < type_vec3.size(); i++)
|
|
|
{
|
|
|
//map<string, string>::iterator iter;
|
|
|
string val_str = "";
|
|
|
if (strstr(type_vec3[i].c_str(), "rev.") != NULL) {
|
|
|
Split(type_vec3[i], ".", rev_vec);
|
|
|
ITKCALL(AOM_ask_value_string(target, rev_vec[1].c_str(), &rev_val));
|
|
|
val_str = rev_val;
|
|
|
rev_vec.clear();
|
|
|
if (rev_val != NULL) {
|
|
|
DOFREE(rev_val);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
iter = valueMap.find(type_vec3[i]);
|
|
|
val_str = (iter->second).c_str();
|
|
|
|
|
|
}
|
|
|
if (strcmp("", val_str.c_str()) != 0 && (" ", val_str.c_str()) != 0) {
|
|
|
if (strcmp("", bzs) != 0 && strcmp(" ", bzs) != 0) {
|
|
|
strcat(bzs, "/");
|
|
|
}
|
|
|
strcat(bzs, val_str.c_str());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
//map<string, string>::iterator iter;
|
|
|
string val_str = "";
|
|
|
if (strstr(bz_split, "rev.") != NULL) {
|
|
|
Split(bz_split, ".", rev_vec);
|
|
|
ITKCALL(AOM_ask_value_string(target, rev_vec[1].c_str(), &rev_val));
|
|
|
val_str = rev_val;
|
|
|
rev_vec.clear();
|
|
|
if (rev_val != NULL) {
|
|
|
DOFREE(rev_val);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
iter = valueMap.find(bz_split);
|
|
|
val_str = (iter->second).c_str();
|
|
|
|
|
|
}
|
|
|
strcat(bzs, val_str.c_str());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (strcmp("", unit_split) != 0 && strcmp(" ", unit_split) != 0) {
|
|
|
string val_str = "";
|
|
|
if (strstr(unit_split, "rev.") != NULL) {
|
|
|
Split(unit_split, ".", rev_vec);
|
|
|
ITKCALL(AOM_UIF_ask_value(target, rev_vec[1].c_str(), &rev_val));
|
|
|
val_str = rev_val;
|
|
|
rev_vec.clear();
|
|
|
if (rev_val != NULL) {
|
|
|
DOFREE(rev_val);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
iter = valueMap.find(unit_split);
|
|
|
val_str = (iter->second).c_str();
|
|
|
|
|
|
}
|
|
|
strcat(units, val_str.c_str());
|
|
|
|
|
|
}
|
|
|
if (strcmp("", code_split) != 0 && strcmp(" ", code_split) != 0) {
|
|
|
string val_str = "";
|
|
|
if (strstr(code_split, "rev.") != NULL) {
|
|
|
Split(code_split, ".", rev_vec);
|
|
|
ITKCALL(AOM_ask_value_string(target, rev_vec[1].c_str(), &rev_val));
|
|
|
val_str = rev_val;
|
|
|
rev_vec.clear();
|
|
|
if (rev_val != NULL) {
|
|
|
DOFREE(rev_val);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
iter = valueMap.find(code_split);
|
|
|
val_str = (iter->second).c_str();
|
|
|
|
|
|
}
|
|
|
strcat(code, val_str.c_str());
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
printf("提示:names==%s\n", names);
|
|
|
printf("提示:specs==%s\n", specs);
|
|
|
printf("提示:bzs==%s\n", bzs);
|
|
|
printf("提示:units==%s\n", units);
|
|
|
printf("提示:code==%s\n", code);
|
|
|
item.unit_code.assign(units);
|
|
|
item.code.assign(code);
|
|
|
if (strcmp(names, "") != 0 && strcmp(names, " ") != 0) {
|
|
|
item.name.assign(names);
|
|
|
}
|
|
|
else {
|
|
|
item.name.assign(" ");
|
|
|
}
|
|
|
if (strcmp(specs, "") != 0 && strcmp(specs, " ") != 0) {
|
|
|
item.spec.assign(specs);
|
|
|
}
|
|
|
else {
|
|
|
item.spec.assign(" ");
|
|
|
}
|
|
|
if (strcmp(bzs, "") != 0 && strcmp(bzs, " ") != 0) {
|
|
|
item.bzs.assign(bzs);
|
|
|
}
|
|
|
else {
|
|
|
item.bzs.assign(" ");
|
|
|
}
|
|
|
}
|
|
|
//if (ConnServer(c_sql_values[1], c_sql_values[2], c_sql_values[0]))//"tc11","infodba","//172.16.50.40/tc11" "TC12","infodba","172.16.68.13/tc1"
|
|
|
//{
|
|
|
// printf("提示:中间数据表访问失败\n");
|
|
|
// return 1;
|
|
|
//}
|
|
|
//else {
|
|
|
// printf("提示:中间数据表访问成功\n");
|
|
|
// char sql[1024] = "\0";
|
|
|
// sprintf(sql, "select * from AHMC_ERP_RULE where PCID= '%s'", classId);
|
|
|
// printf("提示:获取拼接规则 开始\n");
|
|
|
// printf("提示:sql==%s\n", sql);
|
|
|
// int outputColumn = 0, outputValueCount = 0;
|
|
|
// char*** outputValue = NULL;
|
|
|
// if (QuerySQLNoInputParam(sql, &outputColumn, &outputValueCount, &outputValue) == -1)
|
|
|
// {
|
|
|
// printf("提示:获取拼接规则 失败, %s \n", sql);
|
|
|
// return 1;
|
|
|
// }
|
|
|
// printf("outputValueCount=%d\n", outputValueCount);
|
|
|
// printf("outputColumn=%d\n", outputColumn);
|
|
|
// //free(sql);
|
|
|
// char* name_split = NULL;
|
|
|
// char* spec_split = NULL;
|
|
|
// char* bz_split = NULL;
|
|
|
// char* unit_split = NULL;
|
|
|
// char* code_split = NULL;
|
|
|
// char names[2048] = { 0 };
|
|
|
// char specs[2048] = { 0 };
|
|
|
// char bzs[2048] = { 0 };
|
|
|
// char units[2048] = { 0 };
|
|
|
// char code[2048] = { 0 };
|
|
|
// if (outputValueCount > 0) {
|
|
|
// name_split = outputValue[0][1];
|
|
|
// spec_split = outputValue[0][2];
|
|
|
// bz_split = outputValue[0][3];
|
|
|
// unit_split = outputValue[0][4];
|
|
|
// code_split = outputValue[0][5];
|
|
|
// printf("名称拼接====%s\n", name_split);
|
|
|
// printf("规格拼接====%s\n", spec_split);
|
|
|
// printf("客户包装拼接====%s\n", bz_split);
|
|
|
// printf("单位拼接====%s\n", unit_split);
|
|
|
// printf("客户代号拼接====%s\n", code_split);
|
|
|
// vector<string> type_vec1;
|
|
|
// vector<string> type_vec2;
|
|
|
// vector<string> type_vec3;
|
|
|
// char sql1[1024] = "\0";
|
|
|
// char sql2[1024] = "\0";
|
|
|
// char sql3[1024] = "\0";
|
|
|
// char sql4[1024] = "\0";
|
|
|
// char sql5[1024] = "\0";
|
|
|
// if (strstr(name_split,"/") != NULL) {
|
|
|
// Split(name_split, "/", type_vec1);
|
|
|
// strcat(sql1, "select ");
|
|
|
// for (int i = 0; i < type_vec1.size(); i++)
|
|
|
// {
|
|
|
// strcat(sql1, type_vec1[i].c_str());
|
|
|
// if (i < type_vec1.size() - 1) {
|
|
|
// strcat(sql1, ",");
|
|
|
// }
|
|
|
// }
|
|
|
// strcat(sql1, " from PICM0 where REREFU= '");
|
|
|
// strcat(sql1, uid);
|
|
|
// strcat(sql1, "'");
|
|
|
// }
|
|
|
// else {
|
|
|
// strcat(sql1,"select ");
|
|
|
// strcat(sql1, name_split);
|
|
|
// strcat(sql1, " from PICM0 where REREFU= '");
|
|
|
// strcat(sql1, uid);
|
|
|
// strcat(sql1, "'");
|
|
|
// }
|
|
|
// if (strstr(spec_split, "/") != NULL) {
|
|
|
// Split(spec_split, "/", type_vec2);
|
|
|
// strcat(sql2, "select ");
|
|
|
// for (int i = 0; i < type_vec2.size(); i++)
|
|
|
// {
|
|
|
// strcat(sql2, type_vec2[i].c_str());
|
|
|
// if (i < type_vec2.size() - 1) {
|
|
|
// strcat(sql2, ",");
|
|
|
// }
|
|
|
// }
|
|
|
// strcat(sql2, " from PICM0 where REREFU= '");
|
|
|
// strcat(sql2, uid);
|
|
|
// strcat(sql2, "'");
|
|
|
// }
|
|
|
// else {
|
|
|
// strcat(sql2, "select ");
|
|
|
// strcat(sql2, spec_split);
|
|
|
// strcat(sql2, " from PICM0 where REREFU= '");
|
|
|
// strcat(sql2, uid);
|
|
|
// strcat(sql2, "'");
|
|
|
// }
|
|
|
// if (strstr(bz_split, "/") != NULL) {
|
|
|
// Split(bz_split, "/", type_vec3);
|
|
|
// strcat(sql3, "select ");
|
|
|
// for (int i = 0; i < type_vec3.size(); i++)
|
|
|
// {
|
|
|
// strcat(sql3, type_vec3[i].c_str());
|
|
|
// if (i < type_vec3.size() - 1) {
|
|
|
// strcat(sql3, ",");
|
|
|
// }
|
|
|
// }
|
|
|
// strcat(sql3, " from PICM0 where REREFU= '");
|
|
|
// strcat(sql3, uid);
|
|
|
// strcat(sql3, "'");
|
|
|
// }
|
|
|
// else {
|
|
|
// strcat(sql3, "select ");
|
|
|
// strcat(sql3, bz_split);
|
|
|
// strcat(sql3, " from PICM0 where REREFU= '");
|
|
|
// strcat(sql3, uid);
|
|
|
// strcat(sql3, "'");
|
|
|
// }
|
|
|
// strcat(sql4, "select ");
|
|
|
// strcat(sql4, unit_split);
|
|
|
// strcat(sql4, " from PICM0 where REREFU= '");
|
|
|
// strcat(sql4, uid);
|
|
|
// strcat(sql4, "'");
|
|
|
//
|
|
|
// strcat(sql5, "select ");
|
|
|
// strcat(sql5, code_split);
|
|
|
// strcat(sql5, " from PICM0 where REREFU= '");
|
|
|
// strcat(sql5, uid);
|
|
|
// strcat(sql5, "'");
|
|
|
//
|
|
|
// printf("提示:sql1==%s\n", sql1);
|
|
|
// printf("提示:sql2==%s\n", sql2);
|
|
|
// printf("提示:sql3==%s\n", sql3);
|
|
|
// printf("提示:sql4==%s\n", sql4);
|
|
|
// printf("提示:sql5==%s\n", sql5);
|
|
|
// int outputColumn1 = 0, outputValueCount1 = 0;
|
|
|
// char*** outputValue1 = NULL;
|
|
|
// if (QuerySQLNoInputParam(sql1, &outputColumn1, &outputValueCount1, &outputValue1) == 0)
|
|
|
// {
|
|
|
// for (int i = 0; i < outputColumn1; i++)
|
|
|
// {
|
|
|
// if (strcmp(outputValue1[0][i],"") != 0 && strcmp(outputValue1[0][i], "") != 0 && strcmp(outputValue1[0][i], "null") != 0) {
|
|
|
// strcat(names, outputValue1[0][i]);
|
|
|
// if (i < outputColumn1 - 1) {
|
|
|
// strcat(names, "/");
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
// int outputColumn2 = 0, outputValueCount2 = 0;
|
|
|
// char*** outputValue2 = NULL;
|
|
|
// if (QuerySQLNoInputParam(sql2, &outputColumn2, &outputValueCount2, &outputValue2) == 0)
|
|
|
// {
|
|
|
|
|
|
// for (int i = 0; i < outputColumn2; i++)
|
|
|
// {
|
|
|
// if (strcmp(outputValue2[0][i], "") != 0 && strcmp(outputValue2[0][i], "") != 0 && strcmp(outputValue2[0][i], "null") != 0) {
|
|
|
// strcat(specs, outputValue2[0][i]);
|
|
|
// if (i < outputColumn2 - 1) {
|
|
|
// strcat(specs, "/");
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// int outputColumn3 = 0, outputValueCount3 = 0;
|
|
|
// char*** outputValue3 = NULL;
|
|
|
// if (QuerySQLNoInputParam(sql3, &outputColumn3, &outputValueCount3, &outputValue3) == 0)
|
|
|
// {
|
|
|
// for (int i = 0; i < outputColumn3; i++)
|
|
|
// {
|
|
|
// if (strcmp(outputValue3[0][i], "") != 0 && strcmp(outputValue3[0][i], "") != 0 && strcmp(outputValue3[0][i], "null") != 0) {
|
|
|
// strcat(bzs, outputValue3[0][i]);
|
|
|
// if (i < outputColumn3 - 1) {
|
|
|
// strcat(bzs, "/");
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// int outputColumn4 = 0, outputValueCount4 = 0;
|
|
|
// char*** outputValue4 = NULL;
|
|
|
// if (QuerySQLNoInputParam(sql4, &outputColumn4, &outputValueCount4, &outputValue4) == 0)
|
|
|
// {
|
|
|
// if (strcmp(outputValue4[0][0], "") != 0 && strcmp(outputValue4[0][0], "") != 0 && strcmp(outputValue4[0][0], "null") != 0) {
|
|
|
// strcat(units, outputValue4[0][0]);
|
|
|
// }
|
|
|
// else {
|
|
|
// strcat(units, " ");
|
|
|
// }
|
|
|
// }
|
|
|
// int outputColumn5 = 0, outputValueCount5 = 0;
|
|
|
// char*** outputValue5 = NULL;
|
|
|
// if (QuerySQLNoInputParam(sql5, &outputColumn5, &outputValueCount5, &outputValue5) == 0)
|
|
|
// {
|
|
|
// if (strcmp(outputValue5[0][0], "") != 0 && strcmp(outputValue5[0][0], "") != 0 && strcmp(outputValue5[0][0], "null") != 0) {
|
|
|
// strcat(code, outputValue5[0][0]);
|
|
|
// }
|
|
|
// else {
|
|
|
// strcat(code, " ");
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// printf("提示:names==%s\n", names);
|
|
|
// printf("提示:specs==%s\n", specs);
|
|
|
// printf("提示:bzs==%s\n", bzs);
|
|
|
// printf("提示:units==%s\n", units);
|
|
|
// printf("提示:code==%s\n", code);
|
|
|
// item.unit_code.assign(units);
|
|
|
// item.code.assign(code);
|
|
|
// if (strcmp(names,"") != 0 && strcmp(names, " ") != 0) {
|
|
|
// item.name.assign(names);
|
|
|
// }
|
|
|
// else {
|
|
|
// item.name.assign(" ");
|
|
|
// }
|
|
|
// if (strcmp(specs, "") != 0 && strcmp(specs, " ") != 0) {
|
|
|
// item.spec.assign(specs);
|
|
|
// }
|
|
|
// else {
|
|
|
// item.spec.assign(" ");
|
|
|
// }
|
|
|
// if (strcmp(bzs, "") != 0 && strcmp(bzs, " ") != 0) {
|
|
|
// item.bzs.assign(bzs);
|
|
|
// }
|
|
|
// else {
|
|
|
// item.bzs.assign(" ");
|
|
|
// }
|
|
|
//}
|
|
|
valueMap.clear();
|
|
|
DOFREE(classId);
|
|
|
DisConnServer();
|
|
|
printf("===================================\n");
|
|
|
printf("获取分类属性 结束\n");
|
|
|
printf("===================================\n");
|
|
|
return 0;
|
|
|
}
|
|
|
//物料传递erp
|
|
|
int HS_ERP_Part(EPM_action_message_t msg) {
|
|
|
printf("===================================\n");
|
|
|
printf("物料传递erp 开始\n");
|
|
|
printf("===================================\n");
|
|
|
int ifail = ITK_ok;
|
|
|
printf("开超级权限\n");
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
//从流程中的参数
|
|
|
tag_t task_tag = NULL_TAG,
|
|
|
root_task_tag = NULLTAG,
|
|
|
* attachments;;
|
|
|
task_tag = msg.task;
|
|
|
int att_cnt = 0;
|
|
|
int value_count = 0;
|
|
|
char** values;
|
|
|
char* mail_url;
|
|
|
ITKCALL(PREF_ask_char_value("Autocode_SendEmailServer_URL", 0, &mail_url));
|
|
|
|
|
|
char* url;
|
|
|
//ITKCALL(PREF_ask_char_values("HS_UNIT_CODE", &value_count, &values));
|
|
|
ITKCALL(PREF_ask_char_value("HS_WL_URL", 0, &url));
|
|
|
tag_t executor;
|
|
|
char* user_id;
|
|
|
char* user_uid;
|
|
|
char* person_name;
|
|
|
EPM_ask_root_task(task_tag, &root_task_tag);
|
|
|
ITKCALL(AOM_ask_value_tag(task_tag, "owning_user", &executor));
|
|
|
tag_t person_tag = NULLTAG;
|
|
|
char* mail_str = NULL;
|
|
|
ITKCALL(ifail = AOM_ask_value_tag(executor, "person", &person_tag));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(person_tag, "PA9", &mail_str));
|
|
|
|
|
|
ITKCALL(AOM_ask_value_string(executor, "user_id", &user_id));
|
|
|
POM_tag_to_uid(executor, &user_uid);
|
|
|
SA_ask_user_person_name2(executor, &person_name);
|
|
|
EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments);
|
|
|
char* taget_type;
|
|
|
vector<EPR_PRAT> part_vec;
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t target = attachments[i];
|
|
|
boolean flag = false;
|
|
|
int form_count = 0;
|
|
|
tag_t* forms = NULLTAG;
|
|
|
tag_t master_form = NULLTAG;
|
|
|
ITKCALL(AOM_ask_value_string(target, "object_type", &taget_type));
|
|
|
printf("taget_type=%s\n", taget_type);
|
|
|
if (((strstr(taget_type, "Revision") != NULL) || (strstr(taget_type, "revision") != NULL))
|
|
|
&& (strstr(taget_type, "Master") == NULL) && (strstr(taget_type, "master") == NULL)
|
|
|
&& (strstr(taget_type, "BOM") == NULL) && (strstr(taget_type, "bom") == NULL) && (strstr(taget_type, "Bom") == NULL))
|
|
|
{
|
|
|
EPR_PRAT part = {};
|
|
|
char* value;
|
|
|
ITKCALL(AOM_ask_value_string(target, "item_id", &value));
|
|
|
if (value != NULL) {
|
|
|
part.id.assign(value);
|
|
|
MEM_free(value);
|
|
|
value = NULL;
|
|
|
}
|
|
|
else {
|
|
|
part.id.assign(" ");
|
|
|
}
|
|
|
/*
|
|
|
ITKCALL(AOM_ask_value_string(target, "hs2_partscode", &value));
|
|
|
if (value != NULL) {
|
|
|
part.code.assign(value);
|
|
|
MEM_free(value);
|
|
|
value = NULL;
|
|
|
}
|
|
|
else {
|
|
|
part.code.assign(" ");
|
|
|
}
|
|
|
|
|
|
ITKCALL(AOM_ask_value_string(target, "hs2_unit", &value));
|
|
|
|
|
|
* ITKCALL(AOM_UIF_ask_value(target, "hs2_unit", &value));
|
|
|
if (value != NULL) {
|
|
|
vector<string> code_vec;
|
|
|
for (int k = 0; k < value_count; k++) {
|
|
|
if (strstr(values[k], "=") != NULL) {
|
|
|
Split(values[k], "=", code_vec);
|
|
|
if (strcmp(code_vec[0].c_str(), value) == 0) {
|
|
|
part.unit_code.assign(code_vec[1]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
MEM_free(value);
|
|
|
value = NULL;
|
|
|
}
|
|
|
else {
|
|
|
part.unit_code.assign(" ");
|
|
|
}
|
|
|
|
|
|
if (value != NULL) {
|
|
|
part.unit_code.assign(value);
|
|
|
MEM_free(value);
|
|
|
value = NULL;
|
|
|
}
|
|
|
else {
|
|
|
part.unit_code.assign(" ");
|
|
|
}
|
|
|
*/
|
|
|
get_classValue(target, part);
|
|
|
part_vec.push_back(part);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
time_t t;
|
|
|
struct tm* lt;
|
|
|
time(&t);//获取Unix时间戳。
|
|
|
lt = localtime(&t);//转为时间结构。
|
|
|
char file_name[256] = "";
|
|
|
char cmd[1000] = "";
|
|
|
char* tc_root_dir = getenv("tc_root");
|
|
|
sprintf(file_name, "%s-%d%d%d%d%d%d-PART", user_id, 1900 + lt->tm_year, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec);
|
|
|
|
|
|
char path[128] = "\0";
|
|
|
strcat(path, "D:\\Siemens\\PLMtoERPlogs");
|
|
|
strcat(path, "\\");
|
|
|
strcat(path, file_name);
|
|
|
strcat(path, ".txt");
|
|
|
FILE* fpWrite = fopen(path, "w");
|
|
|
printf("path=%s\n", path);
|
|
|
char part_value[20480] = "\0";
|
|
|
for (int i = 0; i < part_vec.size(); i++)
|
|
|
{
|
|
|
strcat(part_value, (part_vec[i].id).c_str());
|
|
|
strcat(part_value, ";");
|
|
|
strcat(part_value, (part_vec[i].name).c_str());
|
|
|
strcat(part_value, ";");
|
|
|
strcat(part_value, (part_vec[i].spec).c_str());
|
|
|
strcat(part_value, ";");
|
|
|
strcat(part_value, (part_vec[i].code).c_str());
|
|
|
strcat(part_value, ";");
|
|
|
strcat(part_value, (part_vec[i].class_id).c_str());
|
|
|
strcat(part_value, ";");
|
|
|
strcat(part_value, (part_vec[i].unit_code).c_str());
|
|
|
strcat(part_value, ";");
|
|
|
strcat(part_value, (part_vec[i].bzs).c_str());
|
|
|
if (i < part_vec.size() - 1) {
|
|
|
strcat(part_value, "&");
|
|
|
}
|
|
|
}
|
|
|
fprintf(fpWrite, "%s", part_value);
|
|
|
fclose(fpWrite);
|
|
|
char* all_mail_sjr;
|
|
|
ITKCALL(PREF_ask_char_value("HS2_SendEmailServer_ALL_SJR", 0, &all_mail_sjr));
|
|
|
char mail_str_all[1024] = "\0";
|
|
|
strcpy(mail_str_all, all_mail_sjr);
|
|
|
if (strstr(mail_str_all, mail_str) == NULL) {
|
|
|
strcat(mail_str_all, ",");
|
|
|
strcat(mail_str_all, mail_str);
|
|
|
}
|
|
|
|
|
|
printf("mail_str_all=%s\n", mail_str_all);
|
|
|
printf("mail_url=%s\n", mail_url);
|
|
|
strcpy(cmd, "java -jar ");
|
|
|
strcat(cmd, tc_root_dir);
|
|
|
strcat(cmd, "\\bin\\HSSendToERP.jar");
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, "PART");
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, path);
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, person_name);
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, url);
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, mail_str_all);
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, mail_url);
|
|
|
printf("%s", cmd);
|
|
|
WinExec(cmd, SW_NORMAL);
|
|
|
//system(cmd);
|
|
|
|
|
|
printf("关超级权限\n");
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
printf("===================================\n");
|
|
|
printf("物料传递erp 结束\n");
|
|
|
printf("===================================\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
void getchibomline_value(tag_t tagt, tag_t top_line_tag, vector<EPR_BOM>& boms, boolean flag) {
|
|
|
int c_line_count = 0;
|
|
|
tag_t* c_line_tags = NULL;
|
|
|
printf("nnnn\n");
|
|
|
tag_t fu_tag = NULLTAG;
|
|
|
ITKCALL(AOM_ask_value_tag(top_line_tag, "bl_line_object", &fu_tag));//获取BOMLINE关联的版本
|
|
|
char* fu_id;
|
|
|
ITKCALL(BOM_line_ask_all_child_lines(top_line_tag, &c_line_count, &c_line_tags));
|
|
|
EPR_BOM bom{};
|
|
|
ITKCALL(AOM_ask_value_string(fu_tag, "item_id", &fu_id));
|
|
|
printf("父件id==%s\n", fu_id);
|
|
|
bom.cinvCode = fu_id;
|
|
|
char* ver;
|
|
|
char* desc;
|
|
|
ITKCALL(AOM_ask_value_string(fu_tag, "item_revision_id", &ver));
|
|
|
ITKCALL(AOM_ask_value_string(fu_tag, "object_desc", &desc));
|
|
|
char ver_desc[128] = "\0";
|
|
|
strcat(ver_desc, ver);
|
|
|
strcat(ver_desc, "-");
|
|
|
strcat(ver_desc, desc);
|
|
|
bom.version = ver_desc;
|
|
|
vector<EPR_ZJ> zjs;
|
|
|
if (c_line_count == 0) {
|
|
|
printf("下面没有BOM结构\n");
|
|
|
}
|
|
|
else {
|
|
|
for (int m = 0; m < c_line_count; m++)
|
|
|
{
|
|
|
EPR_ZJ zj{};
|
|
|
tag_t c_line_tag = c_line_tags[m];
|
|
|
char* zi_id;
|
|
|
char* zi_num;
|
|
|
char* zi_jc_num;
|
|
|
char* seq;
|
|
|
//char seq[128] = "\0";
|
|
|
//sprintf(seq,"%d",m+1);
|
|
|
tag_t zi_tag = NULLTAG;
|
|
|
ITKCALL(AOM_ask_value_tag(c_line_tag, "bl_line_object", &zi_tag));//获取BOMLINE关联的版本
|
|
|
ITKCALL(AOM_ask_value_string(zi_tag, "item_id", &zi_id));
|
|
|
ITKCALL(AOM_ask_value_string(c_line_tag, "bl_quantity", &zi_num));
|
|
|
ITKCALL(AOM_ask_value_string(c_line_tag, "bl_occ_hs2_QtyD", &zi_jc_num));
|
|
|
ITKCALL(AOM_ask_value_string(c_line_tag, "bl_sequence_no", &seq));
|
|
|
printf("子件行号=%s\n", seq);
|
|
|
if (zi_id != NULL) {
|
|
|
zj.invCode = zi_id;
|
|
|
}
|
|
|
else {
|
|
|
zj.invCode = " ";
|
|
|
}
|
|
|
if (seq != NULL) {
|
|
|
zj.sortSeq = seq;
|
|
|
}
|
|
|
else {
|
|
|
zj.sortSeq = " ";
|
|
|
}
|
|
|
if (zi_num != NULL) {
|
|
|
zj.baseQtyN = zi_num;
|
|
|
}
|
|
|
else {
|
|
|
zj.baseQtyN = " ";
|
|
|
}
|
|
|
if (zi_jc_num != NULL) {
|
|
|
zj.baseQtyD = zi_jc_num;
|
|
|
}
|
|
|
else {
|
|
|
zj.baseQtyD = " ";
|
|
|
}
|
|
|
zjs.push_back(zj);
|
|
|
}
|
|
|
bom.zjs = zjs;
|
|
|
}
|
|
|
boms.push_back(bom);
|
|
|
if (flag) {
|
|
|
if (c_line_count == 0) {
|
|
|
printf("下面没有BOM结构\n");
|
|
|
}
|
|
|
else {
|
|
|
for (int m = 0; m < c_line_count; m++)
|
|
|
{
|
|
|
tag_t c_line_tag = c_line_tags[m];
|
|
|
int c_c_line_count = 0;
|
|
|
tag_t* c_c_line_tags = NULL;
|
|
|
ITKCALL(BOM_line_ask_all_child_lines(c_line_tag, &c_c_line_count, &c_c_line_tags));
|
|
|
if (c_c_line_count > 0)
|
|
|
{
|
|
|
getchibomline_value(tagt, c_line_tag, boms, flag);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//BOM传递erp-全部层级
|
|
|
int HS_ERP_BOM_ALL(EPM_action_message_t msg)
|
|
|
{
|
|
|
printf("===================================\n");
|
|
|
printf("BOM传递erp 开始\n");
|
|
|
printf("===================================\n");
|
|
|
int ifail = ITK_ok;
|
|
|
printf("开超级权限\n");
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
int att_cnt = 0;
|
|
|
//从流程中的参数
|
|
|
tag_t task_tag = NULL_TAG,
|
|
|
root_task_tag = NULLTAG,
|
|
|
* attachments;;
|
|
|
task_tag = msg.task;
|
|
|
tag_t executor;
|
|
|
char* user_id;
|
|
|
char* user_uid;
|
|
|
EPM_ask_root_task(task_tag, &root_task_tag);
|
|
|
char* mail_url;
|
|
|
ITKCALL(PREF_ask_char_value("Autocode_SendEmailServer_URL", 0, &mail_url));
|
|
|
char* url;
|
|
|
ITKCALL(PREF_ask_char_value("HS_BOM_URL", 0, &url));
|
|
|
char* person_name;
|
|
|
ITKCALL(AOM_ask_value_tag(task_tag, "owning_user", &executor));
|
|
|
tag_t person_tag = NULLTAG;
|
|
|
char* mail_str = NULL;
|
|
|
ITKCALL(ifail = AOM_ask_value_tag(executor, "person", &person_tag));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(person_tag, "PA9", &mail_str));
|
|
|
ITKCALL(AOM_ask_value_string(executor, "user_id", &user_id));
|
|
|
SA_ask_user_person_name2(executor, &person_name);
|
|
|
POM_tag_to_uid(executor, &user_uid);
|
|
|
EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments);
|
|
|
vector<EPR_BOM> boms;
|
|
|
string str = "";
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t tagt = attachments[i];//
|
|
|
char* id = NULL;
|
|
|
char* item_rev = NULL;
|
|
|
char* uid = NULL;
|
|
|
char* object_string = NULL;
|
|
|
if (checkIsTypeOrSubtype(tagt, "PSBOMViewRevision") != 1)
|
|
|
{
|
|
|
printf("类型不是PSBOMViewRevision\n");
|
|
|
continue;
|
|
|
}
|
|
|
printf("类型是PSBOMViewRevision,继续\n");
|
|
|
int c_line_count = 0;
|
|
|
tag_t bom_window_tag = NULLTAG,
|
|
|
top_line_tag = NULLTAG,
|
|
|
target_tag = NULLTAG,
|
|
|
* c_line_tags;
|
|
|
char* target_type;
|
|
|
ITKCALL(ifail = AOM_ask_value_string(tagt, "object_string", &object_string));
|
|
|
if (strcmp("", str.c_str()) == 0) {
|
|
|
str = object_string;
|
|
|
if (strstr(str.c_str(), "/") != NULL) {
|
|
|
str = replace_all(str, "/", "-");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ITKCALL(BOM_create_window(&bom_window_tag));//创建window视图
|
|
|
ITKCALL(BOM_set_window_top_line_bvr(bom_window_tag, tagt, &top_line_tag));//获取顶层bomline
|
|
|
ITKCALL(AOM_ask_value_tag(top_line_tag, "bl_line_object", &target_tag));//获取BOMLINE关联的版本
|
|
|
ITKCALL(BOM_line_ask_all_child_lines(top_line_tag, &c_line_count, &c_line_tags));
|
|
|
if (c_line_count == 0) {
|
|
|
printf("没有BOM结构\n");
|
|
|
}
|
|
|
else {
|
|
|
boolean flag = true;
|
|
|
getchibomline_value(tagt, top_line_tag, boms, flag);
|
|
|
}
|
|
|
ITKCALL(BOM_close_window(bom_window_tag));
|
|
|
|
|
|
|
|
|
}
|
|
|
if (boms.size() > 0) {
|
|
|
time_t t;
|
|
|
struct tm* lt;
|
|
|
time(&t);//获取Unix时间戳。
|
|
|
lt = localtime(&t);//转为时间结构。
|
|
|
char file_name[256] = "";
|
|
|
char cmd[1024] = "";
|
|
|
char* tc_root_dir = getenv("tc_root");
|
|
|
sprintf(file_name, "%s-%d%02d%02d%02d%02d%02d-BOM-%s", user_id, 1900 + lt->tm_year, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec, str.c_str());
|
|
|
|
|
|
char path[128] = "\0";
|
|
|
strcat(path, "D:\\Siemens\\PLMtoERPlogs");
|
|
|
strcat(path, "\\");
|
|
|
strcat(path, file_name);
|
|
|
strcat(path, ".txt");
|
|
|
FILE* fpWrite = fopen(path, "w");
|
|
|
for (int j = 0; j < boms.size(); j++)
|
|
|
{
|
|
|
vector<EPR_ZJ> zjs = boms[j].zjs;
|
|
|
char bom_value[8000] = "\0";
|
|
|
strcat(bom_value, (boms[j].cinvCode).c_str());
|
|
|
strcat(bom_value, ";");
|
|
|
strcat(bom_value, (boms[j].version).c_str());
|
|
|
strcat(bom_value, "|");
|
|
|
for (int k = 0; k < zjs.size(); k++)
|
|
|
{
|
|
|
if (strcmp("", (zjs[k].sortSeq).c_str()) == 0) {
|
|
|
strcat(bom_value, " ");
|
|
|
}
|
|
|
else {
|
|
|
strcat(bom_value, (zjs[k].sortSeq).c_str());
|
|
|
}
|
|
|
strcat(bom_value, ";");
|
|
|
if (strcmp("", (zjs[k].invCode).c_str()) == 0) {
|
|
|
strcat(bom_value, " ");
|
|
|
}
|
|
|
else {
|
|
|
strcat(bom_value, (zjs[k].invCode).c_str());
|
|
|
}
|
|
|
strcat(bom_value, ";");
|
|
|
if (strcmp("", (zjs[k].baseQtyN).c_str()) == 0 || strcmp(" ", (zjs[k].baseQtyN).c_str()) == 0) {
|
|
|
strcat(bom_value, "1");
|
|
|
}
|
|
|
else {
|
|
|
strcat(bom_value, (zjs[k].baseQtyN).c_str());
|
|
|
}
|
|
|
strcat(bom_value, ";");
|
|
|
if (strcmp("", (zjs[k].baseQtyD).c_str()) == 0 || strcmp(" ", (zjs[k].baseQtyD).c_str()) == 0) {
|
|
|
strcat(bom_value, "1");
|
|
|
}
|
|
|
else {
|
|
|
strcat(bom_value, (zjs[k].baseQtyD).c_str());
|
|
|
}
|
|
|
if (k < zjs.size() - 1) {
|
|
|
strcat(bom_value, "&");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
fprintf(fpWrite, "%s\n", bom_value);
|
|
|
}
|
|
|
fclose(fpWrite);
|
|
|
char* all_mail_sjr;
|
|
|
ITKCALL(PREF_ask_char_value("HS2_SendEmailServer_ALL_SJR", 0, &all_mail_sjr));
|
|
|
char mail_str_all[1024] = "\0";
|
|
|
strcpy(mail_str_all, all_mail_sjr);
|
|
|
if (strstr(mail_str_all, mail_str) == NULL) {
|
|
|
strcat(mail_str_all, ",");
|
|
|
strcat(mail_str_all, mail_str);
|
|
|
}
|
|
|
|
|
|
printf("mail_str_all=%s\n", mail_str_all);
|
|
|
strcpy(cmd, "java -jar ");
|
|
|
strcat(cmd, tc_root_dir);
|
|
|
strcat(cmd, "\\bin\\HSSendToERP.jar");
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, "BOM");
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, path);
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, person_name);
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, url);
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, mail_str_all);
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, mail_url);
|
|
|
printf("%s", cmd);
|
|
|
WinExec(cmd, SW_NORMAL);
|
|
|
//system(cmd);
|
|
|
|
|
|
|
|
|
//AOM_lock(master_form);
|
|
|
//ITKCALL(AOM_set_value_string(master_form, "y4_ERPwlzt", "已传递"));
|
|
|
//AOM_save(master_form);
|
|
|
//AOM_unlock(master_form);
|
|
|
}
|
|
|
|
|
|
printf("关超级权限\n");
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
printf("===================================\n");
|
|
|
printf("BOM传递erp 结束\n");
|
|
|
printf("===================================\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
//BOM传递erp
|
|
|
int HS_ERP_BOM(EPM_action_message_t msg)
|
|
|
{
|
|
|
printf("===================================\n");
|
|
|
printf("BOM传递erp 开始\n");
|
|
|
printf("===================================\n");
|
|
|
int ifail = ITK_ok;
|
|
|
printf("开超级权限\n");
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
int att_cnt = 0;
|
|
|
//从流程中的参数
|
|
|
tag_t task_tag = NULL_TAG,
|
|
|
root_task_tag = NULLTAG,
|
|
|
* attachments;;
|
|
|
task_tag = msg.task;
|
|
|
tag_t executor;
|
|
|
char* user_id;
|
|
|
char* user_uid;
|
|
|
EPM_ask_root_task(task_tag, &root_task_tag);
|
|
|
char* mail_url;
|
|
|
ITKCALL(PREF_ask_char_value("Autocode_SendEmailServer_URL", 0, &mail_url));
|
|
|
char* url;
|
|
|
ITKCALL(PREF_ask_char_value("HS_BOM_URL", 0, &url));
|
|
|
char* person_name;
|
|
|
ITKCALL(AOM_ask_value_tag(task_tag, "owning_user", &executor));
|
|
|
tag_t person_tag = NULLTAG;
|
|
|
char* mail_str = NULL;
|
|
|
ITKCALL(ifail = AOM_ask_value_tag(executor, "person", &person_tag));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(person_tag, "PA9", &mail_str));
|
|
|
ITKCALL(AOM_ask_value_string(executor, "user_id", &user_id));
|
|
|
SA_ask_user_person_name2(executor, &person_name);
|
|
|
POM_tag_to_uid(executor, &user_uid);
|
|
|
EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments);
|
|
|
vector<EPR_BOM> boms;
|
|
|
|
|
|
string str = "";
|
|
|
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t tagt = attachments[i];//
|
|
|
char* id = NULL;
|
|
|
char* item_rev = NULL;
|
|
|
char* uid = NULL;
|
|
|
if (checkIsTypeOrSubtype(tagt, "PSBOMViewRevision") != 1)
|
|
|
{
|
|
|
printf("类型不是PSBOMViewRevision\n");
|
|
|
continue;
|
|
|
}
|
|
|
//char* bom_name;
|
|
|
//ITKCALL(AOM_ask_value_string(tagt,"object_name",&bom_name));
|
|
|
//string bomName = bom_name;
|
|
|
//printf("bomName1=%s\n", bomName.c_str());
|
|
|
//if (strstr(bom_name,"/") != NULL) {
|
|
|
// bomName = replace_all(bomName, "/", "-");
|
|
|
//}
|
|
|
//printf("bomName2=%s\n", bomName.c_str());
|
|
|
printf("类型是PSBOMViewRevision,继续\n");
|
|
|
int c_line_count = 0;
|
|
|
tag_t bom_window_tag = NULLTAG,
|
|
|
top_line_tag = NULLTAG,
|
|
|
target_tag = NULLTAG,
|
|
|
* c_line_tags;
|
|
|
char* target_type;
|
|
|
char* object_string;
|
|
|
ITKCALL(ifail = AOM_ask_value_string(tagt, "object_string", &object_string));
|
|
|
if (strcmp(str.c_str(), "") == 0) {
|
|
|
str = object_string;
|
|
|
}
|
|
|
ITKCALL(BOM_create_window(&bom_window_tag));//创建window视图
|
|
|
ITKCALL(BOM_set_window_top_line_bvr(bom_window_tag, tagt, &top_line_tag));//获取顶层bomline
|
|
|
ITKCALL(AOM_ask_value_tag(top_line_tag, "bl_line_object", &target_tag));//获取BOMLINE关联的版本
|
|
|
|
|
|
|
|
|
ITKCALL(BOM_line_ask_all_child_lines(top_line_tag, &c_line_count, &c_line_tags));
|
|
|
if (c_line_count == 0) {
|
|
|
printf("没有BOM结构\n");
|
|
|
}
|
|
|
else {
|
|
|
boolean flag = false;
|
|
|
getchibomline_value(tagt, top_line_tag, boms, flag);
|
|
|
}
|
|
|
ITKCALL(BOM_close_window(bom_window_tag));
|
|
|
|
|
|
//system(cmd);
|
|
|
|
|
|
|
|
|
//AOM_lock(master_form);
|
|
|
//ITKCALL(AOM_set_value_string(master_form, "y4_ERPwlzt", "已传递"));
|
|
|
//AOM_save(master_form);
|
|
|
//AOM_unlock(master_form);
|
|
|
|
|
|
}
|
|
|
if (strstr(str.c_str(), "/") != NULL) {
|
|
|
str = replace_all(str, "/", "-");
|
|
|
}
|
|
|
if (boms.size() > 0) {
|
|
|
time_t t;
|
|
|
struct tm* lt;
|
|
|
time(&t);//获取Unix时间戳。
|
|
|
lt = localtime(&t);//转为时间结构。
|
|
|
char file_name[256] = "";
|
|
|
char cmd[1024] = "";
|
|
|
char* tc_root_dir = getenv("tc_root");
|
|
|
sprintf(file_name, "%s-%d%02d%02d%02d%02d%02d-BOM-%s", user_id, 1900 + lt->tm_year, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec, str.c_str());
|
|
|
|
|
|
char path[128] = "\0";
|
|
|
strcat(path, "D:\\Siemens\\PLMtoERPlogs");
|
|
|
strcat(path, "\\");
|
|
|
strcat(path, file_name);
|
|
|
strcat(path, ".txt");
|
|
|
FILE* fpWrite = fopen(path, "w");
|
|
|
for (int j = 0; j < boms.size(); j++)
|
|
|
{
|
|
|
vector<EPR_ZJ> zjs = boms[j].zjs;
|
|
|
char bom_value[8000] = "\0";
|
|
|
strcat(bom_value, (boms[j].cinvCode).c_str());
|
|
|
strcat(bom_value, ";");
|
|
|
strcat(bom_value, (boms[j].version).c_str());
|
|
|
strcat(bom_value, "|");
|
|
|
for (int k = 0; k < zjs.size(); k++)
|
|
|
{
|
|
|
if (strcmp("", (zjs[k].sortSeq).c_str()) == 0) {
|
|
|
strcat(bom_value, " ");
|
|
|
}
|
|
|
else {
|
|
|
strcat(bom_value, (zjs[k].sortSeq).c_str());
|
|
|
}
|
|
|
strcat(bom_value, ";");
|
|
|
if (strcmp("", (zjs[k].invCode).c_str()) == 0) {
|
|
|
strcat(bom_value, " ");
|
|
|
}
|
|
|
else {
|
|
|
strcat(bom_value, (zjs[k].invCode).c_str());
|
|
|
}
|
|
|
strcat(bom_value, ";");
|
|
|
if (strcmp("", (zjs[k].baseQtyN).c_str()) == 0 || strcmp(" ", (zjs[k].baseQtyN).c_str()) == 0) {
|
|
|
strcat(bom_value, "1");
|
|
|
}
|
|
|
else {
|
|
|
strcat(bom_value, (zjs[k].baseQtyN).c_str());
|
|
|
}
|
|
|
strcat(bom_value, ";");
|
|
|
if (strcmp("", (zjs[k].baseQtyD).c_str()) == 0 || strcmp(" ", (zjs[k].baseQtyD).c_str()) == 0) {
|
|
|
strcat(bom_value, "1");
|
|
|
}
|
|
|
else {
|
|
|
strcat(bom_value, (zjs[k].baseQtyD).c_str());
|
|
|
}
|
|
|
if (k < zjs.size() - 1) {
|
|
|
strcat(bom_value, "&");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
fprintf(fpWrite, "%s\n", bom_value);
|
|
|
}
|
|
|
fclose(fpWrite);
|
|
|
char* all_mail_sjr;
|
|
|
ITKCALL(PREF_ask_char_value("HS2_SendEmailServer_ALL_SJR", 0, &all_mail_sjr));
|
|
|
char mail_str_all[1024] = "\0";
|
|
|
strcpy(mail_str_all, all_mail_sjr);
|
|
|
if (strstr(mail_str_all, mail_str) == NULL) {
|
|
|
strcat(mail_str_all, ",");
|
|
|
strcat(mail_str_all, mail_str);
|
|
|
}
|
|
|
|
|
|
printf("mail_str_all=%s\n", mail_str_all);
|
|
|
strcpy(cmd, "java -jar ");
|
|
|
strcat(cmd, tc_root_dir);
|
|
|
strcat(cmd, "\\bin\\HSSendToERP.jar");
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, "BOM");
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, path);
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, person_name);
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, url);
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, mail_str_all);
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, mail_url);
|
|
|
printf("%s", cmd);
|
|
|
WinExec(cmd, SW_NORMAL);
|
|
|
}
|
|
|
|
|
|
|
|
|
printf("关超级权限\n");
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
printf("===================================\n");
|
|
|
printf("BOM传递erp 结束\n");
|
|
|
printf("===================================\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
//电子签名
|
|
|
int HS_pdf_signoff(EPM_action_message_t msg) {
|
|
|
int ifail = ITK_ok;
|
|
|
|
|
|
//流程节点相关
|
|
|
tag_t root_task = NULLTAG, * sub_tasks = NULL, current_task = NULLTAG, type_tag = NULLTAG;
|
|
|
int sub_task_count = 0;
|
|
|
char root_task_name[128] = "", task_name[128] = "";
|
|
|
int occur_of_counts = 0;
|
|
|
tag_t* taskAttches = NULLTAG;
|
|
|
char tgt_type[WSO_name_size_c + 1] = "", * type_class;
|
|
|
////循环内部变量
|
|
|
tag_t cur_task = NULLTAG;
|
|
|
//循环变量
|
|
|
int count = 0;
|
|
|
|
|
|
//节点循环处理变量
|
|
|
tag_t itemrevision = NULLTAG, master_form_rel_type = NULLTAG;
|
|
|
int form_count = 0;
|
|
|
tag_t* form_list = NULL, master_form = NULLTAG;
|
|
|
|
|
|
current_task = msg.task;
|
|
|
//CreateLogFile("PLA8_signoff",&txtfile);
|
|
|
ECHO("=========================================================\n");
|
|
|
ECHO("电子签名 开始执行\n");
|
|
|
ECHO("=========================================================\n");
|
|
|
//参数相关
|
|
|
int arg_cnt = 0;
|
|
|
char* argflag = NULL, * argvalue = NULL, * arg = NULL;
|
|
|
char TZ[16] = "";
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
ECHO("参数个数为:%d\n", arg_cnt);
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
if (arg_cnt > 0)
|
|
|
{
|
|
|
for (int i = 0; i < arg_cnt; i++)
|
|
|
{
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
|
|
|
if (stricmp(argflag, "type") == 0)
|
|
|
{
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(TZ, argvalue);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
if (argflag != NULL) {
|
|
|
MEM_free(argflag);
|
|
|
argflag = NULL;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
char* tz_uid;
|
|
|
char tz_path[512] = "";
|
|
|
//ITKCALL(PREF_ask_char_values("HS_UNIT_CODE", &value_count, &values));
|
|
|
char tzs[64] = "HS2_TZ_";
|
|
|
strcat(tzs, TZ);
|
|
|
ITKCALL(PREF_ask_char_value(tzs, 0, &tz_uid));
|
|
|
tag_t tz_target;
|
|
|
ITK__convert_uid_to_tag(tz_uid, &tz_target);
|
|
|
int target_count = 0;
|
|
|
tag_t* target_tags = NULL;
|
|
|
char* target_type;
|
|
|
ITKCALL(AOM_ask_value_tags(tz_target, "ref_list", &target_count, &target_tags));
|
|
|
ITKCALL(AOM_ask_value_string(target_tags[0], "file_ext", &target_type));
|
|
|
time_t now;
|
|
|
struct tm* p;
|
|
|
time(&now);
|
|
|
p = localtime(&now);
|
|
|
|
|
|
sprintf_s(tz_path, "%s\\TZ_[%d-%d-%d-%d-%02d-%02d].%s", getenv("TEMP"), 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec, target_type);
|
|
|
|
|
|
IMF_export_file(target_tags[0], tz_path);
|
|
|
//获取属性
|
|
|
EPM_ask_root_task(msg.task, &root_task);
|
|
|
EPM_ask_sub_tasks(root_task, &sub_task_count, &sub_tasks);
|
|
|
EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches);
|
|
|
ECHO("%d target attachment found", occur_of_counts);
|
|
|
|
|
|
for (count = 0; count < occur_of_counts; count++)
|
|
|
{
|
|
|
ITKCALL(TCTYPE_ask_object_type(taskAttches[count], &type_tag));
|
|
|
ITKCALL(ifail = TCTYPE_ask_class_name2(type_tag, &type_class));
|
|
|
|
|
|
//过滤掉非版本对象
|
|
|
if (((strstr(type_class, "Revision") != NULL) || (strstr(type_class, "revision") != NULL))
|
|
|
&& (strstr(type_class, "Master") == NULL) && (strstr(type_class, "master") == NULL)
|
|
|
&& (strstr(type_class, "BOM") == NULL) && (strstr(type_class, "bom") == NULL) && (strstr(type_class, "Bom") == NULL))
|
|
|
{
|
|
|
itemrevision = taskAttches[count];
|
|
|
ITKCALL(GRM_find_relation_type(TC_master_form_rtype, &master_form_rel_type));
|
|
|
ITKCALL(GRM_list_secondary_objects_only(itemrevision, master_form_rel_type, &form_count, &form_list));
|
|
|
//获得数据集
|
|
|
tag_t relation_type = NULLTAG;
|
|
|
//tag_t attach_relation_type = NULLTAG;
|
|
|
ITKCALL(GRM_find_relation_type(TC_specification_rtype, &relation_type));
|
|
|
tag_t* secondary_objects = NULLTAG;
|
|
|
int ds_count = 0;
|
|
|
char* dataset_type = NULL, * desc_value = NULL, * file_path = NULL, * desc_path;
|
|
|
|
|
|
ITKCALL(GRM_list_secondary_objects_only(itemrevision, relation_type, &ds_count, &secondary_objects));
|
|
|
|
|
|
for (int j = 0; j < ds_count; j++)
|
|
|
{
|
|
|
printf("进1\n");
|
|
|
ITKCALL(AOM_ask_value_string(secondary_objects[j], "object_type", &dataset_type));
|
|
|
int des_count = 0;
|
|
|
tag_t* dess = NULL;
|
|
|
|
|
|
printf("dataset_type=%s\n", dataset_type);
|
|
|
if (strcmp(dataset_type, "PDF") != 0) {
|
|
|
|
|
|
if (dataset_type != NULL) {
|
|
|
MEM_free(dataset_type);
|
|
|
dataset_type = NULL;
|
|
|
}
|
|
|
|
|
|
continue;
|
|
|
}
|
|
|
ITKCALL(AOM_ask_value_tags(secondary_objects[j], "ref_list", &des_count, &dess));
|
|
|
if (des_count < 1) {
|
|
|
printf("该数据集引用数量错误\n");
|
|
|
continue;
|
|
|
}
|
|
|
else {
|
|
|
char* sizeFile;
|
|
|
AOM_ask_value_string(dess[0], "file_size", &sizeFile);
|
|
|
printf("sizeFile %s \n", sizeFile);
|
|
|
if (strcmp(sizeFile, "0 bytes") == 0) {
|
|
|
printf("文件大小是0bytes\n");
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
tag_t spec_dataset_rev = NULLTAG,
|
|
|
ref_object = NULLTAG;
|
|
|
char* ref_object_name = NULL;
|
|
|
AE_reference_type_t reference_type;
|
|
|
char* datasetName = NULL;
|
|
|
char* pathname;
|
|
|
char* origin_file_name;
|
|
|
vector<string> type_vec;
|
|
|
printf("开始判断类型\n");
|
|
|
if (strcmp(dataset_type, "PDF") == 0) {
|
|
|
printf("pdf类型\n");
|
|
|
int values_count = 0;
|
|
|
char** values;
|
|
|
char* value;
|
|
|
ITKCALL(PREF_ask_char_values("HS_signoff_pdf_attr", &values_count, &values));
|
|
|
char signoffValue[1024] = "\0";
|
|
|
for (int i = 0; i < values_count; i++)
|
|
|
{
|
|
|
printf("values=%s\n", values[i]);
|
|
|
Split(values[i], "=", type_vec);
|
|
|
ITKCALL(AOM_ask_value_string(itemrevision, type_vec[1].c_str(), &value));
|
|
|
strcat(signoffValue, type_vec[0].c_str());
|
|
|
strcat(signoffValue, "=");
|
|
|
strcat(signoffValue, value);
|
|
|
strcat(signoffValue, "|");
|
|
|
MEM_free(value);
|
|
|
type_vec.clear();
|
|
|
}
|
|
|
MEM_free(values);
|
|
|
printf("signoffValue=%s\n", signoffValue);
|
|
|
char path[128] = "\0";
|
|
|
strcat(path, getenv("TEMP"));
|
|
|
strcat(path, "\\");
|
|
|
strcat(path, "PDFsignoff.txt");
|
|
|
FILE* fpWrite = fopen(path, "w");
|
|
|
fprintf(fpWrite, "%s", signoffValue);
|
|
|
fclose(fpWrite);
|
|
|
//MEM_free(fpWrite);
|
|
|
AOM_ask_value_string(secondary_objects[j], "object_name", &datasetName);
|
|
|
AE_ask_dataset_latest_rev(secondary_objects[j], &spec_dataset_rev);
|
|
|
AOM_ask_value_string(spec_dataset_rev, "object_name", &ref_object_name);
|
|
|
printf("ref_object_name=%s\n", ref_object_name);
|
|
|
char ref_name[WSO_name_size_c + 1] = "PDF_Reference";
|
|
|
|
|
|
AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object);
|
|
|
if (ref_object == NULLTAG)
|
|
|
{
|
|
|
printf("\nref_object is NULLTAG\n");
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
printf("reference_type=%d\n", reference_type);
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
ITKCALL(IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname));
|
|
|
IMF_ask_original_file_name2(ref_object, &origin_file_name);
|
|
|
char new_ds_name[WSO_name_size_c + 1] = "";
|
|
|
char* new_file_name = USER_new_file_name(new_ds_name, ref_name, "pdf", 0);
|
|
|
char* temp_dir = getenv("temp");
|
|
|
char temp_file[SS_MAXPATHLEN] = "";
|
|
|
char temp_file2[SS_MAXPATHLEN] = "";
|
|
|
|
|
|
strcpy(temp_file, temp_dir);
|
|
|
strcat(temp_file, "\\");
|
|
|
strcat(temp_file, new_file_name);
|
|
|
IMF_export_file(ref_object, temp_file);
|
|
|
/*if (strstr(temp_file, ".pdf") != NULL) {
|
|
|
sprintf(temp_file2, "%s\\1%s", temp_dir, new_file_name);
|
|
|
}
|
|
|
else {
|
|
|
sprintf(temp_file2, "%s\\1%s.pdf", temp_dir, new_file_name);
|
|
|
}*/
|
|
|
if (strstr(new_file_name, ".pdf") != NULL) {
|
|
|
sprintf(temp_file2, "%s\\1%s", temp_dir, new_file_name);
|
|
|
}
|
|
|
else {
|
|
|
sprintf(temp_file2, "%s\\1%s.pdf", temp_dir, new_file_name);
|
|
|
}
|
|
|
//sprintf(temp_file2, "%s.pdf", temp_file);
|
|
|
printf("\ntemp_file=%s\n", temp_file);
|
|
|
char cmd[256] = "";
|
|
|
char* tc_root_dir = getenv("tc_root");
|
|
|
strcpy(cmd, "java -jar ");
|
|
|
strcat(cmd, tc_root_dir);
|
|
|
strcat(cmd, "\\bin\\HS_PDFSignoff.jar");
|
|
|
strcat(cmd, " \"");
|
|
|
strcat(cmd, path);
|
|
|
strcat(cmd, "\" \"");
|
|
|
strcat(cmd, temp_file);
|
|
|
strcat(cmd, "\" \"");
|
|
|
strcat(cmd, temp_file2);
|
|
|
strcat(cmd, "\" \"");
|
|
|
strcat(cmd, tz_path);
|
|
|
strcat(cmd, "\"");
|
|
|
printf("\n%s\n", cmd);
|
|
|
system(cmd);
|
|
|
char txtPath[256] = "";
|
|
|
strcpy(txtPath, "DEL /f ");
|
|
|
strcat(txtPath, path);
|
|
|
system(txtPath);
|
|
|
tag_t new_file_tag = NULLTAG;
|
|
|
IMF_file_t file_descriptor;
|
|
|
if (temp_file2 != NULL) {
|
|
|
IMF_import_file(temp_file2, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
IMF_import_file(temp_file, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor);
|
|
|
}
|
|
|
|
|
|
//IMF_import_file(temp_file2, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor);
|
|
|
IMF_set_original_file_name2(new_file_tag, origin_file_name);
|
|
|
IMF_close_file(file_descriptor);
|
|
|
AOM_save(new_file_tag);
|
|
|
AOM_unlock(new_file_tag);
|
|
|
|
|
|
AOM_lock(spec_dataset_rev);
|
|
|
|
|
|
AE_remove_dataset_named_ref_by_tag2(spec_dataset_rev, ref_name, ref_object);
|
|
|
|
|
|
AE_add_dataset_named_ref2(spec_dataset_rev, ref_name, AE_PART_OF, new_file_tag);
|
|
|
AOM_save(spec_dataset_rev);
|
|
|
AOM_unlock(spec_dataset_rev);
|
|
|
char tempPath[256] = "";
|
|
|
char tempPath2[256] = "";
|
|
|
char tempPath3[256] = "";
|
|
|
strcpy(tempPath, "DEL /f ");
|
|
|
strcat(tempPath, temp_file);
|
|
|
system(tempPath);
|
|
|
strcpy(tempPath2, "DEL /f ");
|
|
|
strcat(tempPath2, temp_file2);
|
|
|
system(tempPath2);
|
|
|
/*strcpy(tempPath3, "DEL /f ");
|
|
|
strcat(tempPath3, tz_path);
|
|
|
system(tempPath3);*/
|
|
|
//ITKCALL(ifail = import_dataset_file(secondary_objects[j], "T2_DWG", "dwg", temp_file, datasetName));
|
|
|
}
|
|
|
}
|
|
|
MEM_free(dataset_type);
|
|
|
|
|
|
}
|
|
|
|
|
|
DOFREE(secondary_objects);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
DOFREE(taskAttches);
|
|
|
ECHO("=========================================================\n");
|
|
|
ECHO("电子签名 结束\n");
|
|
|
ECHO("=========================================================\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
/**
|
|
|
* 设置流程名称
|
|
|
*/
|
|
|
int HS2_set_process_name(EPM_action_message_t msg) {
|
|
|
|
|
|
printf("===================================\n");
|
|
|
printf("设置流程名称 开始\n");
|
|
|
printf("===================================\n");
|
|
|
printf("开超级权限\n");
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
int ifail = ITK_ok;
|
|
|
tag_t tast_tag = NULL_TAG, job;
|
|
|
tag_t aUserTag = NULLTAG;//当前用户对象
|
|
|
char* userName;
|
|
|
printf("获取用户\n");
|
|
|
int s = POM_get_user(&userName, &aUserTag);
|
|
|
tast_tag = msg.task;
|
|
|
tag_t root_task_tag = NULLTAG;
|
|
|
int att_cnt = 0;
|
|
|
EPM_ask_root_task(tast_tag, &root_task_tag);
|
|
|
|
|
|
if (tast_tag != NULL_TAG) {
|
|
|
char finish_date_str[300] = "";
|
|
|
char* job_name = NULL;
|
|
|
char* job_name1 = NULL;
|
|
|
AOM_ask_value_string(root_task_tag, "job_name", &job_name);
|
|
|
AOM_ask_value_string(tast_tag, "job_name", &job_name1);
|
|
|
printf("job_name=%s\n", job_name);
|
|
|
printf("job_name1=%s\n", job_name1);
|
|
|
tag_t schedule_tag;
|
|
|
tag_t* task_tag;
|
|
|
int task_num = 0;
|
|
|
char* proj_name;
|
|
|
char file_name[56] = "\0";
|
|
|
bool setJFW = false;
|
|
|
ITKCALL(AOM_ask_value_tags(root_task_tag, "fnd0RootScheduleTask", &task_num, &task_tag));
|
|
|
if (task_tag[0] != NULL_TAG) {
|
|
|
ITKCALL(AOM_ask_value_tag(task_tag[0], "schedule_tag", &schedule_tag));
|
|
|
if (schedule_tag != NULL_TAG) {
|
|
|
tag_t* projects;
|
|
|
int proj_num = 0;
|
|
|
ITKCALL(AOM_ask_value_tags(schedule_tag, "project_list", &proj_num, &projects));
|
|
|
if (proj_num > 0) {
|
|
|
ITKCALL(AOM_ask_value_string(projects[0], "object_name", &proj_name));
|
|
|
printf("proj_name=%s\n", proj_name);
|
|
|
}
|
|
|
|
|
|
int c_sql_value_count = 0;
|
|
|
char** c_sql_values;
|
|
|
ITKCALL(PREF_ask_char_values("HS2_SQL_Connect2", &c_sql_value_count, &c_sql_values));
|
|
|
if (c_sql_value_count != 3)
|
|
|
{
|
|
|
printf("首选项 DFL2_SQL_Connect2 配置错误 数量%d \n ", c_sql_value_count);
|
|
|
}
|
|
|
else {
|
|
|
if (ConnServer(c_sql_values[1], c_sql_values[2], c_sql_values[0]))//"tc11","infodba","//172.16.50.40/tc11" "TC12","infodba","172.16.68.13/tc1"
|
|
|
{
|
|
|
printf("提示:中间数据表访问失败\n");
|
|
|
}
|
|
|
else {
|
|
|
printf("提示:中间数据表访问成功\n");
|
|
|
char sql[1024] = "\0";
|
|
|
sprintf(sql, "select FILENAME from AHMC_TASK_CHECK where TASKNAME= '%s'", job_name);
|
|
|
printf("提示:sql==%s\n", sql);
|
|
|
int outputColumn = 0, outputValueCount = 0;
|
|
|
char*** outputValue = NULL;
|
|
|
if (QuerySQLNoInputParam(sql, &outputColumn, &outputValueCount, &outputValue) == -1)
|
|
|
{
|
|
|
printf("提示:获取交付物名称 失败, %s \n", sql);
|
|
|
}
|
|
|
else {
|
|
|
printf("outputValueCount=%d\n", outputValueCount);
|
|
|
//
|
|
|
if (outputValueCount > 0) {
|
|
|
printf("outputValue=%s\n", outputValue[0][0]);
|
|
|
setJFW = true;
|
|
|
strcpy(file_name, outputValue[0][0]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
EPM_ask_job(tast_tag, &job);
|
|
|
//AOM_ask_value_string(job, "object_name", &job_name);
|
|
|
if (setJFW) {
|
|
|
sprintf(finish_date_str, "%s-%s(%s)", proj_name, job_name, file_name);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sprintf(finish_date_str, "%s-%s", proj_name, job_name);
|
|
|
}
|
|
|
|
|
|
printf("finish_date_str=%s\n", finish_date_str);
|
|
|
AOM_lock(job);
|
|
|
AOM_set_value_string(job, "object_name", finish_date_str);
|
|
|
AOM_save(job);
|
|
|
AOM_unlock(job);
|
|
|
if (job_name != NULL) {
|
|
|
MEM_free(job_name);
|
|
|
job_name = NULL;
|
|
|
}
|
|
|
if (userName != NULL) {
|
|
|
MEM_free(userName);
|
|
|
userName = NULL;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
printf("关超级权限\n");
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
printf("===================================\n");
|
|
|
printf("设置流程名称 结束\n");
|
|
|
printf("===================================\n");
|
|
|
|
|
|
return ifail;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//流程邮件提醒
|
|
|
int Connor_Send_Mail_To_All_Users(EPM_action_message_t msg) {
|
|
|
bool debug = false;
|
|
|
int ifail = ITK_ok, arg_cnt = 0, att_cnt = 0, task_count = 0, user_cnt = 0;
|
|
|
char* arg = NULL, * argflag = NULL, * argvalue = NULL, * task_name = NULL, * task_type = NULL;
|
|
|
char* user_id = NULL, * user_name = NULL, * job_name = NULL, * userName = NULL;
|
|
|
tag_t task_tag = NULLTAG, rootTask_tag = NULLTAG, user_tag = NULLTAG, * taskAttches;
|
|
|
tag_t* attachments = NULL, * task_tags = NULL, ownUser, root_task_tag;
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
vector<tag_t> all_user_tags;
|
|
|
vector<string> mail_addrs;
|
|
|
tag_t memberTag = NULLTAG;
|
|
|
SIGNOFF_TYPE_t memberType;
|
|
|
ITKCALL(POM_get_user(&user_name, &user_tag));
|
|
|
ITKCALL(SA_ask_user_identifier2(user_tag, &user_id));
|
|
|
DOFREE(user_id);
|
|
|
char* url;
|
|
|
ITKCALL(PREF_ask_char_value("Autocode_SendEmailServer_URL", 0, &url));
|
|
|
printf("=============================================================\n");
|
|
|
printf("开始执行:Connor_Send_Mail_To_All_Users\n");
|
|
|
printf("=============================================================\n");
|
|
|
printf("开超级权限\n");
|
|
|
string types;
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
task_tag = msg.task;
|
|
|
if (arg_cnt > 0)
|
|
|
{
|
|
|
for (int i = 0; i < arg_cnt; i++) {
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
ITKCALL(ifail = ITK_ask_argument_named_value(arg, &argflag, &argvalue));
|
|
|
if (strcmp(argflag, "status") == 0) {
|
|
|
types.assign(argvalue);
|
|
|
}
|
|
|
MEM_free(argflag);
|
|
|
MEM_free(argvalue);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
char* task_uid;
|
|
|
POM_tag_to_uid(task_tag, &task_uid);
|
|
|
time_t t;
|
|
|
struct tm* lt;
|
|
|
time(&t);//获取Unix时间戳。
|
|
|
lt = localtime(&t);//转为时间结构。
|
|
|
char year[128] = "\0"; //当前年份
|
|
|
sprintf(year, "%d-%d-%d", lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday);
|
|
|
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(rootTask_tag, "job_name", &job_name));
|
|
|
printf("流程名称:%s\n", job_name);
|
|
|
ITKCALL(ifail = EPM_ask_name2(task_tag, &task_name));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(task_tag, "task_type", &task_type));
|
|
|
//ITKCALL(ifail = AOM_ask_value_string(task_tag, "task_type", &task_type));
|
|
|
AOM_ask_value_tag(task_tag, "owning_user", &ownUser);
|
|
|
AOM_ask_value_string(ownUser, "user_name", &userName);
|
|
|
if (ifail != ITK_ok) {
|
|
|
DOFREE(task_name);
|
|
|
DOFREE(task_type);
|
|
|
}
|
|
|
ECHO("task_type = %s\n", task_type);
|
|
|
int occur_of_counts;
|
|
|
string projectName;
|
|
|
string objectType;
|
|
|
EPM_ask_root_task(task_tag, &root_task_tag);
|
|
|
//EPM_ask_name2(root_task_tag);
|
|
|
ITKCALL(ifail = EPM_ask_attachments(root_task_tag, EPM_target_attachment, &occur_of_counts, &taskAttches));
|
|
|
char* type_class;
|
|
|
for (int t = 0; t < occur_of_counts; t++) {
|
|
|
tag_t item;
|
|
|
if (checkIsTypeOrSubtype(taskAttches[t], "ItemRevision")) {
|
|
|
char* typeObj;
|
|
|
ITEM_ask_item_of_rev(taskAttches[t], &item);
|
|
|
|
|
|
//if (checkIsTypeOrSubtype(item, "HS2_Document")) {
|
|
|
printf("是文档类型,获取项目名称");
|
|
|
char* valueName;
|
|
|
AOM_ask_value_string(taskAttches[t], "projects_list", &valueName);
|
|
|
|
|
|
if (strcmp(valueName, "") == 0 || strcmp(valueName, " ")) {
|
|
|
projectName.assign(valueName);
|
|
|
projectName = replace_all(projectName, " ", "###");
|
|
|
projectName = replace_all(projectName, "&", "--");
|
|
|
//replace(projectName.begin(), projectName.end(), ' ', '##');
|
|
|
}
|
|
|
//}
|
|
|
|
|
|
AOM_UIF_ask_value(item, "object_type", &typeObj);
|
|
|
objectType = typeObj;
|
|
|
|
|
|
}
|
|
|
//ITKCALL(WSOM_ask_object_type2(taskAttches[t], &type_class));
|
|
|
}
|
|
|
if (strcmp("EPMAcknowledgeTask", task_type) == 0) {
|
|
|
int subcount;
|
|
|
tag_t* subTags;
|
|
|
EPM_ask_sub_tasks(task_tag, &subcount, &subTags);
|
|
|
|
|
|
for (int j = 0; j < subcount; j++) {
|
|
|
char* subType, * taskname;
|
|
|
tag_t subTag = subTags[j];
|
|
|
ITKCALL(AOM_ask_value_string(subTag, "object_type", &subType));
|
|
|
if (strcmp(subType, "EPMPerformSignoffTask") == 0) {
|
|
|
ITKCALL(EPM_ask_name2(subTag, &taskname));
|
|
|
printf("获取到了认可下的 审核节点 name ==%s \n", taskname);
|
|
|
|
|
|
int reviewer_cnt = 0;
|
|
|
tag_t* reviewers = NULL;
|
|
|
int count = 0;
|
|
|
tag_t* be_tag = NULLTAG;
|
|
|
char* node_task_name;
|
|
|
int* attach_type;
|
|
|
ITKCALL(AOM_ask_value_tags(subTag, "predecessors", &count, &be_tag));
|
|
|
printf("目标数量:%d\n", count);
|
|
|
for (int j = 0; j < count; j++)
|
|
|
{
|
|
|
EPM_ask_name2(be_tag[j], &node_task_name);
|
|
|
ECHO("node_task_name = %s\n", node_task_name);
|
|
|
if (stricmp(node_task_name, "select-signoff-team") == 0) {
|
|
|
EPM_ask_all_attachments(be_tag[j], &reviewer_cnt, &reviewers, &attach_type);
|
|
|
ECHO("perform_count=%d\n", reviewer_cnt);
|
|
|
for (int k = 0; k < reviewer_cnt; k++) {
|
|
|
tag_t reviewer = reviewers[k];
|
|
|
tag_t user_tag = NULLTAG;
|
|
|
tag_t group_tag = NULLTAG;
|
|
|
EPM_signoff_decision_t decision;
|
|
|
char* comment = NULL, * date_str = NULL, * group_full_name = NULL, * user_name = NULL;
|
|
|
date_t date;
|
|
|
ITKCALL(EPM_ask_signoff_member(reviewer, &memberTag, &memberType));
|
|
|
ITKCALL(SA_ask_groupmember_user(memberTag, &user_tag));
|
|
|
if (user_tag == NULLTAG) {
|
|
|
printf(">> %d. 未指派用户\n", k + 1);
|
|
|
continue;
|
|
|
}
|
|
|
//ITKCALL(ifail = AOM_ask_value_tag(reviewer, "group", &group_tag));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(user_tag, "user_name", &user_name));
|
|
|
//ITKCALL(ifail = AOM_ask_value_string(group_tag, "full_name", &group_full_name));
|
|
|
all_user_tags.push_back(user_tag);
|
|
|
DOFREE(comment);
|
|
|
DOFREE(user_name);
|
|
|
DOFREE(group_full_name);
|
|
|
DOFREE(date_str);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (strcmp("EPMDoTask", task_type) == 0) {
|
|
|
tag_t user_tag = NULLTAG;
|
|
|
ITKCALL(ifail = AOM_ask_value_tag(task_tag, "fnd0Performer", &user_tag));
|
|
|
if (user_tag == NULLTAG) {
|
|
|
printf("未找到执行者\n");
|
|
|
}
|
|
|
char* user_name = NULL, * task_state = NULL;
|
|
|
ITKCALL(ifail = AOM_ask_value_string(user_tag, "user_name", &user_name));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(task_tag, "task_state", &task_state));
|
|
|
printf(">> DO任务信息:%s|%s\n", user_name, task_state);
|
|
|
all_user_tags.push_back(user_tag);
|
|
|
DOFREE(user_name);
|
|
|
DOFREE(task_state);
|
|
|
}
|
|
|
else if (strcmp("EPMPerformSignoffTask", task_type) == 0) {
|
|
|
int reviewer_cnt = 0;
|
|
|
tag_t* reviewers = NULL;
|
|
|
int count = 0;
|
|
|
tag_t* be_tag = NULLTAG;
|
|
|
char* node_task_name;
|
|
|
int* attach_type;
|
|
|
ITKCALL(AOM_ask_value_tags(task_tag, "predecessors", &count, &be_tag));
|
|
|
printf("目标数量:%d\n", count);
|
|
|
for (int j = 0; j < count; j++)
|
|
|
{
|
|
|
EPM_ask_name2(be_tag[j], &node_task_name);
|
|
|
ECHO("node_task_name = %s\n", node_task_name);
|
|
|
if (stricmp(node_task_name, "select-signoff-team") == 0) {
|
|
|
EPM_ask_all_attachments(be_tag[j], &reviewer_cnt, &reviewers, &attach_type);
|
|
|
ECHO("perform_count=%d\n", reviewer_cnt);
|
|
|
for (int k = 0; k < reviewer_cnt; k++) {
|
|
|
tag_t reviewer = reviewers[k];
|
|
|
tag_t user_tag = NULLTAG;
|
|
|
tag_t group_tag = NULLTAG;
|
|
|
EPM_signoff_decision_t decision;
|
|
|
char* comment = NULL, * date_str = NULL, * group_full_name = NULL, * user_name = NULL;
|
|
|
date_t date;
|
|
|
ITKCALL(EPM_ask_signoff_member(reviewer, &memberTag, &memberType));
|
|
|
ITKCALL(SA_ask_groupmember_user(memberTag, &user_tag));
|
|
|
if (user_tag == NULLTAG) {
|
|
|
printf(">> %d. 未指派用户\n", k + 1);
|
|
|
continue;
|
|
|
}
|
|
|
//ITKCALL(ifail = AOM_ask_value_tag(reviewer, "group", &group_tag));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(user_tag, "user_name", &user_name));
|
|
|
//ITKCALL(ifail = AOM_ask_value_string(group_tag, "full_name", &group_full_name));
|
|
|
all_user_tags.push_back(user_tag);
|
|
|
DOFREE(comment);
|
|
|
DOFREE(user_name);
|
|
|
DOFREE(group_full_name);
|
|
|
DOFREE(date_str);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
DOFREE(reviewers);
|
|
|
}
|
|
|
else {
|
|
|
printf(">> 未知任务类型\n");
|
|
|
}
|
|
|
DOFREE(task_name);
|
|
|
/*DOFREE(task_type);*/
|
|
|
user_cnt = all_user_tags.size();
|
|
|
printf("处理用户数据:%d\n", user_cnt);
|
|
|
for (int i = 0; i < user_cnt; i++) {
|
|
|
tag_t mail_user = all_user_tags[i], person_tag = NULLTAG;
|
|
|
char* user_str = NULL, * mail_str = NULL;
|
|
|
ITKCALL(ifail = AOM_ask_value_tag(mail_user, "person", &person_tag));
|
|
|
if (ifail != ITK_ok || person_tag == NULLTAG) {
|
|
|
continue;
|
|
|
}
|
|
|
ITKCALL(ifail = AOM_ask_value_string(person_tag, "PA9", &mail_str));
|
|
|
if (ifail != ITK_ok) {
|
|
|
continue;
|
|
|
}
|
|
|
ITKCALL(ifail = AOM_ask_value_string(mail_user, "user_name", &user_str));
|
|
|
printf(">> %d. %s -> %s\n", i + 1, user_str, mail_str);
|
|
|
if (mail_str == NULL || strcmp("", mail_str) == 0 || std::find(mail_addrs.begin(), mail_addrs.end(), mail_str) != mail_addrs.end()) {
|
|
|
printf(">> Skip\n");
|
|
|
}
|
|
|
else {
|
|
|
mail_addrs.push_back(mail_str);
|
|
|
}
|
|
|
DOFREE(user_str);
|
|
|
DOFREE(mail_str);
|
|
|
}
|
|
|
user_cnt = mail_addrs.size();
|
|
|
|
|
|
|
|
|
printf("发送邮件:%d", user_cnt);
|
|
|
char user_mail[2048] = "\0";
|
|
|
for (int i = 0; i < user_cnt; i++) {
|
|
|
string mail_addr = mail_addrs[i];
|
|
|
WriteLog(">> %d. 发送邮件给[%s]", i + 1, mail_addr.c_str());
|
|
|
strcat(user_mail, mail_addr.c_str());
|
|
|
if (i < user_cnt - 1) {
|
|
|
strcat(user_mail, ",");
|
|
|
}
|
|
|
}
|
|
|
char cmd[1024] = "";
|
|
|
char jarfile[512] = "";
|
|
|
sprintf(jarfile, "%s\\bin\\SendToEmail.jar", getenv("TC_ROOT"));
|
|
|
string job_names;
|
|
|
job_names.assign(job_name);
|
|
|
job_names = replace_all(job_names, " ", "###");
|
|
|
job_names = replace_all(job_names, "&", "--");
|
|
|
if (types.empty()) {
|
|
|
strcpy_s(cmd, "java -jar ");
|
|
|
strcat_s(cmd, jarfile);
|
|
|
strcat_s(cmd, " 【TeamCenter】-");
|
|
|
strcat_s(cmd, job_names.c_str());
|
|
|
strcat_s(cmd, " ");
|
|
|
strcat_s(cmd, user_mail);
|
|
|
strcat_s(cmd, " 收到用户");
|
|
|
if (userName != NULL) {
|
|
|
strcat_s(cmd, userName);
|
|
|
strcat_s(cmd, "发起的");
|
|
|
}
|
|
|
if (!projectName.empty()) {
|
|
|
strcat_s(cmd, "项目名称-");
|
|
|
strcat_s(cmd, projectName.c_str());
|
|
|
strcat_s(cmd, "-");
|
|
|
}
|
|
|
else if (projectName.empty())
|
|
|
{
|
|
|
strcat_s(cmd, "项目名称(无项目)");
|
|
|
}
|
|
|
strcat_s(cmd, job_names.c_str());
|
|
|
strcat_s(cmd, "(");
|
|
|
objectType = replace_all(objectType, " ", "###");
|
|
|
objectType = replace_all(objectType, "&", "--");
|
|
|
strcat_s(cmd, objectType.c_str());
|
|
|
strcat_s(cmd, ")");
|
|
|
|
|
|
strcat_s(cmd, "任务,请尽快登录Teamcenter,在我的工作列表中执行此任务。");
|
|
|
strcat_s(cmd, " ");
|
|
|
strcat_s(cmd, url);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strcpy_s(cmd, "java -jar ");
|
|
|
strcat_s(cmd, jarfile);
|
|
|
strcat_s(cmd, " 【TeamCenter】-");
|
|
|
strcat_s(cmd, job_names.c_str());
|
|
|
strcat_s(cmd, " ");
|
|
|
strcat_s(cmd, user_mail);
|
|
|
strcat_s(cmd, " ");
|
|
|
if (userName != NULL) {
|
|
|
strcat_s(cmd, userName);
|
|
|
strcat_s(cmd, "发起的");
|
|
|
}
|
|
|
if (!projectName.empty()) {
|
|
|
strcat_s(cmd, "项目名称-");
|
|
|
strcat_s(cmd, projectName.c_str());
|
|
|
}
|
|
|
else if (projectName.empty())
|
|
|
{
|
|
|
strcat_s(cmd, "项目名称(无项目)-");
|
|
|
}
|
|
|
strcat_s(cmd, job_names.c_str());
|
|
|
strcat_s(cmd, "(");
|
|
|
objectType = replace_all(objectType, " ", "###");
|
|
|
objectType = replace_all(objectType, "&", "--");
|
|
|
strcat_s(cmd, objectType.c_str());
|
|
|
strcat_s(cmd, ")");
|
|
|
strcat_s(cmd, "工作流程已经审批完成,请注意查看,无需执行任何审批操作");
|
|
|
strcat_s(cmd, " ");
|
|
|
strcat_s(cmd, url);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
printf("CMD:%s", cmd);
|
|
|
WinExec(cmd, SW_NORMAL);
|
|
|
|
|
|
//system(cmd);
|
|
|
printf("执行完成");
|
|
|
printf("关超级权限\n");
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
end:
|
|
|
DOFREE(job_name);
|
|
|
DOFREE(attachments);
|
|
|
all_user_tags.clear();
|
|
|
printf("=============================================================\n");
|
|
|
printf("执行结束:Connor_Send_Mail_To_All_Users\n");
|
|
|
printf("=============================================================\n");
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
|
|
|
int HS_set_signoff(EPM_action_message_t msg) {
|
|
|
|
|
|
printf("===================================\n");
|
|
|
printf("word/excel文档签名 开始\n");
|
|
|
printf("===================================\n");
|
|
|
|
|
|
int ifail = ITK_ok;
|
|
|
int att_cnt = 0, jpg_count = 0;
|
|
|
tag_t task_tag = NULLTAG,
|
|
|
root_task_tag = NULLTAG,
|
|
|
* attachments = NULL;
|
|
|
//节点循环处理变量
|
|
|
char* argflag = NULL, * argvalue = NULL, * arg = NULL;
|
|
|
int arg_cnt = 0;
|
|
|
char sign_attr[2048] = "";
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
ECHO("参数个数为:%d\n", arg_cnt);
|
|
|
|
|
|
if (arg_cnt > 0)
|
|
|
{
|
|
|
for (int i = 0; i < arg_cnt; i++)
|
|
|
{
|
|
|
//获取下一个参数(从0开始)
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
//获取参数的名称和值
|
|
|
ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
|
|
|
if (strcmp(argflag, "sign") == 0)
|
|
|
{
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(sign_attr, argvalue);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
MEM_free(argflag);
|
|
|
MEM_free(argvalue);
|
|
|
}
|
|
|
tag_t itemrevision = NULLTAG;
|
|
|
printf("开超级权限\n");
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
|
|
|
task_tag = msg.task;
|
|
|
char* taskName;
|
|
|
EPM_ask_root_task(task_tag, &root_task_tag);
|
|
|
AOM_ask_value_string(root_task_tag, "job_name", &taskName);
|
|
|
//EPM_ask_name2(root_task_tag, &taskName);
|
|
|
EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments);
|
|
|
|
|
|
if (att_cnt > 0) {
|
|
|
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
int doc_num = 0;
|
|
|
tag_t* doc_tags = NULL;
|
|
|
tag_t* dataFile = NULL;
|
|
|
int fileNum = 0;
|
|
|
char* tag_type;
|
|
|
char* type;
|
|
|
ITKCALL(AOM_ask_value_string(attachments[i], "object_type", &tag_type));
|
|
|
printf("tag_type=%s\n", tag_type);
|
|
|
if (strstr(tag_type, "Revision") != NULL && strstr(tag_type, "Master") == NULL)
|
|
|
{
|
|
|
itemrevision = attachments[i];
|
|
|
/* int values_count = 0;
|
|
|
char** values;
|
|
|
char* value;
|
|
|
ITKCALL(PREF_ask_char_values("HS2_signoff_attr", &values_count, &values));*/
|
|
|
vector<string> sign_vec;
|
|
|
Split(sign_attr, ";", sign_vec);
|
|
|
char signoffValue[1024] = "\0";
|
|
|
vector<string> type_vec;
|
|
|
char* value;
|
|
|
for (int i = 0; i < sign_vec.size(); i++)
|
|
|
{
|
|
|
printf("values=%s\n", sign_vec[i].c_str());
|
|
|
Split(sign_vec[i].c_str(), "=", type_vec);
|
|
|
ITKCALL(AOM_ask_value_string(itemrevision, type_vec[1].c_str(), &value));
|
|
|
strcat(signoffValue, type_vec[0].c_str());
|
|
|
strcat(signoffValue, "=");
|
|
|
strcat(signoffValue, value);
|
|
|
strcat(signoffValue, "|");
|
|
|
MEM_free(value);
|
|
|
type_vec.clear();
|
|
|
}
|
|
|
//MEM_free(values);
|
|
|
printf("signoffValue=%s\n", signoffValue);
|
|
|
char path[128] = "\0";
|
|
|
strcat(path, getenv("TEMP"));
|
|
|
strcat(path, "\\");
|
|
|
strcat(path, "signoff.txt");
|
|
|
FILE* fpWrite = fopen(path, "w");
|
|
|
fprintf(fpWrite, "%s", signoffValue);
|
|
|
fclose(fpWrite);
|
|
|
ITKCALL(AOM_ask_value_tags(itemrevision, "IMAN_specification", &doc_num, &doc_tags));
|
|
|
if (doc_num > 0)
|
|
|
{
|
|
|
for (int i = 0; i < doc_num; i++)
|
|
|
{
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &type));
|
|
|
printf("type=%s\n", type);
|
|
|
tag_t spec_dataset_rev = NULLTAG, ref_object = NULLTAG;
|
|
|
AE_reference_type_t reference_type;
|
|
|
AE_ask_dataset_latest_rev(doc_tags[i], &spec_dataset_rev);
|
|
|
char* new_file_name = NULL;
|
|
|
char* origin_file_name;
|
|
|
char* pathname;
|
|
|
char ref_name[WSO_name_size_c + 1] = "";
|
|
|
char cmd[256] = "";
|
|
|
boolean flag = false;
|
|
|
if (strcmp(type, "MSWordX") == 0) {
|
|
|
//ITKCALL(AOM_ask_value_tags(doc_tags[i],"ref_list",&fileNum,&dataFile));
|
|
|
strcpy(cmd, "SubstMacros-MSWord.wsf");
|
|
|
strcpy(ref_name, "word");
|
|
|
AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object);
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
char new_ds_name[WSO_name_size_c + 1] = "";
|
|
|
new_file_name = USER_new_file_name(new_ds_name, ref_name, "docx", 0);
|
|
|
flag = true;
|
|
|
}
|
|
|
}
|
|
|
else if (strcmp(type, "MSWord") == 0) {
|
|
|
//ITKCALL(AOM_ask_value_tags(doc_tags[i],"ref_list",&fileNum,&dataFile));
|
|
|
strcpy(cmd, "SubstMacros-MSWord.wsf");
|
|
|
strcpy(ref_name, "word");
|
|
|
AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object);
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
char new_ds_name[WSO_name_size_c + 1] = "";
|
|
|
new_file_name = USER_new_file_name(new_ds_name, ref_name, "doc", 0);
|
|
|
flag = true;
|
|
|
}
|
|
|
}
|
|
|
else if (strcmp(type, "MSExcelX") == 0)
|
|
|
{
|
|
|
//ITKCALL(AOM_ask_value_tags(doc_tags[i],"ref_list",&fileNum,&dataFile));
|
|
|
strcpy(cmd, "SubstMacros-MSExcel.wsf");
|
|
|
strcpy(ref_name, "excel");
|
|
|
AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object);
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
char new_ds_name[WSO_name_size_c + 1] = "";
|
|
|
new_file_name = USER_new_file_name(new_ds_name, ref_name, "xlsx", 0);
|
|
|
flag = true;
|
|
|
}
|
|
|
}
|
|
|
else if (strcmp(type, "MSExcel") == 0)
|
|
|
{
|
|
|
//ITKCALL(AOM_ask_value_tags(doc_tags[i],"ref_list",&fileNum,&dataFile));
|
|
|
strcpy(cmd, "SubstMacros-MSExcel.wsf");
|
|
|
strcpy(ref_name, "excel");
|
|
|
AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object);
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
char new_ds_name[WSO_name_size_c + 1] = "";
|
|
|
new_file_name = USER_new_file_name(new_ds_name, ref_name, "xls", 0);
|
|
|
flag = true;
|
|
|
}
|
|
|
}
|
|
|
if (ref_object == NULLTAG || !flag) {
|
|
|
continue;
|
|
|
}
|
|
|
ITKCALL(IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname));
|
|
|
IMF_ask_original_file_name2(ref_object, &origin_file_name);
|
|
|
char* temp_dir = getenv("temp");
|
|
|
char temp_file[SS_MAXPATHLEN] = "";
|
|
|
char temp_file1[SS_MAXPATHLEN] = "";
|
|
|
char temp_file2[SS_MAXPATHLEN] = "";
|
|
|
char time1[256] = "\0";
|
|
|
char file_path[128] = "\0";
|
|
|
time_t t = time(0);
|
|
|
tm* local = localtime(&t);
|
|
|
sprintf(time1, "%d%d%d%d%d%d", local->tm_year, local->tm_mon, local->tm_mday, local->tm_hour, local->tm_min, local->tm_sec);
|
|
|
strcpy(temp_file, temp_dir);
|
|
|
string folderPath = "";
|
|
|
folderPath.append("D:\\Siemens\\Officesignofflogs\\");
|
|
|
string task_name = taskName;
|
|
|
|
|
|
cout << folderPath << endl;
|
|
|
if (strstr(task_name.c_str(), "/") != NULL) {
|
|
|
task_name = replace_all(task_name, "/", " ");
|
|
|
}
|
|
|
if (strstr(task_name.c_str(), "\\") != NULL) {
|
|
|
task_name = replace_all(task_name, "\\", " ");
|
|
|
}
|
|
|
folderPath.append(task_name);
|
|
|
folderPath.append("-");
|
|
|
folderPath.append(time1);
|
|
|
cout << folderPath << endl;
|
|
|
if (0 != access(folderPath.c_str(), 0))
|
|
|
{
|
|
|
// if this folder not exist, create a new one.
|
|
|
ITKCALL(mkdir(folderPath.c_str())); // 返回 0 表示创建成功,-1 表示失败
|
|
|
//换成 ::_mkdir ::_access 也行,不知道什么意思
|
|
|
}
|
|
|
strcat(temp_file, "\\");
|
|
|
strcat(temp_file, new_file_name);
|
|
|
IMF_export_file(ref_object, temp_file);
|
|
|
strcpy(temp_file1, folderPath.c_str());
|
|
|
strcat(temp_file1, "\\");
|
|
|
strcat(temp_file1, "签字前文件 ");
|
|
|
strcat(temp_file1, new_file_name);
|
|
|
|
|
|
strcpy(temp_file2, folderPath.c_str());
|
|
|
strcat(temp_file2, "\\");
|
|
|
strcat(temp_file2, "签字后文件 ");
|
|
|
strcat(temp_file2, new_file_name);
|
|
|
|
|
|
cout << "Copy file" << endl;
|
|
|
string from = temp_file, to = temp_file1, to2 = temp_file2;
|
|
|
ifstream in(from, ios::in | ios::binary);
|
|
|
if (!in)
|
|
|
{
|
|
|
cout << "could not find file" << from << endl;
|
|
|
return 1;
|
|
|
}
|
|
|
ofstream out(to, ios::out | ios::binary);
|
|
|
char ch;
|
|
|
while (in.get(ch))
|
|
|
{
|
|
|
out.put(ch);
|
|
|
}
|
|
|
cout << "file has been copied" << endl;
|
|
|
in.close();
|
|
|
out.close();
|
|
|
strcat(cmd, " \"");
|
|
|
strcat(cmd, temp_file);
|
|
|
strcat(cmd, "\" \"");
|
|
|
strcat(cmd, path);
|
|
|
strcat(cmd, "\"");
|
|
|
printf("\n%s\n", cmd);
|
|
|
|
|
|
system(cmd);
|
|
|
char ch2;
|
|
|
ifstream in2(from, ios::in | ios::binary);
|
|
|
if (!in2)
|
|
|
{
|
|
|
cout << "could not find file" << from << endl;
|
|
|
return 1;
|
|
|
}
|
|
|
ofstream out2(to2, ios::out | ios::binary);
|
|
|
//char ch;
|
|
|
while (in2.get(ch2))
|
|
|
{
|
|
|
out2.put(ch2);
|
|
|
}
|
|
|
cout << "file has been copied" << endl;
|
|
|
in.close();
|
|
|
out.close();
|
|
|
|
|
|
|
|
|
tag_t new_file_tag = NULLTAG;
|
|
|
IMF_file_t file_descriptor;
|
|
|
IMF_import_file(temp_file, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor);
|
|
|
IMF_set_original_file_name2(new_file_tag, origin_file_name);
|
|
|
IMF_close_file(file_descriptor);
|
|
|
AOM_save(new_file_tag);
|
|
|
//AOM_unlock(new_file_tag);
|
|
|
|
|
|
AOM_lock(spec_dataset_rev);
|
|
|
|
|
|
AE_remove_dataset_named_ref_by_tag2(spec_dataset_rev, ref_name, ref_object);
|
|
|
|
|
|
AE_add_dataset_named_ref2(spec_dataset_rev, ref_name, AE_PART_OF, new_file_tag);
|
|
|
AOM_save(spec_dataset_rev);
|
|
|
AOM_unlock(spec_dataset_rev);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
printf("关超级权限\n");
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
printf("===================================\n");
|
|
|
printf("word/excel文档签名 结束\n");
|
|
|
printf("===================================\n");
|
|
|
|
|
|
return ifail;
|
|
|
|
|
|
}
|
|
|
|
|
|
//流程自动指派审批人
|
|
|
int HS2_AutoAssign(EPM_action_message_t msg) {
|
|
|
|
|
|
printf("===================================\n");
|
|
|
printf("流程自动指派审批人 开始\n");
|
|
|
printf("===================================\n");
|
|
|
int ifail = ITK_ok;
|
|
|
printf("开超级权限\n");
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
int att_cnt = 0;
|
|
|
tag_t task_tag = NULL_TAG,
|
|
|
root_task_tag = NULLTAG,
|
|
|
* attachments;
|
|
|
char* argflag = NULL, * argvalue = NULL, * arg = NULL;
|
|
|
int arg_cnt = 0;
|
|
|
char task_name[1024] = "";
|
|
|
vector<string> vec;
|
|
|
char* message;
|
|
|
//获取handler的参数的个数
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
ECHO("参数个数为:%d\n", arg_cnt);
|
|
|
|
|
|
if (arg_cnt > 0)
|
|
|
{
|
|
|
for (int i = 0; i < arg_cnt; i++)
|
|
|
{
|
|
|
//获取下一个参数(从0开始)
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
//获取参数的名称和值
|
|
|
ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
|
|
|
if (strcmp(argflag, "task") == 0)
|
|
|
{
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(task_name, argvalue);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
MEM_free(argflag);
|
|
|
MEM_free(argvalue);
|
|
|
}
|
|
|
task_tag = msg.task;
|
|
|
EPM_ask_root_task(task_tag, &root_task_tag);
|
|
|
int cnt_task = 0; tag_t* tasks = NULLTAG;
|
|
|
EPM_ask_sub_tasks(root_task_tag, &cnt_task, &tasks);
|
|
|
//ITKCALL(EPM_ask_tasks(root_task_tag, EPM_started, &cnt_task, &tasks));
|
|
|
EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments);
|
|
|
if (att_cnt > 0) {
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t rev_tag = attachments[i];
|
|
|
char* tag_type;
|
|
|
ITKCALL(AOM_ask_value_string(rev_tag, "object_type", &tag_type));
|
|
|
|
|
|
if (strcmp("HS2_ChangeTaskRevision", tag_type) == 0) {
|
|
|
int doc_num = 0;
|
|
|
tag_t* doc_tags = NULL;
|
|
|
tag_t* pathFile = NULLTAG;
|
|
|
int Num = 0;
|
|
|
char* excel_path;
|
|
|
ITKCALL(AOM_ask_value_tags(rev_tag, "IMAN_specification", &doc_num, &doc_tags));
|
|
|
char user[1024] = "\0";
|
|
|
for (int i = 0; i < doc_num; i++)
|
|
|
{
|
|
|
char* type;
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &type));
|
|
|
printf("type=%s\n", type);
|
|
|
if (strcmp(type, "MSExcelX") != 0 && strcmp(type, "MSExcel") != 0) {
|
|
|
continue;
|
|
|
}
|
|
|
char* data_name;
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_name", &data_name));
|
|
|
if (strstr(data_name, "任务单") == NULL) {
|
|
|
continue;
|
|
|
}
|
|
|
Book* book;
|
|
|
time_t t = time(0);
|
|
|
tm* local = localtime(&t);
|
|
|
|
|
|
char path[SS_MAXPATHLEN] = "";
|
|
|
char time1[256] = "\0";
|
|
|
sprintf(time1, "%d%d%d%d%d%d", local->tm_year, local->tm_mon, local->tm_mday, local->tm_hour, local->tm_min, local->tm_sec);
|
|
|
char* temp_dir = getenv("TEMP");
|
|
|
strcpy(path, temp_dir);
|
|
|
strcat(path, "\\");
|
|
|
strcat(path, time1);
|
|
|
cout << string(type) << endl;//MSExcel
|
|
|
|
|
|
if (strcmp(type, "MSExcelX") == 0)
|
|
|
{
|
|
|
strcat(path, ".xlsx");
|
|
|
//path << string(temp_dir) << "\\" << local->tm_year << local->tm_mon << local->tm_mday << local->tm_hour << local->tm_min << local->tm_sec << ".xlsx";
|
|
|
book = xlCreateXMLBook();
|
|
|
book->setKey(L"Halil Kural", L"windows-2723210a07c4e90162b26966a8jcdboe");//设置密钥
|
|
|
}
|
|
|
else//MSExcel
|
|
|
{
|
|
|
strcat(path, ".xls");
|
|
|
//path << string(temp_dir) << "\\" << local->tm_year << local->tm_mon << local->tm_mday << local->tm_hour << local->tm_min << local->tm_sec << ".xls";
|
|
|
book = xlCreateBook();
|
|
|
book->setKey(L"Halil Kural", L"windows-2723210a07c4e90162b26966a8jcdboe");//设置密钥
|
|
|
}
|
|
|
AE_export_named_ref(doc_tags[i], "excel", path);
|
|
|
//const string xxxxpath = "C:\\新建文件夹\\1.xlsx";
|
|
|
//printf("xxxxpath=%s \n", xxxxpath.c_str());
|
|
|
//stringstream pathpp;
|
|
|
//pathpp << string(path);
|
|
|
//printf("path2=%ls \n", StringToWString(xxxxpath).c_str());
|
|
|
printf("1111\n");
|
|
|
if (book->load(StringToWString(path).c_str())) {
|
|
|
printf("开始读取excel数据 \n");
|
|
|
Sheet* sheet = book->getSheet(0);
|
|
|
int rowNum = sheet->lastRow();
|
|
|
cout << "rowNum:" << rowNum << endl;//2
|
|
|
int colNum = sheet->lastCol();
|
|
|
cout << "colNum:" << colNum << endl;
|
|
|
char user_name[1024] = "\0";
|
|
|
for (auto j = 7; j < rowNum; j++) {
|
|
|
string userID = "", xh = "";
|
|
|
if (IsCellEmpty(sheet->cellType(j, 1))) {
|
|
|
if (sheet->cellType(j, 1) == 1) {//CELLTYPE_NUMBER
|
|
|
xh = DoubleToStringByStdToString(sheet->readNum(j, 1));//代号
|
|
|
}
|
|
|
else {
|
|
|
xh = WStringToString(sheet->readStr(j, 1));//代号
|
|
|
}
|
|
|
|
|
|
cout << xh << "--" << endl;//
|
|
|
}
|
|
|
if (strcmp("", xh.c_str()) == 0 || strcmp(" ", xh.c_str()) == 0) {
|
|
|
break;
|
|
|
}
|
|
|
if (IsCellEmpty(sheet->cellType(j, 7))) {
|
|
|
if (sheet->cellType(j, 7) == 1) {//CELLTYPE_NUMBER
|
|
|
userID = DoubleToStringByStdToString(sheet->readNum(j, 7));//代号
|
|
|
}
|
|
|
else {
|
|
|
userID = WStringToString(sheet->readStr(j, 7));//代号
|
|
|
}
|
|
|
cout << userID << "--" << endl;//
|
|
|
if (strstr(user_name, userID.c_str()) == NULL) {
|
|
|
strcat(user_name, userID.c_str());
|
|
|
strcat(user_name, ";");
|
|
|
vec.push_back(userID);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
struct stat info;
|
|
|
if (stat(path, &info) == 0) {
|
|
|
remove(path);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
for (int j = 0; j < cnt_task; j++)
|
|
|
{
|
|
|
tag_t subtask = tasks[j];
|
|
|
char* sub_task_object_type = NULL;
|
|
|
char* sub_task_object_name = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(subtask, "object_name", &sub_task_object_name));
|
|
|
cout << "名称--------" << sub_task_object_name << endl;
|
|
|
ITKCALL(AOM_ask_value_string(subtask, "object_type", &sub_task_object_type));
|
|
|
cout << "类型--------" << sub_task_object_type << endl;
|
|
|
if (strcmp(task_name, sub_task_object_name) == 0)
|
|
|
{
|
|
|
cout << "bingo0" << endl;
|
|
|
// ITKCALL( SA_find_user( "0120160006", &user_tag ));
|
|
|
// ITKCALL( EPM_assign_responsible_party( task, user_tag));//设置编制节点的责任方
|
|
|
tag_t tmp_select_signoff_task = NULLTAG;
|
|
|
ITKCALL(EPM_ask_sub_task(subtask, EPM_select_signoff_team_task, &tmp_select_signoff_task));
|
|
|
for (int k = 0; k < vec.size(); k++)
|
|
|
{
|
|
|
//构建器
|
|
|
tag_t* results;
|
|
|
const char query_name_product[1][QRY_name_size_c + 1] = { "管理 - 员工信息" };
|
|
|
tag_t query_tag1 = NULLTAG;
|
|
|
int entry_count1 = 0;
|
|
|
char** entries1;
|
|
|
char** values1;
|
|
|
char* other_values1[1];
|
|
|
char* other_entrys1[1];
|
|
|
other_values1[0] = (char*)calloc(48, sizeof(char));
|
|
|
other_entrys1[0] = (char*)calloc(48, sizeof(char));
|
|
|
int num_found1 = 0;
|
|
|
ITKCALL(QRY_find2(query_name_product[0], &query_tag1));
|
|
|
if (query_tag1 == NULLTAG)
|
|
|
{
|
|
|
WriteLog("query_tag=NULLTAG,没找到 [%s]查询构建器!\n", query_name_product[0]);
|
|
|
ITK_exit_module(1);
|
|
|
return 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
WriteLog("找到查询构建器\n");
|
|
|
}
|
|
|
|
|
|
ITKCALL(QRY_find_user_entries(query_tag1, &entry_count1, &entries1, &values1));//entries1:查询条件表达式;values1:查询条件值(MEM_free释放)
|
|
|
if (entry_count1 == 0)
|
|
|
{
|
|
|
WriteLog("entry_count1=0,查询构建器中没有配置查询条件!\n");
|
|
|
//ITK_exit_module(1);
|
|
|
if (entries1 != NULL) {
|
|
|
MEM_free(entries1);
|
|
|
entries1 = NULL;
|
|
|
}
|
|
|
if (values1 != NULL) {
|
|
|
MEM_free(values1);
|
|
|
values1 = NULL;
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
//date_tag.second = p->tm_sec ;
|
|
|
|
|
|
for (int n = 0; n < entry_count1; n++)
|
|
|
{
|
|
|
printf("entries1[%d]=%s\n", n, entries1[n]);
|
|
|
if (tc_strcmp(entries1[n], "人员姓名") == 0) {
|
|
|
//strcpy(values[n],nowtime1);
|
|
|
tc_strcpy(other_entrys1[0], "人员姓名");
|
|
|
tc_strcpy(other_values1[0], vec[k].c_str());//* 2012-05 NBJF16025 Test001 NBJF16046 16C104
|
|
|
printf("other_values1[0] %s\n", other_values1[0]);
|
|
|
|
|
|
}
|
|
|
|
|
|
printf("values[%d]=%s\n", n, values1[n]);
|
|
|
|
|
|
}
|
|
|
|
|
|
ITKCALL(ifail = QRY_execute(query_tag1, 1, other_entrys1, other_values1, &num_found1, &results));
|
|
|
|
|
|
if (ifail != ITK_ok) {
|
|
|
EMH_ask_error_text(ifail, &message);
|
|
|
WriteLog("程序异常 : \"%d\",\"%s\"\n", ifail, message);
|
|
|
MEM_free(message);
|
|
|
if (entries1 != NULL) {
|
|
|
MEM_free(entries1);
|
|
|
entries1 = NULL;
|
|
|
}
|
|
|
if (values1 != NULL) {
|
|
|
MEM_free(values1);
|
|
|
values1 = NULL;
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
if (num_found1 == 0)
|
|
|
{
|
|
|
printf("num_found=0,查询构建器中没找到满足条件的数据!\n");
|
|
|
//ITK_exit_module(1);
|
|
|
if (entries1 != NULL) {
|
|
|
MEM_free(entries1);
|
|
|
entries1 = NULL;
|
|
|
}
|
|
|
if (values1 != NULL) {
|
|
|
MEM_free(values1);
|
|
|
values1 = NULL;
|
|
|
}
|
|
|
}
|
|
|
//开始获取产品信息
|
|
|
printf("查询构建器得到ITEM数num_found1: \"%d\" \n", num_found1);
|
|
|
|
|
|
if (num_found1 != 0) {
|
|
|
tag_t login_group = NULLTAG;
|
|
|
printf("111!\n");
|
|
|
tag_t user = results[0];
|
|
|
/* char* user_id;
|
|
|
tag_t user_tag = NULLTAG;
|
|
|
printf("222!\n");
|
|
|
int mem_cnt = 0;
|
|
|
tag_t* members = NULL;*/
|
|
|
int signoff_cnt = 0;
|
|
|
tag_t* signoffs = NULL;
|
|
|
/* ITKCALL(AOM_ask_value_string(user, "user_id", &user_id));
|
|
|
printf("user_id=%s\n", user_id);
|
|
|
ITKCALL(SA_find_user2(user_id, &user_tag));
|
|
|
ITKCALL(SA_ask_user_login_group(user_tag, &login_group));
|
|
|
printf("333!\n");
|
|
|
ITKCALL(SA_find_groupmembers(user_tag, login_group, &mem_cnt, &members));
|
|
|
printf("mem_cnt=%d\n", mem_cnt);
|
|
|
printf("444!\n");
|
|
|
ITKCALL(EPM_create_adhoc_signoff(tmp_select_signoff_task, members[0], &signoff_cnt, &signoffs));*/
|
|
|
ITKCALL(EPM_create_adhoc_signoff(tmp_select_signoff_task, user, &signoff_cnt, &signoffs));
|
|
|
printf("555!\n");
|
|
|
ITKCALL(EPM_set_adhoc_signoff_selection_done(tmp_select_signoff_task, true));
|
|
|
printf("666!\n");
|
|
|
if (signoffs)
|
|
|
{
|
|
|
MEM_free(signoffs);
|
|
|
signoffs = NULL;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// ITKCALL(EPM_trigger_action(tmp_select_signoff_task,EPM_complete_action, ""));
|
|
|
break;
|
|
|
}
|
|
|
//}
|
|
|
//}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
printf("关超级权限\n");
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
printf("===================================\n");
|
|
|
printf("流程自动指派审批人 结束\n");
|
|
|
printf("===================================\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
//pdf名称修改
|
|
|
int HS_mod_pdf_name(EPM_action_message_t msg) {
|
|
|
int ifail = ITK_ok;
|
|
|
//流程节点相关
|
|
|
tag_t root_task = NULLTAG, * sub_tasks = NULL, current_task = NULLTAG, type_tag = NULLTAG;
|
|
|
int sub_task_count = 0;
|
|
|
char root_task_name[128] = "", task_name[128] = "";
|
|
|
int occur_of_counts = 0;
|
|
|
tag_t* taskAttches = NULLTAG;
|
|
|
char tgt_type[WSO_name_size_c + 1] = "", * type_class;
|
|
|
////循环内部变量
|
|
|
tag_t cur_task = NULLTAG;
|
|
|
//循环变量
|
|
|
int count = 0;
|
|
|
//节点循环处理变量
|
|
|
tag_t itemrevision = NULLTAG;
|
|
|
char* argflag = NULL, * argvalue = NULL, * arg = NULL;
|
|
|
int arg_cnt = 0;
|
|
|
char item_type[1024] = "";
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
ECHO("参数个数为:%d\n", arg_cnt);
|
|
|
|
|
|
if (arg_cnt > 0)
|
|
|
{
|
|
|
for (int i = 0; i < arg_cnt; i++)
|
|
|
{
|
|
|
//获取下一个参数(从0开始)
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
//获取参数的名称和值
|
|
|
ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
|
|
|
if (strcmp(argflag, "type") == 0)
|
|
|
{
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(item_type, argvalue);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
MEM_free(argflag);
|
|
|
MEM_free(argvalue);
|
|
|
}
|
|
|
current_task = msg.task;
|
|
|
//CreateLogFile("PLA8_signoff",&txtfile);
|
|
|
ECHO("=========================================================\n");
|
|
|
ECHO("pdf名称修改 开始执行\n");
|
|
|
ECHO("=========================================================\n");
|
|
|
//获取属性
|
|
|
EPM_ask_root_task(msg.task, &root_task);
|
|
|
EPM_ask_sub_tasks(root_task, &sub_task_count, &sub_tasks);
|
|
|
EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches);
|
|
|
ECHO("%d target attachment found", occur_of_counts);
|
|
|
|
|
|
for (count = 0; count < occur_of_counts; count++)
|
|
|
{
|
|
|
ITKCALL(TCTYPE_ask_object_type(taskAttches[count], &type_tag));
|
|
|
ITKCALL(ifail = TCTYPE_ask_class_name2(type_tag, &type_class));
|
|
|
|
|
|
//过滤掉非版本对象
|
|
|
if (strcmp(type_class, item_type) == 0)
|
|
|
{
|
|
|
char* item_id, * item_name, * item_rev;
|
|
|
int level = 0;
|
|
|
itemrevision = taskAttches[count];
|
|
|
ITKCALL(AOM_ask_value_string(itemrevision, "item_id", &item_id));
|
|
|
ITKCALL(AOM_ask_value_string(itemrevision, "object_name", &item_name));
|
|
|
ITKCALL(AOM_ask_value_string(itemrevision, "item_revision_id", &item_rev));
|
|
|
|
|
|
//获得数据集
|
|
|
tag_t relation_type = NULLTAG;
|
|
|
//tag_t attach_relation_type = NULLTAG;
|
|
|
ITKCALL(GRM_find_relation_type(TC_specification_rtype, &relation_type));
|
|
|
tag_t* secondary_objects = NULLTAG;
|
|
|
int ds_count = 0;
|
|
|
char* dataset_type = NULL;
|
|
|
ITKCALL(GRM_list_secondary_objects_only(itemrevision, relation_type, &ds_count, &secondary_objects));
|
|
|
for (int j = 0; j < ds_count; j++)
|
|
|
{
|
|
|
char dataset_name[512] = "\0";
|
|
|
printf("进1\n");
|
|
|
ITKCALL(AOM_ask_value_string(secondary_objects[j], "object_type", &dataset_type));
|
|
|
int des_count = 0;
|
|
|
tag_t* dess = NULL;
|
|
|
|
|
|
printf("dataset_type=%s\n", dataset_type);
|
|
|
if (strcmp(dataset_type, "PDF") != 0) {
|
|
|
|
|
|
if (dataset_type != NULL) {
|
|
|
MEM_free(dataset_type);
|
|
|
dataset_type = NULL;
|
|
|
}
|
|
|
|
|
|
continue;
|
|
|
}
|
|
|
ITKCALL(AOM_ask_value_tags(secondary_objects[j], "ref_list", &des_count, &dess));
|
|
|
if (des_count < 1) {
|
|
|
printf("该数据集引用数量错误\n");
|
|
|
continue;
|
|
|
}
|
|
|
tag_t spec_dataset_rev = NULLTAG,
|
|
|
ref_object = NULLTAG;
|
|
|
char* ref_object_name = NULL;
|
|
|
AE_reference_type_t reference_type;
|
|
|
//char* datasetName = NULL;
|
|
|
char* pathname;
|
|
|
char* origin_file_name;
|
|
|
vector<string> type_vec;
|
|
|
printf("开始判断类型\n");
|
|
|
if (strcmp(dataset_type, "PDF") == 0) {
|
|
|
printf("pdf类型\n");
|
|
|
sprintf(dataset_name, "%s_%s_%s", item_id, item_name, item_rev);
|
|
|
if (level != 0) {
|
|
|
char level_num[64] = "\0";
|
|
|
sprintf(level_num, "%d", level);
|
|
|
strcat(dataset_name, "_");
|
|
|
strcat(dataset_name, level_num);
|
|
|
}
|
|
|
level++;
|
|
|
AOM_lock(secondary_objects[j]);
|
|
|
AOM_set_value_string(secondary_objects[j], "object_name", dataset_name);
|
|
|
AOM_save(secondary_objects[j]);
|
|
|
AOM_unlock(secondary_objects[j]);
|
|
|
//AOM_ask_value_string(secondary_objects[j], "object_name", &datasetName);
|
|
|
AE_ask_dataset_latest_rev(secondary_objects[j], &spec_dataset_rev);
|
|
|
AOM_ask_value_string(spec_dataset_rev, "object_name", &ref_object_name);
|
|
|
printf("ref_object_name=%s\n", ref_object_name);
|
|
|
char ref_name[WSO_name_size_c + 1] = "PDF_Reference";
|
|
|
|
|
|
AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object);
|
|
|
if (ref_object == NULLTAG)
|
|
|
{
|
|
|
printf("\nref_object is NULLTAG\n");
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
printf("reference_type=%d\n", reference_type);
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
ITKCALL(IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname));
|
|
|
IMF_ask_original_file_name2(ref_object, &origin_file_name);
|
|
|
char new_ds_name[WSO_name_size_c + 1] = "";
|
|
|
char* new_file_name = USER_new_file_name(new_ds_name, ref_name, "pdf", 0);
|
|
|
char* temp_dir = getenv("temp");
|
|
|
char temp_file[SS_MAXPATHLEN] = "";
|
|
|
strcpy(temp_file, temp_dir);
|
|
|
strcat(temp_file, "\\");
|
|
|
strcat(temp_file, new_file_name);
|
|
|
IMF_export_file(ref_object, temp_file);
|
|
|
printf("\ntemp_file=%s\n", temp_file);
|
|
|
tag_t new_file_tag = NULLTAG;
|
|
|
IMF_file_t file_descriptor;
|
|
|
IMF_import_file(temp_file, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor);
|
|
|
IMF_set_original_file_name2(new_file_tag, dataset_name);
|
|
|
IMF_close_file(file_descriptor);
|
|
|
AOM_save(new_file_tag);
|
|
|
//AOM_unlock(new_file_tag);
|
|
|
AOM_lock(spec_dataset_rev);
|
|
|
AE_remove_dataset_named_ref_by_tag2(spec_dataset_rev, ref_name, ref_object);
|
|
|
AE_add_dataset_named_ref2(spec_dataset_rev, ref_name, AE_PART_OF, new_file_tag);
|
|
|
AOM_save(spec_dataset_rev);
|
|
|
AOM_unlock(spec_dataset_rev);
|
|
|
}
|
|
|
}
|
|
|
MEM_free(dataset_type);
|
|
|
|
|
|
}
|
|
|
DOFREE(secondary_objects);
|
|
|
}
|
|
|
}
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
DOFREE(taskAttches);
|
|
|
ECHO("=========================================================\n");
|
|
|
ECHO("pdf名称修改 结束\n");
|
|
|
ECHO("=========================================================\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
//黏贴图纸后操作
|
|
|
int HS_SendToSRM(void* returnValue)
|
|
|
{
|
|
|
int ifail = 0;
|
|
|
char* strs = NULL;
|
|
|
char* user = NULL;
|
|
|
char* person_name = NULL;
|
|
|
char* user_id = NULL;
|
|
|
tag_t userTag = NULLTAG;
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
ITKCALL(ifail = USERARG_get_string_argument(&strs));
|
|
|
ITKCALL(ifail = USERARG_get_string_argument(&user));
|
|
|
printf("strs=%s\n", strs);
|
|
|
printf("user=%s\n", user);
|
|
|
ITK__convert_uid_to_tag(user, &userTag);
|
|
|
ITKCALL(AOM_ask_value_string(userTag, "user_id", &user_id));
|
|
|
SA_ask_user_person_name2(userTag, &person_name);
|
|
|
printf("user_id=%s\n", user_id);
|
|
|
printf("person_name=%s\n", person_name);
|
|
|
char* url;
|
|
|
//图纸接口的首选项
|
|
|
ITKCALL(PREF_ask_char_value("HS_DRAW_URL", 0, &url));
|
|
|
time_t t;
|
|
|
struct tm* lt;
|
|
|
time(&t);//获取Unix时间戳。
|
|
|
lt = localtime(&t);//转为时间结构。
|
|
|
char file_name[256] = "";
|
|
|
|
|
|
char cmd[1000] = "";
|
|
|
char* tc_root_dir = getenv("tc_root");
|
|
|
sprintf(file_name, "%s-%d%d%d%d%d%d", user_id, lt->tm_year, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec);
|
|
|
printf("file_name====%s\n", file_name);
|
|
|
char path[128] = "\0";
|
|
|
strcat(path, getenv("TEMP"));
|
|
|
strcat(path, "\\");
|
|
|
strcat(path, file_name);
|
|
|
strcat(path, ".txt");
|
|
|
FILE* fpWrite = fopen(path, "w");
|
|
|
printf("path=%s\n", path);
|
|
|
char Draw_value[10480] = "\0";
|
|
|
strcat(Draw_value, strs);
|
|
|
fprintf(fpWrite, "%s", Draw_value);
|
|
|
fclose(fpWrite);
|
|
|
strcpy(cmd, "java -jar ");
|
|
|
strcat(cmd, tc_root_dir);
|
|
|
strcat(cmd, "\\bin\\HSSendSRM.jar");
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, "DRAW");
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, path);
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, person_name);
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, url);
|
|
|
printf("%s", cmd);
|
|
|
WinExec(cmd, SW_NORMAL);
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
return 0;
|
|
|
}
|
|
|
//图纸信息传递SRM
|
|
|
int HS_SRM_Drawing(EPM_action_message_t msg) {
|
|
|
ECHO("===================================\n");
|
|
|
ECHO("图纸信息传递SRM 开始\n");
|
|
|
ECHO("===================================\n");
|
|
|
int ifail = ITK_ok;
|
|
|
ECHO("开超级权限\n");
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
//从流程中的参数
|
|
|
tag_t task_tag = NULL_TAG,
|
|
|
root_task_tag = NULLTAG,
|
|
|
* attachments,
|
|
|
* comps;
|
|
|
task_tag = msg.task;
|
|
|
int att_cnt = 0;
|
|
|
int value_count = 0;
|
|
|
int count = 0;
|
|
|
char** values;
|
|
|
char* url;
|
|
|
//ITKCALL(PREF_ask_char_values("HS_UNIT_CODE", &value_count, &values));
|
|
|
//图纸接口的首选项
|
|
|
ITKCALL(PREF_ask_char_value("HS_DRAW_URL", 0, &url));
|
|
|
tag_t executor;
|
|
|
char* user_id;
|
|
|
char* user_uid;
|
|
|
char* person_name;
|
|
|
char* valueid = "null";//零件id
|
|
|
char* revvalueid = "null";//零件版本id
|
|
|
EPM_ask_root_task(task_tag, &root_task_tag);
|
|
|
//
|
|
|
ITKCALL(AOM_ask_value_tag(task_tag, "owning_user", &executor));
|
|
|
ITKCALL(AOM_ask_value_string(executor, "user_id", &user_id));
|
|
|
POM_tag_to_uid(executor, &user_uid);
|
|
|
SA_ask_user_person_name2(executor, &person_name);
|
|
|
EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments);
|
|
|
char* taget_type;
|
|
|
vector<SPM_DRAW> Draw_vec;
|
|
|
SPM_DRAW Draw;
|
|
|
char* rootUid;
|
|
|
ITK__convert_tag_to_uid(root_task_tag, &rootUid);
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t target = attachments[i];
|
|
|
boolean flag = false;
|
|
|
int form_count = 0;
|
|
|
int num = 0;
|
|
|
tag_t* forms = NULLTAG;
|
|
|
tag_t* num_tags = NULLTAG;
|
|
|
|
|
|
tag_t master_form = NULLTAG;
|
|
|
tag_t systemItem = NULLTAG;
|
|
|
tag_t lastrev = NULLTAG;
|
|
|
char* status;
|
|
|
ITKCALL(AOM_ask_value_string(target, "object_type", &taget_type));
|
|
|
|
|
|
ECHO("3.15流程目标类型======%s\n", taget_type);
|
|
|
|
|
|
if (((strstr(taget_type, "Revision") != NULL) || (strstr(taget_type, "revision") != NULL))
|
|
|
&& (strstr(taget_type, "Master") == NULL) && (strstr(taget_type, "master") == NULL)
|
|
|
&& (strstr(taget_type, "BOM") == NULL) && (strstr(taget_type, "bom") == NULL) && (strstr(taget_type, "Bom") == NULL))
|
|
|
{
|
|
|
//判断是否为零件版本
|
|
|
if (strcmp(taget_type, "Part Revision") == 0) {
|
|
|
//获取发布状态,判断是否发布
|
|
|
ITKCALL(AOM_ask_value_tags(target, "release_status_list", &num, &num_tags));
|
|
|
if (num > 0) {
|
|
|
printf("进入Part Revision的判断\n");
|
|
|
//1、先获取零件id
|
|
|
ITKCALL(AOM_ask_value_string(target, "item_id", &valueid));
|
|
|
ECHO("3.15物料id===1===%s\n", valueid);
|
|
|
|
|
|
//获取关系文件夹下的图纸
|
|
|
ITKCALL(AOM_ask_value_tags(target, "TC_Is_Represented_By", &count, &comps));
|
|
|
//获取所有版本的图纸
|
|
|
if (count > 0) {
|
|
|
for (int j = 0; j < count; j++) {
|
|
|
tag_t comp = comps[j];
|
|
|
char* tustatus;
|
|
|
ITKCALL(AOM_ask_value_tags(comp, "release_status_list", &num, &num_tags));
|
|
|
if (num > 0)
|
|
|
{
|
|
|
//先通过版本获取对象
|
|
|
ITEM_ask_item_of_rev(comp, &systemItem);
|
|
|
//再通过对象获取最新版本
|
|
|
ITEM_ask_latest_rev(systemItem, &lastrev);
|
|
|
//2、通过最新版本,获取版本id
|
|
|
ITKCALL(AOM_ask_value_string(lastrev, "item_revision_id", &revvalueid));
|
|
|
ECHO("3.15版本id===1===%s\n", revvalueid);
|
|
|
//将获取到的零件id和图纸版本id写进集合中
|
|
|
if (strcmp(valueid, "") != 0 && strcmp(valueid, " ") != 0) {
|
|
|
Draw.cInvCode.assign(valueid);
|
|
|
}
|
|
|
else {
|
|
|
Draw.cInvCode.assign(" ");
|
|
|
}
|
|
|
if (strcmp(revvalueid, "") != 0 && strcmp(revvalueid, " ") != 0) {
|
|
|
Draw.VersionNo.assign(revvalueid);
|
|
|
}
|
|
|
else {
|
|
|
Draw.VersionNo.assign(" ");
|
|
|
}
|
|
|
Draw_vec.push_back(Draw);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
WriteLog("图纸未发布");
|
|
|
ECHO("图纸未发布\n");
|
|
|
ifail = ITK_err;
|
|
|
ITKCALL(ifail = EMH_store_error_s1(EMH_severity_error, ITK_err, ("图纸未发布")));
|
|
|
goto end;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ECHO("不存在图纸\n");
|
|
|
ifail = ITK_err;
|
|
|
ITKCALL(ifail = EMH_store_error_s1(EMH_severity_error, ITK_err, ("不存在图纸")));
|
|
|
goto end;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
WriteLog("零件未发布");
|
|
|
ECHO("零件未发布\n");
|
|
|
ifail = ITK_err;
|
|
|
ITKCALL(ifail = EMH_store_error_s1(EMH_severity_error, ITK_err, ("零件未发布")));
|
|
|
goto end;
|
|
|
}
|
|
|
}//判断是否为图纸版本
|
|
|
else if (strcmp(taget_type, "HS2_ProductPartRevision") == 0) {
|
|
|
//获取发布状态,判断是否发布
|
|
|
ITKCALL(AOM_ask_value_tags(target, "release_status_list", &num, &num_tags));
|
|
|
if (num > 0) {
|
|
|
//1、先获取版本id
|
|
|
ITKCALL(AOM_ask_value_string(target, "item_revision_id", &revvalueid));
|
|
|
ECHO("3.15版本id===2===%s\n", revvalueid);
|
|
|
//获取关系文件夹下的零件
|
|
|
ITKCALL(AOM_ask_value_tags(target, "representation_for", &count, &comps));
|
|
|
//判断是否有零件
|
|
|
if (count > 0) {
|
|
|
for (int j = 0; j < count; j++) {
|
|
|
tag_t comp = comps[j];
|
|
|
char* tustatus;
|
|
|
ITKCALL(AOM_ask_value_tags(comp, "release_status_list", &num, &num_tags));
|
|
|
if (num > 0)
|
|
|
{
|
|
|
//2、获取零件id
|
|
|
ITKCALL(AOM_ask_value_string(comp, "item_id", &valueid));
|
|
|
ECHO("3.15物料id===2===%s\n", valueid);
|
|
|
//将获取到的零件id和图纸版本id写进集合中
|
|
|
if (strcmp(valueid, "") != 0 && strcmp(valueid, " ") != 0) {
|
|
|
Draw.cInvCode.assign(valueid);
|
|
|
}
|
|
|
else {
|
|
|
Draw.cInvCode.assign(" ");
|
|
|
}
|
|
|
if (strcmp(revvalueid, "") != 0 && strcmp(revvalueid, " ") != 0) {
|
|
|
Draw.VersionNo.assign(revvalueid);
|
|
|
}
|
|
|
else {
|
|
|
Draw.VersionNo.assign(" ");
|
|
|
}
|
|
|
Draw_vec.push_back(Draw);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
WriteLog("图纸未发布");
|
|
|
ECHO("图纸未发布\n");
|
|
|
ifail = ITK_err;
|
|
|
ITKCALL(ifail = EMH_store_error_s1(EMH_severity_error, ITK_err, ("图纸未发布")));
|
|
|
goto end;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//else {
|
|
|
// ECHO("不存在图纸版本\n");
|
|
|
// ifail = ITK_err;
|
|
|
// ITKCALL(ifail = EMH_store_error_s1(EMH_severity_information, ITK_err, ("不存在图纸版本,请发布!!")));//错误弹窗
|
|
|
// goto end;
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
|
|
|
time_t t;
|
|
|
struct tm* lt;
|
|
|
time(&t);//获取Unix时间戳。
|
|
|
lt = localtime(&t);//转为时间结构。
|
|
|
char file_name[256] = "";
|
|
|
|
|
|
char cmd[1000] = "";
|
|
|
char* tc_root_dir = getenv("tc_root");
|
|
|
sprintf(file_name, "%s-%d%d%d%d%d%d", user_id, lt->tm_year, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec);
|
|
|
printf("file_name====%s\n", file_name);
|
|
|
char path[128] = "\0";
|
|
|
strcat(path, getenv("TEMP"));
|
|
|
strcat(path, "\\");
|
|
|
strcat(path, file_name);
|
|
|
strcat(path, ".txt");
|
|
|
FILE* fpWrite = fopen(path, "w");
|
|
|
printf("path=%s\n", path);
|
|
|
char Draw_value[10480] = "\0";
|
|
|
|
|
|
for (int i = 0; i < Draw_vec.size(); i++)
|
|
|
{
|
|
|
|
|
|
strcat(Draw_value, (Draw_vec[i].cInvCode).c_str());
|
|
|
strcat(Draw_value, ";");
|
|
|
strcat(Draw_value, (Draw_vec[i].VersionNo).c_str());
|
|
|
|
|
|
if (i < Draw_vec.size() - 1) {
|
|
|
|
|
|
strcat(Draw_value, "&");
|
|
|
}
|
|
|
}
|
|
|
fprintf(fpWrite, "%s", Draw_value);
|
|
|
fclose(fpWrite);
|
|
|
strcpy(cmd, "java -jar ");
|
|
|
strcat(cmd, tc_root_dir);
|
|
|
strcat(cmd, "\\bin\\HSSendSRM.jar");
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, "DRAW");
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, path);
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, person_name);
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, url);
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, rootUid);
|
|
|
printf("%s", cmd);
|
|
|
WinExec(cmd, SW_NORMAL);
|
|
|
//system(cmd);
|
|
|
|
|
|
end:
|
|
|
ECHO("关超级权限\n");
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
ECHO("===================================\n");
|
|
|
ECHO("图纸信息传递SRM 结束\n");
|
|
|
ECHO("===================================\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
//时间表任务通知
|
|
|
int Connor_Schedule_Task_Mail(EPM_action_message_t msg) {
|
|
|
bool debug = false;
|
|
|
int ifail = ITK_ok, arg_cnt = 0, att_cnt = 0, task_count = 0, user_cnt = 0;
|
|
|
char* arg = NULL, * argflag = NULL, * argvalue = NULL, * task_name = NULL, * task_type = NULL;
|
|
|
char* user_id = NULL, * user_name = NULL, * job_name = NULL, * task_state = NULL;
|
|
|
tag_t task_tag = NULLTAG, rootTask_tag = NULLTAG, user_tag = NULLTAG;
|
|
|
tag_t* attachments = NULL, * task_tags = NULL;
|
|
|
vector<tag_t> all_user_tags;
|
|
|
vector<string> mail_addrs;
|
|
|
tag_t memberTag = NULLTAG;
|
|
|
SIGNOFF_TYPE_t memberType;
|
|
|
ITKCALL(POM_get_user(&user_name, &user_tag));
|
|
|
ITKCALL(SA_ask_user_identifier2(user_tag, &user_id));
|
|
|
DOFREE(user_id);
|
|
|
char* url;
|
|
|
ITKCALL(PREF_ask_char_value("Autocode_SendEmailServer_URL", 0, &url));
|
|
|
printf("=============================================================\n");
|
|
|
printf("开始执行:Connor_Schedule_Task_Mail\n");
|
|
|
printf("=============================================================\n");
|
|
|
printf("开超级权限\n");
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
task_tag = msg.task;
|
|
|
if (task_tag == NULLTAG) {
|
|
|
goto end;
|
|
|
}
|
|
|
//获取handler的参数的个数
|
|
|
char sign_attr[2048] = "";
|
|
|
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
ECHO("参数个数为:%d\n", arg_cnt);
|
|
|
|
|
|
if (arg_cnt > 0)
|
|
|
{
|
|
|
for (int i = 0; i < arg_cnt; i++)
|
|
|
{
|
|
|
//获取下一个参数(从0开始)
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
|
|
|
//获取参数的名称和值
|
|
|
ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
|
|
|
if (strcmp(argflag, "flag") == 0)
|
|
|
{
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(sign_attr, argvalue);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
MEM_free(argflag);
|
|
|
MEM_free(argvalue);
|
|
|
}
|
|
|
//char* task_uid;
|
|
|
//POM_tag_to_uid(task_tag, &task_uid);
|
|
|
//char mail_content[1024] = "您有一个项目任务,请查看:";
|
|
|
char mail_content[1024] = "\0";
|
|
|
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(rootTask_tag, "job_name", &job_name));
|
|
|
printf("流程名称:%s\n", job_name);
|
|
|
strcpy(mail_content, job_name);
|
|
|
ITKCALL(ifail = EPM_ask_name2(task_tag, &task_name));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(task_tag, "task_type", &task_type));
|
|
|
if (ifail != ITK_ok) {
|
|
|
DOFREE(task_name);
|
|
|
DOFREE(task_type);
|
|
|
}
|
|
|
ECHO("task_type = %s\n", task_type);
|
|
|
char mail_subject[512] = "\0";
|
|
|
if (strcmp("EPMDoTask", task_type) == 0) {
|
|
|
|
|
|
//获取所属项目,开始日期,完成日期
|
|
|
//时间任务表对象,时间表对象
|
|
|
tag_t* schedule_tasks = NULL;
|
|
|
tag_t schedule_tag = NULL;
|
|
|
int task_num = 0;
|
|
|
//所属项目
|
|
|
char start_date_s[512] = "\0";
|
|
|
char finish_date_s[512] = "\0";
|
|
|
char* projects_list = NULL;
|
|
|
date_t start_date, finish_date;
|
|
|
ITKCALL(ifail = AOM_ask_value_tags(task_tag, "fnd0RootScheduleTask", &task_num, &schedule_tasks));
|
|
|
//if (task_num > 0) {
|
|
|
if (task_num == 0) {
|
|
|
ITKCALL(ifail = AOM_ask_value_tags(task_tag, "root_reference_attachments", &task_num, &schedule_tasks));
|
|
|
}
|
|
|
ITKCALL(ifail = AOM_ask_value_tag(schedule_tasks[0], "schedule_tag", &schedule_tag));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(schedule_tag, "projects_list", &projects_list));
|
|
|
ITKCALL(ifail = AOM_ask_value_date(schedule_tasks[0], "start_date", &start_date));
|
|
|
ITKCALL(ifail = AOM_ask_value_date(schedule_tasks[0], "finish_date", &finish_date));
|
|
|
|
|
|
if (strcmp("start", sign_attr) == 0) {
|
|
|
strcpy(mail_subject, "您有一个项目任务,请查看");
|
|
|
ITKCALL(ifail = AOM_ask_value_tag(task_tag, "fnd0Performer", &user_tag));
|
|
|
if (user_tag == NULLTAG) {
|
|
|
printf("未找到执行者\n");
|
|
|
}
|
|
|
ITKCALL(ifail = AOM_ask_value_string(user_tag, "user_name", &user_name));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(task_tag, "task_state", &task_state));
|
|
|
printf(">> DO任务信息:%s|%s\n", user_name, task_state);
|
|
|
all_user_tags.push_back(user_tag);
|
|
|
|
|
|
sprintf(start_date_s, "%d-%d-%d-%02d:%02d", start_date.year, start_date.month + 1, start_date.day, start_date.hour, start_date.minute);
|
|
|
sprintf(finish_date_s, "%d-%d-%d-%02d:%02d", finish_date.year, finish_date.month + 1, finish_date.day, finish_date.hour, finish_date.minute);
|
|
|
/*sprintf(start_date_s, "%d-%d-%d-%d:%d", start_date.year, start_date.month + 1, start_date.day, start_date.hour, start_date.minute);
|
|
|
sprintf(finish_date_s, "%d-%d-%d-%d:%d", finish_date.year, finish_date.month + 1, finish_date.day, finish_date.hour, finish_date.minute);*/
|
|
|
strcat_s(mail_content, "-项目名称:");
|
|
|
strcat_s(mail_content, projects_list);
|
|
|
strcat_s(mail_content, "-开始日期:");
|
|
|
strcat_s(mail_content, start_date_s);
|
|
|
strcat_s(mail_content, "-完成日期:");
|
|
|
strcat_s(mail_content, finish_date_s);
|
|
|
|
|
|
}
|
|
|
else if (strcmp("end", sign_attr) == 0) {
|
|
|
strcpy(mail_subject, "您有一个项目任务已完成,请查看");
|
|
|
ITKCALL(ifail = AOM_ask_value_tag(task_tag, "owning_user", &user_tag));
|
|
|
if (user_tag == NULLTAG) {
|
|
|
printf("未找任务所有者\n");
|
|
|
}
|
|
|
ITKCALL(ifail = AOM_ask_value_string(user_tag, "user_name", &user_name));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(task_tag, "task_state", &task_state));
|
|
|
printf(">> 完成任务信息:%s|%s\n", user_name, task_state);
|
|
|
all_user_tags.push_back(user_tag);
|
|
|
//实际开始时间
|
|
|
char actual_start_date_s[512] = "\0";
|
|
|
//系统当前时间作为实际完成时间
|
|
|
time_t t;
|
|
|
struct tm* lt;
|
|
|
time(&t);//获取Unix时间戳。
|
|
|
lt = localtime(&t);//转为时间结构。
|
|
|
char current_date_s[512] = "\0"; //当前年份
|
|
|
strftime(current_date_s, 64, "%Y-%m-%d-%H:%M:%S", lt);
|
|
|
//sprintf(current_date_s, "%d-%d-%d-%d:%d", lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday,lt->tm_hour,lt->tm_min);
|
|
|
//char actual_finish_date_s[512] = "\0";
|
|
|
date_t actual_start_date;
|
|
|
/*int hour = start_date.hour;
|
|
|
string hour_s = "0";
|
|
|
if (hour < 10) {s
|
|
|
hour_s.append(to_string(hour));
|
|
|
}*/
|
|
|
sprintf(start_date_s, "%d-%d-%d-%02d:%02d", start_date.year, start_date.month + 1, start_date.day, start_date.hour, start_date.minute);
|
|
|
//sprintf(start_date_s, "%d-%d-%d-%d:%d", start_date.year, start_date.month + 1, start_date.day, start_date.hour, start_date.minute);
|
|
|
sprintf(finish_date_s, "%d-%d-%d-%02d:%02d", finish_date.year, finish_date.month + 1, finish_date.day, finish_date.hour, finish_date.minute);
|
|
|
ITKCALL(ifail = AOM_ask_value_date(schedule_tasks[0], "actual_start_date", &actual_start_date));
|
|
|
sprintf(actual_start_date_s, "%d-%d-%d-%02d:%02d", actual_start_date.year, actual_start_date.month + 1, actual_start_date.day, actual_start_date.hour, actual_start_date.minute);
|
|
|
//sprintf(actual_finish_date_s, "%d-%d-%d", actual_finish_date.year, actual_finish_date.month + 1, actual_finish_date.day);
|
|
|
ITKCALL(ifail = AOM_ask_value_tag(task_tag, "fnd0Performer", &user_tag));
|
|
|
if (user_tag == NULLTAG) {
|
|
|
printf("未找到执行者\n");
|
|
|
}
|
|
|
ITKCALL(ifail = AOM_ask_value_string(user_tag, "user_name", &user_name));
|
|
|
strcat_s(mail_content, "-项目名称:");
|
|
|
strcat_s(mail_content, projects_list);
|
|
|
strcat_s(mail_content, "-开始日期:");
|
|
|
strcat_s(mail_content, start_date_s);
|
|
|
strcat_s(mail_content, "-完成日期:");
|
|
|
strcat_s(mail_content, finish_date_s);
|
|
|
strcat_s(mail_content, "-实际开始日期:");
|
|
|
strcat_s(mail_content, actual_start_date_s);
|
|
|
strcat_s(mail_content, "-实际完成日期:");
|
|
|
strcat_s(mail_content, current_date_s);
|
|
|
strcat_s(mail_content, "-任务指派人:");
|
|
|
strcat_s(mail_content, user_name);
|
|
|
|
|
|
|
|
|
}
|
|
|
else {
|
|
|
printf(">> 未配置任务参数flag或任务参数配置错误\n");
|
|
|
}
|
|
|
printf("邮件内容=%s\n", mail_content);
|
|
|
DOFREE(user_name);
|
|
|
DOFREE(task_state);
|
|
|
//else {
|
|
|
//printf(">> 当前流程不存在时间表任务\n");
|
|
|
//}
|
|
|
|
|
|
}
|
|
|
else {
|
|
|
printf(">> 未知任务类型\n");
|
|
|
}
|
|
|
user_cnt = all_user_tags.size();
|
|
|
printf("处理用户数据:%d\n", user_cnt);
|
|
|
for (int i = 0; i < user_cnt; i++) {
|
|
|
tag_t mail_user = all_user_tags[i], person_tag = NULLTAG;
|
|
|
char* user_str = NULL, * mail_str = NULL;
|
|
|
ITKCALL(ifail = AOM_ask_value_tag(mail_user, "person", &person_tag));
|
|
|
if (ifail != ITK_ok || person_tag == NULLTAG) {
|
|
|
continue;
|
|
|
}
|
|
|
ITKCALL(ifail = AOM_ask_value_string(person_tag, "PA9", &mail_str));
|
|
|
if (ifail != ITK_ok) {
|
|
|
continue;
|
|
|
}
|
|
|
ITKCALL(ifail = AOM_ask_value_string(mail_user, "user_name", &user_str));
|
|
|
printf(">> %d. %s -> %s\n", i + 1, user_str, mail_str);
|
|
|
if (mail_str == NULL || strcmp("", mail_str) == 0 || std::find(mail_addrs.begin(), mail_addrs.end(), mail_str) != mail_addrs.end()) {
|
|
|
printf(">> Skip\n");
|
|
|
}
|
|
|
else {
|
|
|
mail_addrs.push_back(mail_str);
|
|
|
}
|
|
|
DOFREE(user_str);
|
|
|
DOFREE(mail_str);
|
|
|
}
|
|
|
user_cnt = mail_addrs.size();
|
|
|
|
|
|
|
|
|
printf("发送邮件:%d", user_cnt);
|
|
|
char user_mail[2048] = "\0";
|
|
|
for (int i = 0; i < user_cnt; i++) {
|
|
|
string mail_addr = mail_addrs[i];
|
|
|
WriteLog(">> %d. 发送邮件给[%s]", i + 1, mail_addr.c_str());
|
|
|
strcat(user_mail, mail_addr.c_str());
|
|
|
if (i < user_cnt - 1) {
|
|
|
strcat(user_mail, ",");
|
|
|
}
|
|
|
}
|
|
|
char cmd[1024] = "";
|
|
|
char jarfile[512] = "";
|
|
|
sprintf(jarfile, "%s\\bin\\SendToEmail.jar", getenv("TC_ROOT"));
|
|
|
//strcpy_s(cmd, "java -jar ");
|
|
|
//strcat_s(cmd, jarfile);
|
|
|
//strcat_s(cmd, " \"");
|
|
|
//strcat_s(cmd, user_mail);
|
|
|
//strcat_s(cmd, "\" \"【TeamCenter】-");
|
|
|
//strcat_s(cmd, mail_subject);
|
|
|
//strcat_s(cmd, "\" \"");
|
|
|
///*strcat_s(cmd, " 收到");
|
|
|
//strcat_s(cmd, job_name);
|
|
|
//strcat_s(cmd, "任务,请尽快处理!!");*/
|
|
|
//strcat_s(cmd, mail_content);
|
|
|
//strcat_s(cmd, "\"");
|
|
|
//strcat_s(cmd, url);
|
|
|
|
|
|
|
|
|
strcpy_s(cmd, "java -jar ");
|
|
|
strcat_s(cmd, jarfile);
|
|
|
strcat_s(cmd, " 【TeamCenter】-");
|
|
|
strcat_s(cmd, mail_subject);
|
|
|
strcat_s(cmd, " ");
|
|
|
strcat_s(cmd, user_mail);
|
|
|
strcat_s(cmd, " ");
|
|
|
strcat_s(cmd, mail_content);
|
|
|
strcat_s(cmd, " ");
|
|
|
strcat_s(cmd, url);
|
|
|
printf("CMD:%s", cmd);
|
|
|
WinExec(cmd, SW_NORMAL);
|
|
|
//system(cmd);
|
|
|
printf("执行完成");
|
|
|
printf("关超级权限\n");
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
end:
|
|
|
all_user_tags.clear();
|
|
|
printf("=============================================================\n");
|
|
|
printf("执行结束:Connor_Schedule_Task_Mail\n");
|
|
|
printf("=============================================================\n");
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
//检查流程目标对象下数据集的大小
|
|
|
int HS2_Check_Dataset_Size(EPM_rule_message_t msg) {
|
|
|
printf("===================================\n");
|
|
|
printf("检查流程目标对象下数据集的大小 开始\n");
|
|
|
printf("===================================\n");
|
|
|
|
|
|
int ifail = ITK_ok;
|
|
|
//流程节点相关
|
|
|
tag_t root_task = NULLTAG, * sub_tasks = NULL, current_task = NULLTAG, type_tag = NULLTAG;
|
|
|
int sub_task_count = 0;
|
|
|
char root_task_name[128] = "", task_name[128] = "";
|
|
|
int occur_of_counts = 0;
|
|
|
tag_t* taskAttches = NULLTAG;
|
|
|
char tgt_type[WSO_name_size_c + 1] = "", * type_class;
|
|
|
////循环内部变量
|
|
|
tag_t cur_task = NULLTAG;
|
|
|
//循环变量
|
|
|
int count = 0;
|
|
|
|
|
|
//节点循环处理变量
|
|
|
tag_t itemrevision = NULLTAG, master_form_rel_type = NULLTAG;
|
|
|
int form_count = 0;
|
|
|
tag_t* form_list = NULL, master_form = NULLTAG;
|
|
|
|
|
|
//开旁路
|
|
|
//参数相关
|
|
|
int arg_cnt = 0;
|
|
|
char* argflag = NULL, * argvalue = NULL, * arg = NULL;
|
|
|
char TZ[16] = "";
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
ECHO("参数个数为:%d\n", arg_cnt);
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
|
|
|
|
|
|
if (arg_cnt > 0)
|
|
|
{
|
|
|
for (int i = 0; i < arg_cnt; i++)
|
|
|
{
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
|
|
|
if (stricmp(argflag, "type") == 0)
|
|
|
{
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(TZ, argvalue);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (argflag != NULL) {
|
|
|
MEM_free(argflag);
|
|
|
argflag = NULL;
|
|
|
}
|
|
|
}
|
|
|
EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches);
|
|
|
for (count = 0; count < occur_of_counts; count++)
|
|
|
{
|
|
|
ITKCALL(TCTYPE_ask_object_type(taskAttches[count], &type_tag));
|
|
|
ITKCALL(ifail = TCTYPE_ask_class_name2(type_tag, &type_class));
|
|
|
|
|
|
if (((strstr(type_class, "Revision") != NULL) || (strstr(type_class, "revision") != NULL))
|
|
|
&& (strstr(type_class, "Master") == NULL) && (strstr(type_class, "master") == NULL)
|
|
|
&& (strstr(type_class, "BOM") == NULL) && (strstr(type_class, "bom") == NULL) && (strstr(type_class, "Bom") == NULL))
|
|
|
{
|
|
|
//获得数据集
|
|
|
tag_t relation_type = NULLTAG;
|
|
|
//tag_t attach_relation_type = NULLTAG;
|
|
|
ITKCALL(GRM_find_relation_type(TC_specification_rtype, &relation_type));
|
|
|
tag_t* secondary_objects = NULLTAG;
|
|
|
int ds_count = 0;
|
|
|
char* dataset_type = NULL, * desc_value = NULL, * file_path = NULL, * desc_path;
|
|
|
|
|
|
ITKCALL(GRM_list_secondary_objects_only(itemrevision, relation_type, &ds_count, &secondary_objects));
|
|
|
for (int j = 0; j < ds_count; j++)
|
|
|
{
|
|
|
int des_count = 0;
|
|
|
tag_t* dess = NULL;
|
|
|
tag_t des = NULL;
|
|
|
char* size = NULL;
|
|
|
ITKCALL(AOM_ask_value_tags(secondary_objects[j], "ref_list", &des_count, &dess));
|
|
|
if (des_count < 1) {
|
|
|
printf("该数据集引用数量错误\n");
|
|
|
ITKCALL(ifail = EMH_store_error_s1(EMH_severity_information, ITK_err, ("该数据集引用数量错误,无引用文件!!")));//错误弹窗
|
|
|
continue;
|
|
|
}
|
|
|
for (int h = 0; h < des_count; h++) {
|
|
|
des = dess[h];
|
|
|
ITKCALL(ifail = AOM_ask_value_string(des, "file_size", &size));
|
|
|
if (strcmp(size, "0 bytes") != 0) {
|
|
|
ITKCALL(ifail = EMH_store_error_s1(EMH_severity_information, ITK_err, ("该数据集大小错误,引用错误!!")));//错误弹窗
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//关旁路
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
printf("===================================\n");
|
|
|
printf("检查流程目标对象下数据集的大小 结束\n");
|
|
|
printf("===================================\n");
|
|
|
return ifail;
|
|
|
}
|