|
|
#include "connor_handler.h"
|
|
|
#include "stdafx.h"
|
|
|
#include "ae/dataset.h"
|
|
|
#include "sa/sa.h"
|
|
|
#include <tc\preferences.h>
|
|
|
#include <ae/datasettype.h>
|
|
|
#include <sa/tcfile.h>
|
|
|
#include<assert.h>
|
|
|
#include<stdio.h>
|
|
|
#include<string.h>
|
|
|
#include "sjjjy.h"
|
|
|
#include <vector>
|
|
|
#include <res/reservation.h>
|
|
|
#include <form/form.h>
|
|
|
#include <vcruntime_string.h>
|
|
|
#include <stdio.h>
|
|
|
#include <string.h>
|
|
|
#include <ctype.h>
|
|
|
#include <curl/curl.h>
|
|
|
#include <stdio.h>
|
|
|
#include <string.h>
|
|
|
#include <stdlib.h>
|
|
|
#ifdef WIN32
|
|
|
#include <io.h>
|
|
|
#include <direct.h>
|
|
|
#include <fstream>
|
|
|
#include <iostream>
|
|
|
#else
|
|
|
#include <unistd.h>
|
|
|
#endif
|
|
|
|
|
|
|
|
|
#include "tc_log.h"
|
|
|
#define ITK_err 919821
|
|
|
|
|
|
|
|
|
extern "C" int POM_AM__set_application_bypass(logical bypass);
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
string getNum(int num) {
|
|
|
char str[3] = "";
|
|
|
sprintf(str, "%02d", num);
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
string getNow(char* format) {
|
|
|
time_t now = time(NULL);
|
|
|
tm* tm_t = localtime(&now);
|
|
|
string str = "";
|
|
|
if (tc_strcmp(format, "yyyyMMdd") == 0) {
|
|
|
str.append(to_string(tm_t->tm_year + 1900)).append(getNum(tm_t->tm_mon + 1)).append(getNum(tm_t->tm_mday));
|
|
|
}
|
|
|
else if (tc_strcmp(format, "LOG") == 0) {//yyyy-MM-dd HH:mi:ss
|
|
|
str.append(to_string(tm_t->tm_year + 1900)).append("-")
|
|
|
.append(getNum(tm_t->tm_mon + 1)).append("-")
|
|
|
.append(getNum(tm_t->tm_mday)).append(" ")
|
|
|
.append(getNum(tm_t->tm_hour)).append(":")
|
|
|
.append(getNum(tm_t->tm_min)).append(":")
|
|
|
.append(getNum(tm_t->tm_sec));
|
|
|
}
|
|
|
return str;
|
|
|
}
|
|
|
/**
|
|
|
*判断某个对象是否是类或者子类
|
|
|
*objtag 要判断的对象
|
|
|
*type_name 类型的名称
|
|
|
*/
|
|
|
int checkIsTypeOrSubtype2(tag_t objtag, char * type_name) {
|
|
|
//printf("判断是否是%s及其子类\n", type_name);
|
|
|
tag_t type = NULLTAG;
|
|
|
ITKCALL(TCTYPE_ask_object_type(objtag, &type));
|
|
|
tag_t item_type = NULLTAG;
|
|
|
ITKCALL(TCTYPE_find_type(type_name, "", &item_type));
|
|
|
int is_type = 0;
|
|
|
if (item_type != NULLTAG) {
|
|
|
//printf("找到%s类\n", type_name);
|
|
|
logical isok = FALSE;
|
|
|
ITKCALL(TCTYPE_is_type_of(type, item_type, &isok));
|
|
|
if (isok) {
|
|
|
//printf("是%s类及其子类\n", type_name);
|
|
|
is_type = 1;
|
|
|
}
|
|
|
else {
|
|
|
//printf("不是%s类及其子类\n", type_name);
|
|
|
is_type = 0;
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
//printf("没有找到%s类\n", type_name);
|
|
|
}
|
|
|
return is_type;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*vector<string> 去重
|
|
|
*/
|
|
|
void DeleteDuplicated(vector<string> &name)
|
|
|
{
|
|
|
sort(name.begin(), name.end());
|
|
|
name.erase(unique(name.begin(), name.end()), name.end());
|
|
|
}
|
|
|
|
|
|
int LB2_Check_WJBH(EPM_action_message_t msg) {
|
|
|
int att_cnt = 0, *arg_num = NULL; // att_cnt:选中的对象的数量
|
|
|
tag_t task = NULLTAG, rootTask_tag = NULLTAG, *attachments = NULL;
|
|
|
char *arg = NULL, *argflag = NULL, **argvalue = NULL;
|
|
|
char type[128] = "", name[128] = "";
|
|
|
char *str = "MEProcessRevision";
|
|
|
|
|
|
char *sType = NULL;
|
|
|
|
|
|
tag_t type_tag = NULLTAG;
|
|
|
task = msg.task;
|
|
|
|
|
|
char message[2048] = "\0"; // 报错信息
|
|
|
int flag = 0; // 用于标记是否有重复的
|
|
|
|
|
|
// 调用查询构建器,第一步获取查询构建器对象
|
|
|
tag_t query_tag1 = NULLTAG;
|
|
|
ITKCALL(QRY_find2("工艺文件查询", &query_tag1));
|
|
|
tag_t query_tag2 = NULLTAG;
|
|
|
ITKCALL(QRY_find2("工艺查询", &query_tag2));
|
|
|
tag_t query_tag3 = NULLTAG;
|
|
|
ITKCALL(QRY_find2("工序查询", &query_tag3));
|
|
|
|
|
|
if (query_tag1 == NULLTAG)
|
|
|
{
|
|
|
printf("未找到工艺文件查询\n");
|
|
|
return EPM_nogo;
|
|
|
}
|
|
|
if (query_tag2 == NULLTAG)
|
|
|
{
|
|
|
printf("未找到工艺查询\n");
|
|
|
return EPM_nogo;
|
|
|
}
|
|
|
if (query_tag3 == NULLTAG)
|
|
|
{
|
|
|
printf("未找到工序查询\n");
|
|
|
return EPM_nogo;
|
|
|
}
|
|
|
|
|
|
|
|
|
ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
|
|
|
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
|
|
|
|
|
POM_AM__set_application_bypass(true); // 开旁路
|
|
|
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t rev_tag = attachments[i];
|
|
|
char* obj_str = NULL; // 对象名称
|
|
|
ITKCALL(AOM_ask_value_string(rev_tag, "object_string", &obj_str));
|
|
|
printf("当前对象是:%s\n", obj_str);
|
|
|
//char* obj_id = NULL; // 对象id
|
|
|
//ITKCALL(AOM_ask_value_string(rev_tag, "item_id", &obj_id));
|
|
|
|
|
|
vector < string > vec;
|
|
|
char *gxkbh[99]; // 对象的"lb2_gxkbh"的数组属性值
|
|
|
int index = 0;
|
|
|
//ITKCALL(AOM_set_value_strings(rev_tag, "lb2_gxkbh", 1, ));
|
|
|
|
|
|
int sjj_num = 0; // 规范关系文件夹下的对象的数量
|
|
|
tag_t *sjj_obj = NULLTAG; // 规范关系文件夹下的对象
|
|
|
|
|
|
if (checkIsTypeOrSubtype2(attachments[i], "MEOPRevision") ||
|
|
|
checkIsTypeOrSubtype2(attachments[i], "MEProcessRevision") ) {
|
|
|
printf("当前为工艺版本或工序版本\n");
|
|
|
// IMAN_specification 规范关系文件夹
|
|
|
ITKCALL(AOM_ask_value_tags(rev_tag, "IMAN_specification", &sjj_num, &sjj_obj));
|
|
|
// 遍历文件夹下每一个对象,找出符合条件的对象
|
|
|
for (int j = 0; j < sjj_num; j++)
|
|
|
{
|
|
|
char* sjj_type = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(sjj_obj[j], "object_type", &sjj_type));
|
|
|
printf("当前数据集类型是:%s\n", sjj_type);
|
|
|
//char* sjj_id = NULL;
|
|
|
//ITKCALL(AOM_ask_value_string(sjj_obj[j], "item_id", &sjj_id));
|
|
|
// 如果是符合条件的数据集对象,则开始进行属性覆盖
|
|
|
if (strcmp(sjj_type, "MSExcelX") == 0 || strcmp(sjj_type, "LB2_CAD") == 0)
|
|
|
{
|
|
|
char *lb2_gxkbh = NULL;
|
|
|
// 先获取该数据集下的指定属性的值
|
|
|
ITKCALL(AOM_ask_value_string(sjj_obj[j], "lb2_gxkbh", &lb2_gxkbh));
|
|
|
|
|
|
// 不为空的值才填进去
|
|
|
if (strcmp(lb2_gxkbh, "") != 0)
|
|
|
{
|
|
|
// 给字符串数组赋值,最后此字符串数组将覆盖对象的lb2_gxkbh属性值
|
|
|
//gxkbh[index] = lb2_gxkbh;
|
|
|
//index++;
|
|
|
|
|
|
int bbq = 0;
|
|
|
|
|
|
if (vec.size() > 0 )
|
|
|
{
|
|
|
vector< string >::iterator itBegin = vec.begin(); // 起始迭代器
|
|
|
vector< string >::iterator itEnd = vec.end(); // 结束迭代器
|
|
|
|
|
|
while (itBegin != itEnd)
|
|
|
{
|
|
|
|
|
|
|
|
|
const char* p = (*itBegin).data();
|
|
|
//printf("vec里面有:%s,当前字符串是:%s\n", p, lb2_gxkbh);
|
|
|
if (strcmp(p, lb2_gxkbh) == 0)
|
|
|
{
|
|
|
bbq = 1;
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
itBegin++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if (bbq == 0)
|
|
|
{
|
|
|
vec.push_back(lb2_gxkbh);
|
|
|
|
|
|
// vec里面没有查重,有的话表明查过了
|
|
|
char **cxtjz = (char **)MEM_alloc(sizeof(char *) * 1); // 查询条件值
|
|
|
cxtjz[0] = lb2_gxkbh;
|
|
|
char **cxtj1 = (char **)MEM_alloc(sizeof(char *) * 1); // 查询条件s
|
|
|
char **cxtj2 = (char **)MEM_alloc(sizeof(char *) * 1);
|
|
|
char **cxtj3 = (char **)MEM_alloc(sizeof(char *) * 1);
|
|
|
cxtj1[0] = "工序卡编号";
|
|
|
cxtj2[0] = "工序卡编号";
|
|
|
cxtj3[0] = "工序卡编号";
|
|
|
|
|
|
// 调用查询构建器,第二步输入查询构建器对象,查询条件数量,查询条件,条件值,返回数量,返回值
|
|
|
int n1 = 0, n2 = 0, n3 = 0;
|
|
|
tag_t *results = NULLTAG;
|
|
|
ITKCALL(QRY_execute(query_tag1, 1, cxtj1, cxtjz, &n1, &results));
|
|
|
ITKCALL(QRY_execute(query_tag2, 1, cxtj2, cxtjz, &n2, &results));
|
|
|
ITKCALL(QRY_execute(query_tag3, 1, cxtj3, cxtjz, &n3, &results));
|
|
|
|
|
|
//printf("%s分别存在%d,%d,%d个\n", lb2_gxkbh, n1, n2, n3);
|
|
|
//printf("%s\n", message);
|
|
|
|
|
|
// 如果其中有一个大于1,则记为重复
|
|
|
if (n1>1 || n2>1 || n3>1)
|
|
|
{
|
|
|
strcat(message, obj_str); // 报错信息
|
|
|
strcat(message, "存在文件编号"); // 报错信息
|
|
|
strcat(message, lb2_gxkbh); // 报错信息
|
|
|
strcat(message, "重复;"); // 报错信息
|
|
|
flag = 1;
|
|
|
}
|
|
|
//printf("%s\n", message);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (checkIsTypeOrSubtype2(attachments[i], "LB2_GYWDRevision")) {
|
|
|
// IMAN_specification 规范关系文件夹
|
|
|
ITKCALL(AOM_ask_value_tags(rev_tag, "LB2_FMWJ", &sjj_num, &sjj_obj));
|
|
|
// 遍历文件夹下每一个对象,找出符合条件的对象
|
|
|
for (int j = 0; j < sjj_num; j++)
|
|
|
{
|
|
|
char* sjj_type = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(sjj_obj[j], "object_type", &sjj_type));
|
|
|
//char* sjj_id = NULL;
|
|
|
//ITKCALL(AOM_ask_value_string(sjj_obj[j], "item_id", &sjj_id));
|
|
|
// 如果是符合条件的数据集对象,则开始进行属性覆盖
|
|
|
if (strcmp(sjj_type, "MSExcelX") == 0 || strcmp(sjj_type, "LB2_CAD") == 0)
|
|
|
{
|
|
|
char *lb2_gxkbh = NULL;
|
|
|
// 先获取该数据集下的指定属性的值
|
|
|
ITKCALL(AOM_ask_value_string(sjj_obj[j], "lb2_gxkbh", &lb2_gxkbh));
|
|
|
|
|
|
// 不为空的值才填进去
|
|
|
if (strcmp(lb2_gxkbh, "") != 0)
|
|
|
{
|
|
|
// 给字符串数组赋值,最后此字符串数组将覆盖对象的lb2_gxkbh属性值
|
|
|
//gxkbh[index] = lb2_gxkbh;
|
|
|
//index++;
|
|
|
|
|
|
int bbq = 0;
|
|
|
|
|
|
if (vec.size() > 0 )
|
|
|
{
|
|
|
vector< string >::iterator itBegin = vec.begin(); // 起始迭代器
|
|
|
vector< string >::iterator itEnd = vec.end(); // 结束迭代器
|
|
|
|
|
|
while (itBegin != itEnd)
|
|
|
{
|
|
|
|
|
|
|
|
|
const char* p = (*itBegin).data();
|
|
|
if (strcmp(p, lb2_gxkbh) == 0)
|
|
|
{
|
|
|
bbq = 1;
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
itBegin++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (bbq == 0)
|
|
|
{
|
|
|
vec.push_back(lb2_gxkbh);
|
|
|
|
|
|
// vec里面没有才查重,有的话表明查过了
|
|
|
char **cxtjz = (char **)MEM_alloc(sizeof(char *) * 1); // 查询条件值
|
|
|
cxtjz[0] = lb2_gxkbh;
|
|
|
char **cxtj1 = (char **)MEM_alloc(sizeof(char *) * 1); // 查询条件s
|
|
|
char **cxtj2 = (char **)MEM_alloc(sizeof(char *) * 1);
|
|
|
char **cxtj3 = (char **)MEM_alloc(sizeof(char *) * 1);
|
|
|
cxtj1[0] = "工序卡编号";
|
|
|
cxtj2[0] = "工序卡编号";
|
|
|
cxtj3[0] = "工序卡编号";
|
|
|
|
|
|
// 调用查询构建器,第二步输入查询构建器对象,查询条件数量,查询条件,条件值,返回数量,返回值
|
|
|
int n1 = 0, n2 = 0, n3 = 0;
|
|
|
tag_t *results = NULLTAG;
|
|
|
ITKCALL(QRY_execute(query_tag1, 1, cxtj1, cxtjz, &n1, &results));
|
|
|
ITKCALL(QRY_execute(query_tag2, 1, cxtj2, cxtjz, &n2, &results));
|
|
|
ITKCALL(QRY_execute(query_tag3, 1, cxtj3, cxtjz, &n3, &results));
|
|
|
|
|
|
// 如果其中有一个大于1,则记为重复
|
|
|
if (n1>1 || n2>1 || n3>1)
|
|
|
{
|
|
|
printf("开始改变message\n");
|
|
|
strcat(message, obj_str); // 报错信息
|
|
|
strcat(message, "存在文件编号"); // 报错信息
|
|
|
strcat(message, lb2_gxkbh); // 报错信息
|
|
|
strcat(message, "重复;"); // 报错信息
|
|
|
flag = 1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 给对象的属性赋值
|
|
|
if (vec.size() > 0 )
|
|
|
{
|
|
|
//DeleteDuplicated(vec); // 先对数组去重
|
|
|
char** urls = (char **)MEM_alloc(sizeof(char *) * 1);
|
|
|
for (size_t i = 0; i < vec.size(); i++) {
|
|
|
urls[i] = (char*)vec[i].c_str();
|
|
|
}
|
|
|
tag_t items_tag = NULL;
|
|
|
ITKCALL(AOM_ask_value_tag(rev_tag, "items_tag", &items_tag));
|
|
|
char * stt = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(items_tag, "object_string", &stt));
|
|
|
AOM_lock(items_tag);
|
|
|
|
|
|
ITKCALL(AOM_set_value_strings(items_tag, "lb2_gxkbh", vec.size(), urls));
|
|
|
AOM_save(items_tag);
|
|
|
AOM_unlock(items_tag);
|
|
|
|
|
|
AOM_refresh(items_tag, false);
|
|
|
|
|
|
|
|
|
// print
|
|
|
for (size_t j = 0; j < vec.size(); j++) {
|
|
|
// 移动 char* 指针
|
|
|
printf("%s\n", urls[j]);
|
|
|
printf("-----------------------分割线-------------\n");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
POM_AM__set_application_bypass(false); // 关旁路
|
|
|
|
|
|
// 说明包含重复值,弹窗报错
|
|
|
if (flag ==1)
|
|
|
{
|
|
|
//POM_AM__set_application_bypass(false); // 关旁路
|
|
|
printf("开始报错\n");
|
|
|
//EMH_store_error_s1(EMH_severity_information, EMH_USER_error_base, message);
|
|
|
|
|
|
EMH_store_error_s1(EMH_severity_error, EMH_USER_error_base, message);
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
|
|
|
int import_dataset_file_binary(tag_t dataset, const char* temp_path, const char* ref_name, char* ext, char* fullfilename, char* original_name)
|
|
|
{
|
|
|
int ifail = ITK_ok;
|
|
|
tag_t new_file_tag = NULLTAG;
|
|
|
IMF_file_t file_descriptor = NULL;
|
|
|
AOM_refresh(dataset, FALSE);
|
|
|
char* new_file_name = NULL;
|
|
|
char new_ds_name[WSO_name_size_c + 1] = "";
|
|
|
char* filename = NULL;
|
|
|
new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
|
|
|
filename = strrchr(fullfilename, '\\') + 1;
|
|
|
if (filename == NULL)
|
|
|
return ITK_ok;
|
|
|
ITKCALL(ifail = IMF_import_file(fullfilename, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor));
|
|
|
|
|
|
if (new_file_tag == NULL) {
|
|
|
printf("创建失败\n");
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
ITKCALL(ifail = IMF_set_original_file_name2(new_file_tag, original_name));
|
|
|
|
|
|
ITKCALL(ifail = IMF_close_file(file_descriptor));
|
|
|
ITKCALL(ifail = AOM_save(new_file_tag));
|
|
|
AOM_unlock(new_file_tag);
|
|
|
ITKCALL(ifail = AOM_refresh(new_file_tag, FALSE));
|
|
|
//添加至命名引用
|
|
|
ITKCALL(ifail = AOM_lock(dataset));
|
|
|
if (ifail != ITK_ok) { return ifail; }
|
|
|
ITKCALL(ifail = RES_checkout2(dataset, "import file", NULL, temp_path, 2));
|
|
|
if (ifail != ITK_ok) { return ifail; }
|
|
|
ITKCALL(ifail = AE_remove_dataset_named_ref2(dataset, ref_name));
|
|
|
if (ifail != ITK_ok) { return ifail; }
|
|
|
ITKCALL(ifail = AOM_save(dataset));
|
|
|
ITKCALL(ifail = AE_add_dataset_named_ref2(dataset, ref_name, AE_PART_OF, new_file_tag));
|
|
|
AOM_save(dataset);
|
|
|
ITKCALL(ifail = RES_checkin(dataset));
|
|
|
AOM_unlock(dataset);
|
|
|
//ITKCALL( AOM_refresh( dataset, FALSE ) );
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
string GbkToUtf8(const char *src_str) {
|
|
|
int len = MultiByteToWideChar(CP_ACP, 0, src_str, -1, NULL, 0);
|
|
|
wchar_t* wstr = new wchar_t[len + 1];
|
|
|
memset(wstr, 0, len + 1);
|
|
|
MultiByteToWideChar(CP_ACP, 0, src_str, -1, wstr, len);
|
|
|
len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
|
|
|
char* str = new char[len + 1];
|
|
|
memset(str, 0, len + 1);
|
|
|
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);
|
|
|
string strTemp = str;
|
|
|
if (wstr) delete[] wstr;
|
|
|
if (str) delete[] str;
|
|
|
return strTemp;
|
|
|
}
|
|
|
|
|
|
string Utf8ToGbk(const char *src_str) {
|
|
|
int len = MultiByteToWideChar(CP_UTF8, 0, src_str, -1, NULL, 0);
|
|
|
wchar_t* wszGBK = new wchar_t[len + 1];
|
|
|
memset(wszGBK, 0, len * 2 + 2);
|
|
|
MultiByteToWideChar(CP_UTF8, 0, src_str, -1, wszGBK, len);
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, NULL, 0, NULL, NULL);
|
|
|
char* szGBK = new char[len + 1];
|
|
|
memset(szGBK, 0, len + 1);
|
|
|
WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, szGBK, len, NULL, NULL);
|
|
|
string strTemp(szGBK);
|
|
|
if (wszGBK) delete[] wszGBK;
|
|
|
if (szGBK) delete[] szGBK;
|
|
|
return strTemp;
|
|
|
}
|
|
|
|
|
|
void delchar(char* str, char c)
|
|
|
{
|
|
|
int i = 0;//str[i]表示原来的字符串
|
|
|
int j = 0;//str[j]表示删除指定字符后的字符串
|
|
|
while (str[i] != '\0')
|
|
|
{
|
|
|
//刚开始指针指向原字符串的首元素地址
|
|
|
//当指针所指向的字符不是我们要删除的字符串时
|
|
|
//才能让str的空间地址,或者说str所指向的字符等于对应的字符
|
|
|
if (str[i] != c)
|
|
|
{
|
|
|
str[j++] = str[i];//str[j++]也是一直往后走的
|
|
|
}
|
|
|
//str[i]依次判断是否为要删除的指定字符,不是就赋给str[j]
|
|
|
i++;
|
|
|
}
|
|
|
//最后一步,将'\0'赋上
|
|
|
str[j] = str[i];
|
|
|
}
|
|
|
|
|
|
|
|
|
void Split(string strArg, string spliter, vector<string> &ans)
|
|
|
{
|
|
|
ans.clear();
|
|
|
size_t index0 = 0;
|
|
|
string one_arg;
|
|
|
if (strArg.find_first_not_of(' ') == string::npos)
|
|
|
strArg = "";
|
|
|
while (strArg.size() > 0)
|
|
|
{
|
|
|
index0 = strArg.find_first_of(spliter);
|
|
|
if (index0 != string::npos)
|
|
|
{
|
|
|
one_arg = strArg.substr(0, index0);
|
|
|
strArg = strArg.substr(index0 + 1);
|
|
|
ans.push_back(one_arg);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ans.push_back(strArg);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
char *remove_suffix(char *file) {
|
|
|
char *last_dot = strrchr(file, '.');
|
|
|
if (last_dot != NULL && strrchr(file, '\\') < last_dot)
|
|
|
*last_dot = '\0';
|
|
|
return file;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int TransToPDF(void *returnValue) {
|
|
|
char * messageUser = NULL, *sType = NULL;
|
|
|
tag_t rev = NULLTAG, task = NULLTAG, *doc_tags = NULLTAG;
|
|
|
int doc_num = 0, spec_num = 0;
|
|
|
|
|
|
string log_path = "";// getenv("temp");
|
|
|
log_path.append("D:\\Siemens\\PDFTransLogs\\").append(getNow("yyyyMMdd")).append(".log");
|
|
|
CreateLogFile(log_path.c_str());
|
|
|
|
|
|
USERARG_get_string_argument(&messageUser);
|
|
|
ITK__convert_uid_to_tag(messageUser, &rev);
|
|
|
char *os = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(rev, "object_string", &os));
|
|
|
WriteLog("%s 开始执行转换 %s", getNow("LOG"), os);
|
|
|
ITKCALL(AOM_ask_value_tags(rev, "IMAN_specification", &spec_num, &doc_tags));
|
|
|
for (int i = 0; i < spec_num; i++)
|
|
|
{
|
|
|
char *type = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &type));
|
|
|
if (strcmp(type, "MSWordX") == 0) {
|
|
|
char *name = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_name", &name));
|
|
|
char f = name[0];
|
|
|
if (f > 47 && f < 58) {
|
|
|
doc_num = 2;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (spec_num > 0)
|
|
|
{
|
|
|
WriteLog("开始执行文件");
|
|
|
for (int i = 0; i < spec_num; i++)
|
|
|
{
|
|
|
char *type = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &type));
|
|
|
if (strcmp(type, "MSWordX") == 0)
|
|
|
{
|
|
|
char *name = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_name", &name));
|
|
|
if (doc_num > 1) {
|
|
|
char f = name[0];
|
|
|
if (f < 48 || f > 57) {
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
WriteLog("type=%s\n", type);
|
|
|
tag_t spec_dataset_rev = NULLTAG, ref_object = NULLTAG;
|
|
|
AE_reference_type_t reference_type;
|
|
|
ITKCALL(AE_ask_dataset_latest_rev(doc_tags[i], &spec_dataset_rev));
|
|
|
char ref_name[WSO_name_size_c + 1] = "word";
|
|
|
ITKCALL(AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object));
|
|
|
WriteLog("开始判断type");
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
char *pathname = NULL;
|
|
|
ITKCALL(IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname));
|
|
|
char *origin_file_name = NULL;
|
|
|
ITKCALL(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, "docx", 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);
|
|
|
ITKCALL(IMF_export_file(ref_object, temp_file));
|
|
|
WriteLog("开始执行cmd方法");
|
|
|
char cmd[256] = "";
|
|
|
strcpy(cmd, "D:\\Siemens\\Teamcenter12\\portal\\plugins\\plug\\SubstMacros-MSWord.wsf");
|
|
|
strcat(cmd, " \"");
|
|
|
strcat(cmd, temp_file);
|
|
|
strcat(cmd, "\" ");
|
|
|
strcat(cmd, "D:\\Siemens\\Teamcenter12\\bin\\PDF.config.txt");
|
|
|
strcat(cmd, " D:\\11.pdf");
|
|
|
WriteLog("\n%s\n", cmd);
|
|
|
system(cmd);
|
|
|
WriteLog("cmd执行完毕");
|
|
|
tag_t *word_tags = NULLTAG;
|
|
|
int word_num = NULL;
|
|
|
ITKCALL(AOM_ask_value_tags(rev, "IMAN_Rendering", &word_num, &word_tags));
|
|
|
tag_t pdf = NULLTAG;
|
|
|
for (int n = 0; n < word_num; n++) {
|
|
|
char *type2 = NULL;
|
|
|
char *pdfname = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(word_tags[n], "object_type", &type2));
|
|
|
//string newtype = Utf8ToGbk(type2);
|
|
|
//type2 = (char*)newtype.data();
|
|
|
WriteLog("type值为%s:", type2);
|
|
|
|
|
|
ITKCALL(AOM_ask_value_string(word_tags[n], "object_name", &pdfname));
|
|
|
char *name1 = NULL;
|
|
|
char *name2 = NULL;
|
|
|
name1 = remove_suffix(pdfname);
|
|
|
name2 = remove_suffix(name);
|
|
|
if (strcmp(type2, "PDF") == 0) {
|
|
|
if (strcmp(name1, name2) == 0) {
|
|
|
pdf = word_tags[n];
|
|
|
break;
|
|
|
}
|
|
|
else {
|
|
|
//ITKCALL(AOM_delete_from_parent(word_tags[n], rev));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (pdf == NULLTAG) {
|
|
|
WriteLog("没有找到PDF数据集,开始进行创建 %s\n", name);
|
|
|
int rfCount;
|
|
|
tag_t pdfTypeTag = NULLTAG, tool = NULLTAG, relationTag, *rfTags, newrelation;
|
|
|
|
|
|
ITKCALL(AE_find_datasettype2("PDF", &pdfTypeTag));
|
|
|
ITKCALL(AE_create_dataset_with_id(pdfTypeTag, name, "", "", "A", &pdf));
|
|
|
ITKCALL(AE_ask_datasettype_def_tool(pdfTypeTag, &tool));
|
|
|
ITKCALL(AE_set_dataset_tool(pdf, tool));
|
|
|
ITKCALL(AE_set_dataset_format2(pdf, "PDF_Reference"));
|
|
|
ITKCALL(AOM_save(pdf));
|
|
|
if (pdf == NULLTAG) {
|
|
|
WriteLog("创建失败\n");
|
|
|
}
|
|
|
else {
|
|
|
WriteLog("创建成功\n");
|
|
|
ITKCALL(GRM_find_relation_type("IMAN_Rendering", &relationTag));
|
|
|
if (relationTag == NULLTAG) {
|
|
|
WriteLog("1111111111111111111111111111111");
|
|
|
}
|
|
|
ITKCALL(GRM_list_secondary_objects_only(rev, relationTag, &rfCount, &rfTags));
|
|
|
ITKCALL(GRM_create_relation(rev, pdf, relationTag, NULLTAG, &newrelation));
|
|
|
ITKCALL(GRM_save_relation(newrelation));
|
|
|
ITKCALL(AOM_unload(rev));
|
|
|
ITKCALL(AOM_refresh(rev, true));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (pdf != NULL) {
|
|
|
WriteLog("已经存在PDF数据集,开始进行创建 %s\n", name);
|
|
|
/*ITKCALL(import_dataset_file_binary(pdf, "/tmp/", "PDF_Reference", "pdf", "D:\\11.pdf", strcat(name, ".pdf")));
|
|
|
tag_t new_file_tag = NULLTAG;
|
|
|
IMF_file_t file_descriptor;
|
|
|
char failname[SS_MAXPATHLEN] = "";
|
|
|
strcat(failname, name);
|
|
|
strcat(failname, ".pdf");
|
|
|
ifstream f(failname);
|
|
|
if (f.good()) {
|
|
|
WriteLog("remove: %s\n", failname);
|
|
|
remove(failname);
|
|
|
}
|
|
|
ITKCALL(IMF_import_file("D:\\11.pdf", failname, SS_BINARY, &new_file_tag, &file_descriptor));
|
|
|
ITKCALL(IMF_set_original_file_name2(new_file_tag, name));
|
|
|
ITKCALL(IMF_close_file(file_descriptor));
|
|
|
ITKCALL(AOM_save(new_file_tag));
|
|
|
ITKCALL(AOM_unlock(new_file_tag));
|
|
|
//WriteLog("complete import file \n");
|
|
|
ITKCALL(AOM_lock(pdf));
|
|
|
//ITKCALL(AE_remove_dataset_named_ref_by_tag2(pdf, "PDF_Reference", ref_object));
|
|
|
ITKCALL(AE_remove_dataset_named_ref2(pdf, "PDF_Reference"));
|
|
|
//ITKCALL(AE_replace_dataset_named_ref(spec_dataset_rev,ref_object,ref_name,AE_PART_OF,new_file_tag));
|
|
|
ITKCALL(AE_add_dataset_named_ref2(pdf, "PDF_Reference", AE_PART_OF, new_file_tag));*/
|
|
|
ITKCALL(import_dataset_file_binary(pdf, "/tmp/", "PDF_Reference", "pdf", "D:\\11.pdf", strcat(name, ".pdf")));
|
|
|
ITKCALL(AOM_save(pdf));
|
|
|
ITKCALL(AOM_unlock(pdf));
|
|
|
|
|
|
ITKCALL(remove("D:\\11.pdf"));
|
|
|
WriteLog("删除成功");
|
|
|
}
|
|
|
else {
|
|
|
WriteLog("当前版本下没有IMAN_Rendering文件夹");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (strcmp(type, "MSExcelX") == 0) {
|
|
|
if (doc_num > 1) {
|
|
|
char *name = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_name", &name));
|
|
|
char f = name[0];
|
|
|
if (f < 48 || f > 57) {
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
WriteLog("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 ref_name[WSO_name_size_c + 1] = "excel";
|
|
|
AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object);
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
char *pathname = NULL;
|
|
|
ITKCALL(IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname));
|
|
|
char *origin_file_name = NULL;
|
|
|
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, "xlsx", 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);
|
|
|
char *name = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_name", &name));
|
|
|
char cmd[256] = "";
|
|
|
strcpy(cmd, "D:\\Siemens\\Teamcenter12\\portal\\plugins\\plug\\SubstMacros-MSExcel.wsf");
|
|
|
strcat(cmd, " \"");
|
|
|
strcat(cmd, temp_file);
|
|
|
strcat(cmd, "\" ");
|
|
|
strcat(cmd, "D:\\Siemens\\Teamcenter12\\bin\\PDF.config.txt");
|
|
|
strcat(cmd, " D:\\11.pdf");
|
|
|
WriteLog("\n%s\n", cmd);
|
|
|
system(cmd);
|
|
|
WriteLog("cmd执行完毕");
|
|
|
tag_t *word_tags = NULLTAG;
|
|
|
int word_num = NULL;
|
|
|
ITKCALL(AOM_ask_value_tags(rev, "IMAN_Rendering", &word_num, &word_tags));
|
|
|
tag_t pdf = NULLTAG;
|
|
|
for (int n = 0; n < word_num; n++) {
|
|
|
char *type2 = NULL;
|
|
|
char *pdfname = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(word_tags[n], "object_type", &type2));
|
|
|
ITKCALL(AOM_ask_value_string(word_tags[n], "object_name", &pdfname));
|
|
|
char *name1 = NULL;
|
|
|
char *name2 = NULL;
|
|
|
name1 = remove_suffix(pdfname);
|
|
|
name2 = remove_suffix(name);
|
|
|
if (strcmp(type2, "PDF") == 0 && strcmp(name1, name2) == 0) {
|
|
|
pdf = word_tags[n];
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (pdf == NULLTAG) {
|
|
|
WriteLog("没有找到PDF数据集,开始进行创建\n", name);
|
|
|
int rfCount;
|
|
|
tag_t pdfTypeTag = NULLTAG, tool = NULLTAG, relationTag, *rfTags, newrelation;
|
|
|
|
|
|
ITKCALL(AE_find_datasettype2("PDF", &pdfTypeTag));
|
|
|
ITKCALL(AE_create_dataset_with_id(pdfTypeTag, name, "", "", "A", &pdf));
|
|
|
ITKCALL(AE_ask_datasettype_def_tool(pdfTypeTag, &tool));
|
|
|
ITKCALL(AE_set_dataset_tool(pdf, tool));
|
|
|
ITKCALL(AE_set_dataset_format2(pdf, "PDF_Reference"));
|
|
|
ITKCALL(AOM_save(pdf));
|
|
|
if (pdf == NULLTAG) {
|
|
|
WriteLog("创建失败\n");
|
|
|
}
|
|
|
else {
|
|
|
WriteLog("创建成功\n");
|
|
|
POM_AM__set_application_bypass(true); // 开旁路
|
|
|
ITKCALL(GRM_find_relation_type("IMAN_Rendering", &relationTag));
|
|
|
if (relationTag == NULLTAG) {
|
|
|
WriteLog("1111111111111111111");
|
|
|
}
|
|
|
ITKCALL(GRM_list_secondary_objects_only(rev, relationTag, &rfCount, &rfTags));
|
|
|
ITKCALL(GRM_create_relation(rev, pdf, relationTag, NULLTAG, &newrelation));
|
|
|
ITKCALL(GRM_save_relation(newrelation));
|
|
|
ITKCALL(AOM_unload(rev));
|
|
|
ITKCALL(AOM_refresh(rev, true));
|
|
|
POM_AM__set_application_bypass(false); // 关旁路
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (pdf != NULL) {
|
|
|
WriteLog("已经存在PDF数据集,开始进行创建 %s\n", name);
|
|
|
import_dataset_file_binary(pdf, "/tmp/", "PDF_Reference", "pdf", "D:\\11.pdf", strcat(name, ".pdf"));
|
|
|
remove("D:\\11.pdf");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else {
|
|
|
WriteLog("没有找到文件");
|
|
|
}
|
|
|
//WriteLog("123456789");
|
|
|
WriteLog("——————转换完成——————");
|
|
|
CloseLog();
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
|
|
|
|
|
|
int Connor_AVIC_Check_XYSX(EPM_action_message_t msg) {
|
|
|
int att_cnt = 0;
|
|
|
int doc_num = 0;
|
|
|
tag_t rootTask_tag = NULLTAG;
|
|
|
tag_t task = NULLTAG;
|
|
|
tag_t *attachments = NULLTAG;
|
|
|
tag_t *doc_tags = NULLTAG;
|
|
|
string error;
|
|
|
char *arg = NULL, *argflag = NULL ,*argvalue = NULL;
|
|
|
int arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
char *Target = NULL, *Form = NULL, *CheckProperty = NULL;
|
|
|
task = msg.task;
|
|
|
ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
|
|
|
if (arg_cnt > 0)
|
|
|
{
|
|
|
for (int i = 0; i < arg_cnt; i++)
|
|
|
{
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
ITKCALL(ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue));
|
|
|
if (strcmp(argflag, "Target") == 0) {
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
printf("获取的Target值:%s\n", argvalue);
|
|
|
Target = argvalue;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
if (strcmp(argflag, "Form") == 0) {
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
printf("获取的Form值:%s\n", argvalue);
|
|
|
Form = argvalue;
|
|
|
}
|
|
|
}
|
|
|
if (strcmp(argflag, "CheckProperty") == 0) {
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
printf("获取的CheckProperty值:%s\n", argvalue);
|
|
|
CheckProperty = argvalue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (strcmp(Target, "target") == 0) {
|
|
|
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &doc_num, &doc_tags));
|
|
|
}
|
|
|
else if (strcmp(Target, "reference") == 0) {
|
|
|
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_reference_attachment, &doc_num, &doc_tags));
|
|
|
}
|
|
|
else {
|
|
|
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
|
|
ITKCALL(AOM_ask_value_tags(attachments[0], Target, &doc_num, &doc_tags));
|
|
|
}
|
|
|
if (doc_num > 0)
|
|
|
{
|
|
|
printf("开始执行\n");
|
|
|
for (int i = 0; i < doc_num; i++)
|
|
|
{
|
|
|
char *type = NULL;
|
|
|
AOM_refresh(doc_tags[i], FALSE);
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &type));
|
|
|
printf("目标对象type:%s\n",type);
|
|
|
if (strcmp(type, Form) == 0) {
|
|
|
char *value1 = NULL;
|
|
|
char *value2 = NULL;
|
|
|
printf("开始分割字符串:%s\n", CheckProperty);
|
|
|
vector<string> ans;
|
|
|
Split(CheckProperty, ";", ans);
|
|
|
if (ans.size() == 0) {
|
|
|
error = GbkToUtf8("流程属性值[CheckProperty]设置有误,请检查后操作!");
|
|
|
EMH_store_error_s1(EMH_severity_user_error, ITK_err, error.c_str());
|
|
|
return 1;
|
|
|
}
|
|
|
int count = 0;
|
|
|
for (int j = 0; j < ans.size(); j++) {
|
|
|
value1 = (char*)ans[j].c_str();
|
|
|
printf("value1:%s\n", value1);
|
|
|
vector<string> vec1;
|
|
|
char *key1 = NULL;
|
|
|
char *val1 = NULL;
|
|
|
char *getValue = NULL;
|
|
|
Split(value1, "=", vec1);
|
|
|
if (vec1.size() != 2 ) {
|
|
|
error = GbkToUtf8("流程属性值[CheckProperty]设置有误,请检查后操作!");
|
|
|
EMH_store_error_s1(EMH_severity_user_error, ITK_err, error.c_str());
|
|
|
return 1;
|
|
|
}
|
|
|
key1 = (char*)vec1[0].c_str();
|
|
|
val1 = (char*)vec1[1].c_str();
|
|
|
printf("key:%s\n", key1);
|
|
|
printf("value:%s\n", val1);
|
|
|
if (key1 == NULL || val1 == NULL) {
|
|
|
error = GbkToUtf8("流程属性值[CheckProperty]设置有误,请检查后操作!");
|
|
|
EMH_store_error_s1(EMH_severity_user_error, ITK_err, error.c_str());
|
|
|
return 1;
|
|
|
}
|
|
|
else {
|
|
|
AOM_refresh(doc_tags[i], FALSE);
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], key1, &getValue));
|
|
|
printf("getValue:%s\n", getValue);
|
|
|
if (strcmp(getValue, val1) == 0) {
|
|
|
count++;
|
|
|
}
|
|
|
else {
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
printf("count:%d\s", count);
|
|
|
printf("ans.size():%d\s", ans.size());
|
|
|
if (count == ans.size()) {
|
|
|
error = GbkToUtf8("BOM中存在限用物料,请在表单中确认是否通过!");
|
|
|
EMH_store_error_s1(EMH_severity_user_error, ITK_err, error.c_str());
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
error = GbkToUtf8("流程关系下没有对应文件");
|
|
|
EMH_store_error_s1(EMH_severity_user_error, ITK_err, error.c_str());
|
|
|
return 1;
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Connor_AVIC_Set_Property(EPM_action_message_t msg) {
|
|
|
printf("开旁路.....\n");
|
|
|
POM_AM__set_application_bypass(true); // 开旁路
|
|
|
int att_cnt = 0;
|
|
|
int doc_num = 0;
|
|
|
tag_t rootTask_tag = NULLTAG;
|
|
|
tag_t task = NULLTAG;
|
|
|
tag_t *attachments = NULLTAG;
|
|
|
tag_t *doc_tags = NULLTAG;
|
|
|
logical isneed = false;
|
|
|
char *arg = NULL, *argflag = NULL ,*argvalue = NULL,
|
|
|
typeClass[TCTYPE_class_name_size_c + 1] = "\0";
|
|
|
int arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
char *Target = NULL, *Form = NULL, *CheckProperty = NULL;
|
|
|
task = msg.task;
|
|
|
ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
|
|
|
if (arg_cnt > 0)
|
|
|
{
|
|
|
for (int i = 0; i < arg_cnt; i++)
|
|
|
{
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
ITKCALL(ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue));
|
|
|
if (strcmp(argflag, "Target") == 0) {
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
printf("获取的值%s:", argvalue);
|
|
|
Target = argvalue;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
if (strcmp(argflag, "Form") == 0) {
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
printf("获取的值%s:", argvalue);
|
|
|
Form = argvalue;
|
|
|
}
|
|
|
}
|
|
|
if (strcmp(argflag, "CheckProperty") == 0) {
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
printf("获取的值%s:", argvalue);
|
|
|
CheckProperty = argvalue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (strcmp(Target, "target") == 0) {
|
|
|
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &doc_num, &doc_tags));
|
|
|
}
|
|
|
else if (strcmp(Target, "reference") == 0) {
|
|
|
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_reference_attachment, &doc_num, &doc_tags));
|
|
|
}
|
|
|
else {
|
|
|
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
|
|
ITKCALL(AOM_ask_value_tags(attachments[0], Target, &doc_num, &doc_tags));
|
|
|
}
|
|
|
|
|
|
|
|
|
if (doc_num > 0)
|
|
|
{
|
|
|
printf("开始执行");
|
|
|
for (int i = 0; i < doc_num; i++)
|
|
|
{
|
|
|
char *type = NULL;
|
|
|
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &type));
|
|
|
printf("type%s:",type);
|
|
|
if (strcmp(type, Form) == 0) {
|
|
|
char *key = NULL;
|
|
|
char *value = NULL;
|
|
|
printf("开始分割字符串");
|
|
|
vector<string> ans;
|
|
|
Split(CheckProperty,"=",ans);
|
|
|
if (ans.size()>1) {
|
|
|
key = (char*)ans[0].c_str();
|
|
|
value = (char*)ans[1].c_str();
|
|
|
printf("key%s:", key);
|
|
|
printf("value%s:", value);
|
|
|
if (key == NULL || value == NULL) {
|
|
|
EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", "流程属性值设置有误,请检查后操作!");
|
|
|
return 1;
|
|
|
}
|
|
|
else {
|
|
|
//ITKCALL(sscanf(CheckProperty, "%[^=]=%s", key, value));
|
|
|
AOM_lock(doc_tags[i]);
|
|
|
ITKCALL(AOM_set_value_string(doc_tags[i], key, value));
|
|
|
AOM_save(doc_tags[i]);
|
|
|
AOM_unlock(doc_tags[i]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
printf("关旁路.....\n");
|
|
|
POM_AM__set_application_bypass(false); // 关旁路
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
|
|
|
// 判断字符是否为中文字符
|
|
|
int isChineseChar(unsigned char c1, unsigned char c2, unsigned char c3) {
|
|
|
return (c1 >= 0xE0 && c1 <= 0xEF) && (c2 >= 0x80 && c2 <= 0xBF) && (c3 >= 0x80 && c3 <= 0xBF);
|
|
|
}
|
|
|
|
|
|
// 将字符串中的特殊字符替换为下划线
|
|
|
void replaceSpecialChars2(char* str) {
|
|
|
char* src = str;
|
|
|
char* dst = str;
|
|
|
while (*src) {
|
|
|
if (isalnum((unsigned char)*src) || *src == '_' || *src == '-') {
|
|
|
*dst++ = *src;
|
|
|
}
|
|
|
else if ((unsigned char)*src >= 0x80) { // 处理多字节字符(如中文)
|
|
|
if (isChineseChar((unsigned char)*src, (unsigned char)*(src + 1), (unsigned char)*(src + 2))) {
|
|
|
*dst++ = *src++;
|
|
|
*dst++ = *src++;
|
|
|
*dst++ = *src;
|
|
|
}
|
|
|
else {
|
|
|
*dst++ = '_';
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
*dst++ = '_';
|
|
|
}
|
|
|
src++;
|
|
|
}
|
|
|
*dst = '\0';
|
|
|
}
|
|
|
void replaceSpecialChars(char* str) {
|
|
|
char* src = str;
|
|
|
char* dst = str;
|
|
|
char* dotPos = strrchr(str, '.'); // 找到最后一个点号的位置
|
|
|
|
|
|
while (*src) {
|
|
|
if (dotPos && src >= dotPos) {
|
|
|
// 如果当前字符在点号之后,直接复制
|
|
|
*dst++ = *src;
|
|
|
}
|
|
|
else {
|
|
|
if (isalnum((unsigned char)*src) || *src == '_' || *src == '-') {
|
|
|
*dst++ = *src;
|
|
|
}
|
|
|
else if ((unsigned char)*src >= 0x80) { // 处理多字节字符(如中文)
|
|
|
if (isChineseChar((unsigned char)*src, (unsigned char)*(src + 1), (unsigned char)*(src + 2))) {
|
|
|
*dst++ = *src++;
|
|
|
*dst++ = *src++;
|
|
|
*dst++ = *src;
|
|
|
}
|
|
|
else {
|
|
|
*dst++ = '_';
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
*dst++ = '_';
|
|
|
}
|
|
|
}
|
|
|
src++;
|
|
|
}
|
|
|
*dst = '\0';
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define MAX_BUFFER_SIZE 10000
|
|
|
|
|
|
size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp) {
|
|
|
size_t totalSize = size * nmemb;
|
|
|
char* buffer = (char*)userp;
|
|
|
size_t currentLength = strlen(buffer);
|
|
|
|
|
|
// 检查剩余空间防止缓冲区溢出
|
|
|
if (currentLength + totalSize > MAX_BUFFER_SIZE) {
|
|
|
printf("Error: Response too large for buffer!\n");
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
// 追加内容到缓冲区
|
|
|
strncat(buffer, (char*)contents, totalSize - 1); // 减1是为了保留'\0'的位置
|
|
|
buffer[currentLength + totalSize - 1] = '\0'; // 添加结束符
|
|
|
|
|
|
return totalSize;
|
|
|
}
|
|
|
|
|
|
char* sendPostRequest(const char* jsonPayload, const char* url) {
|
|
|
CURL* curl;
|
|
|
CURLcode res;
|
|
|
char readBuffer[MAX_BUFFER_SIZE];
|
|
|
memset(readBuffer, 0, MAX_BUFFER_SIZE);
|
|
|
curl = curl_easy_init();
|
|
|
if (curl) {
|
|
|
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, url);
|
|
|
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
|
|
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
|
|
|
struct curl_slist* headers = NULL;
|
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, readBuffer);
|
|
|
|
|
|
headers = curl_slist_append(headers, "Content-Type: application/json");
|
|
|
headers = curl_slist_append(headers, "Cookie: JSESSIONID=64EF3E9DDE22D9A15B9586AC83E60F15");
|
|
|
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
|
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, jsonPayload);
|
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); // 禁止验证对端证书
|
|
|
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); // 禁止验证主机名
|
|
|
res = curl_easy_perform(curl);
|
|
|
|
|
|
if (res != CURLE_OK) {
|
|
|
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
curl_slist_free_all(headers);
|
|
|
curl_easy_cleanup(curl);
|
|
|
}
|
|
|
else {
|
|
|
printf("Failed to initialize curl.\n");
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
return readBuffer;
|
|
|
}
|
|
|
|
|
|
bool isFileEmpty(const std::string& filePath) {
|
|
|
std::FILE* file = std::fopen(filePath.c_str(), "rb");
|
|
|
if (!file) {
|
|
|
throw std::runtime_error("Failed to open file");
|
|
|
}
|
|
|
|
|
|
// Seek to the end of the file
|
|
|
if (std::fseek(file, 0, SEEK_END) != 0) {
|
|
|
std::fclose(file);
|
|
|
throw std::runtime_error("Failed to seek in file");
|
|
|
}
|
|
|
|
|
|
// Get the current position, which is now the end of the file
|
|
|
long fileSize = std::ftell(file);
|
|
|
|
|
|
std::fclose(file);
|
|
|
|
|
|
return fileSize == 0;
|
|
|
}
|
|
|
|
|
|
void checkAndRemoveFile(const std::string& path) {
|
|
|
// 尝试直接删除(假设是当前系统默认编码)
|
|
|
if (_access(path.c_str(), 0) != -1) {
|
|
|
if (remove(path.c_str()) == 0) {
|
|
|
std::cout << "文件删除成功: " << path << std::endl;
|
|
|
return; // 成功删除后直接返回
|
|
|
}
|
|
|
else {
|
|
|
perror("文件删除失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 尝试使用 GBK 编码的路径
|
|
|
std::string gbkPath = Utf8ToGbk(path.c_str());
|
|
|
if (_access(gbkPath.c_str(), 0) != -1) {
|
|
|
if (remove(gbkPath.c_str()) == 0) {
|
|
|
std::cout << "文件删除成功: " << gbkPath << std::endl;
|
|
|
return; // 成功删除后直接返回
|
|
|
}
|
|
|
else {
|
|
|
perror("文件删除失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 尝试将 GBK 转换为 UTF-8 并再次检查
|
|
|
std::string utf8Path = GbkToUtf8(path.c_str());
|
|
|
if (_access(utf8Path.c_str(), 0) != -1) {
|
|
|
if (remove(utf8Path.c_str()) == 0) {
|
|
|
std::cout << "文件删除成功: " << utf8Path << std::endl;
|
|
|
return; // 成功删除后直接返回
|
|
|
}
|
|
|
else {
|
|
|
perror("文件删除失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 文件不存在
|
|
|
std::cout << "文件不存在: " << path << std::endl;
|
|
|
}
|
|
|
|
|
|
int Connor_AVIC_TransToPDF(EPM_action_message_t mag) {
|
|
|
POM_AM__set_application_bypass(true); // 开旁路
|
|
|
int att_cnt = 0, * arg_num = NULL; // att_cnt:选中的对象的数量
|
|
|
int spec_num = 0, doc_num = 0;
|
|
|
tag_t task = NULLTAG, rootTask_tag = NULLTAG, * attachments = NULL, rev_class_id = NULLTAG;
|
|
|
tag_t* doc_tags = NULLTAG;
|
|
|
char* arg = NULL, * argflag = NULL, ** argvalue = NULL, * type = NULL;
|
|
|
char* str = "MEProcessRevision";
|
|
|
char* sType = NULL;
|
|
|
|
|
|
string log_path = "";// getenv("temp");
|
|
|
log_path.append("D:\\Siemens\\PDFTransLogs\\").append(getNow("yyyyMMdd")).append(".log");
|
|
|
CreateLogFile(log_path.c_str());
|
|
|
WriteLog("开始判断是否为版本");
|
|
|
ITKCALL(POM_class_id_of_class("ItemRevision", &rev_class_id));
|
|
|
tag_t type_tag = NULLTAG;
|
|
|
task = mag.task;
|
|
|
ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
|
|
|
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
|
|
if (att_cnt > 0) {
|
|
|
for (int a = 0; a < att_cnt; a++) {
|
|
|
logical answer = false;
|
|
|
tag_t sub_class_id = NULLTAG;
|
|
|
ITKCALL(POM_class_of_instance(attachments[a], &sub_class_id));
|
|
|
ITKCALL(POM_is_descendant(rev_class_id, sub_class_id, &answer));
|
|
|
if (!answer) {
|
|
|
continue;
|
|
|
}
|
|
|
WriteLog("获取规范关系");
|
|
|
ITKCALL(AOM_ask_value_tags(attachments[a], "IMAN_specification", &spec_num, &doc_tags));
|
|
|
|
|
|
char* os = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(attachments[a], "object_string", &os));
|
|
|
WriteLog("%s 开始执行转换 %s", getNow("LOG"), os);
|
|
|
WriteLog("循环规范关系");
|
|
|
vector<char*> filePaths;
|
|
|
char* uid;
|
|
|
POM_tag_to_uid(attachments[a], &uid);
|
|
|
if (spec_num == 0) {
|
|
|
continue;
|
|
|
}
|
|
|
for (int i = 0; i < spec_num; i++)
|
|
|
{
|
|
|
char* type = NULL;
|
|
|
char* documType = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &type));
|
|
|
|
|
|
if (strcmp(type, "MSWord") == 0 || strcmp(type, "MSWordX") == 0) {
|
|
|
documType = "word";
|
|
|
}
|
|
|
else if (strcmp(type, "MSExcelX") == 0 || strcmp(type, "MSExcel") == 0) {
|
|
|
documType = "excel";
|
|
|
}
|
|
|
else {
|
|
|
continue;
|
|
|
}
|
|
|
char* duid = NULL;
|
|
|
ITK__convert_tag_to_uid(doc_tags[i], &duid);
|
|
|
printf("uid:%s\n", duid);
|
|
|
|
|
|
char* lastName = NULL;
|
|
|
int refCount = 0;
|
|
|
tag_t* refTags;
|
|
|
//ITKCALL(ifail = AE_ask_dataset_named_ref2(doc_tags[i], ref_name, &reference_type, &ref_object));
|
|
|
ITKCALL(AOM_ask_value_tags(doc_tags[i], "ref_list", &refCount, &refTags));
|
|
|
if (refCount > 0) {
|
|
|
ITKCALL(AOM_ask_value_string(refTags[0], "original_file_name", &lastName));
|
|
|
replaceSpecialChars(lastName);
|
|
|
}
|
|
|
else {
|
|
|
printf("没有找到数据集\n");
|
|
|
continue;
|
|
|
}
|
|
|
char* ruid = NULL;
|
|
|
ITK__convert_tag_to_uid(refTags[0], &ruid);
|
|
|
printf("ruid:%s\n", ruid);
|
|
|
|
|
|
char sendname[SS_MAXPATHLEN] = "";
|
|
|
strcat(sendname, "D:/WORDEXCELFOLDER/");
|
|
|
strcat(sendname, lastName);
|
|
|
|
|
|
// 检查文件是否存在
|
|
|
checkAndRemoveFile(sendname);
|
|
|
|
|
|
|
|
|
tag_t ref_object = NULLTAG;
|
|
|
printf("1");
|
|
|
AE_reference_type_t reference_type;
|
|
|
printf("2");
|
|
|
//char ref_name[WSO_name_size_c + 1] = "excel";
|
|
|
ITKCALL(AE_ask_dataset_named_ref2(doc_tags[i], documType, &reference_type, &ref_object));
|
|
|
printf("3");
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
ITKCALL(IMF_export_file(ref_object, sendname));
|
|
|
// 创建新的字符串副本
|
|
|
char* newSendname = new char[strlen(sendname) + 1];
|
|
|
strcpy(newSendname, sendname);
|
|
|
|
|
|
filePaths.push_back(newSendname);
|
|
|
}
|
|
|
}
|
|
|
//构建json
|
|
|
std::string jsonPayload = "{ \"revId\": \"";
|
|
|
jsonPayload += uid;
|
|
|
jsonPayload += "\", \"filePaths\": [";
|
|
|
|
|
|
for (size_t b = 0; b < filePaths.size(); ++b) {
|
|
|
jsonPayload += "\"";
|
|
|
jsonPayload += filePaths[b];
|
|
|
jsonPayload += "\"";
|
|
|
if (b < filePaths.size() - 1) {
|
|
|
jsonPayload += ", ";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
jsonPayload += "] }";
|
|
|
|
|
|
printf("\njsonPayload:%s\n", jsonPayload.c_str());
|
|
|
|
|
|
//发送Post请求
|
|
|
const char* url = "http://127.0.0.1:13022/api/TransToPDFMQ";
|
|
|
char* response = sendPostRequest(jsonPayload.c_str(), url);
|
|
|
if (response) {
|
|
|
WriteLog("POST请求发送成功,响应: %s", response);
|
|
|
}
|
|
|
else {
|
|
|
WriteLog("POST请求发送失败");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
POM_AM__set_application_bypass(false); // 关旁路
|
|
|
WriteLog("——————转换完成——————");
|
|
|
CloseLog();
|
|
|
return ITK_ok;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Connor_AVIC_TransToPDF2(EPM_action_message_t mag) {
|
|
|
POM_AM__set_application_bypass(true); // 开旁路
|
|
|
int att_cnt = 0, *arg_num = NULL; // att_cnt:选中的对象的数量
|
|
|
int spec_num = NULL, doc_num = 0;
|
|
|
tag_t task = NULLTAG, rootTask_tag = NULLTAG, *attachments = NULL, rev_class_id = NULLTAG;
|
|
|
tag_t *doc_tags = NULLTAG;
|
|
|
char *arg = NULL, *argflag = NULL, **argvalue = NULL, *type = NULL;
|
|
|
char *str = "MEProcessRevision";
|
|
|
char *sType = NULL;
|
|
|
|
|
|
string log_path = "";// getenv("temp");
|
|
|
log_path.append("D:\\Siemens\\PDFTransLogs\\").append(getNow("yyyyMMdd")).append(".log");
|
|
|
CreateLogFile(log_path.c_str());
|
|
|
WriteLog("开始判断是否为版本");
|
|
|
ITKCALL(POM_class_id_of_class("ItemRevision", &rev_class_id));
|
|
|
tag_t type_tag = NULLTAG;
|
|
|
task = mag.task;
|
|
|
ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
|
|
|
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
|
|
if (att_cnt>0) {
|
|
|
for (int a = 0; a < att_cnt;a++) {
|
|
|
logical answer = false;
|
|
|
tag_t sub_class_id = NULLTAG;
|
|
|
ITKCALL(POM_class_of_instance(attachments[a], &sub_class_id));
|
|
|
ITKCALL(POM_is_descendant(rev_class_id, sub_class_id, &answer));
|
|
|
if (!answer) {
|
|
|
continue;
|
|
|
}
|
|
|
WriteLog("确认为版本对象,继续操作");
|
|
|
try {
|
|
|
WriteLog("获取规范关系");
|
|
|
ITKCALL(AOM_ask_value_tags(attachments[a], "IMAN_specification", &spec_num, &doc_tags));
|
|
|
}
|
|
|
catch(...){
|
|
|
continue;
|
|
|
}
|
|
|
char *os = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(attachments[a], "object_string", &os));
|
|
|
WriteLog("%s 开始执行转换 %s", getNow("LOG"), os);
|
|
|
WriteLog("循环规范关系");
|
|
|
for (int i = 0; i < spec_num; i++)
|
|
|
{
|
|
|
char *type = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &type));
|
|
|
WriteLog("判断数据集是否是MSWordX");
|
|
|
if (strcmp(type, "MSWordX") == 0) {
|
|
|
|
|
|
char *name = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_name", &name));
|
|
|
WriteLog("获取数据集名称是否以数字开头 %s", name);
|
|
|
char f = name[0];
|
|
|
if (f > 47 && f < 58) {
|
|
|
WriteLog("以数字开头");
|
|
|
doc_num = 2;
|
|
|
}
|
|
|
else {
|
|
|
WriteLog("不以数字开头");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//ITKCALL(AOM_ask_value_tags(attachments[0],"root_target_attachment", &doc_num, &doc_tags));
|
|
|
if (spec_num > 0)
|
|
|
{
|
|
|
WriteLog("开始执行文件");
|
|
|
for (int i = 0; i < spec_num; i++)
|
|
|
{
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &type));
|
|
|
WriteLog("获取为MSWordX开始执行");
|
|
|
if (strcmp(type, "MSWordX") == 0)
|
|
|
{
|
|
|
WriteLog("doc_num %d", doc_num);
|
|
|
WriteLog("判断名称是否以数字开头");
|
|
|
if (doc_num > 1) {
|
|
|
char *name = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_name", &name));
|
|
|
char f = name[0];
|
|
|
if (f < 48 || f > 57) {
|
|
|
WriteLog("名称不以数字开头直接退出当前循环");
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
//获取数据集的名称
|
|
|
char* lastName = NULL;
|
|
|
int refCount = 0;
|
|
|
tag_t* refTags;
|
|
|
ITKCALL(AOM_ask_value_tags(doc_tags[i], "ref_list", &refCount,&refTags));
|
|
|
if (refCount>0) {
|
|
|
ITKCALL(AOM_ask_value_string(refTags[0], "original_file_name", &lastName));
|
|
|
replaceSpecialChars(lastName);
|
|
|
}
|
|
|
else {
|
|
|
printf("没找到引用");
|
|
|
}
|
|
|
WriteLog("type=%s\n", type);
|
|
|
tag_t spec_dataset_rev = NULLTAG, ref_object = NULLTAG;
|
|
|
AE_reference_type_t reference_type;
|
|
|
ITKCALL(AE_ask_dataset_latest_rev(doc_tags[i], &spec_dataset_rev));
|
|
|
char ref_name[WSO_name_size_c + 1] = "word";
|
|
|
ITKCALL(AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object));
|
|
|
WriteLog("开始判断type");
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
char *pathname = "";
|
|
|
ITKCALL(IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname));
|
|
|
char *origin_file_name = "";
|
|
|
ITKCALL(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, "docx", 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);
|
|
|
ITKCALL(IMF_export_file(ref_object, temp_file));
|
|
|
char *name = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_name", &name));
|
|
|
WriteLog("开始执行cmd方法");
|
|
|
char cmd[256] = "";
|
|
|
strcpy(cmd, "D:\\Siemens\\Teamcenter12\\portal\\plugins\\plug\\SubstMacros-MSWord.wsf");
|
|
|
strcat(cmd, " \"");
|
|
|
strcat(cmd, temp_file);
|
|
|
strcat(cmd, "\" ");
|
|
|
strcat(cmd, "D:\\Siemens\\Teamcenter12\\bin\\PDF.config.txt");
|
|
|
strcat(cmd, " D:\\11.pdf");
|
|
|
WriteLog("\n%s\n", cmd);
|
|
|
system(cmd);
|
|
|
WriteLog("cmd执行完毕");
|
|
|
tag_t *word_tags = NULLTAG;
|
|
|
int word_num = NULL;
|
|
|
|
|
|
ITKCALL(AOM_ask_value_tags(attachments[a], "IMAN_Rendering", &word_num, &word_tags));
|
|
|
tag_t pdf = NULLTAG;
|
|
|
for (int n = 0; n < word_num; n++) {
|
|
|
char *type = "";
|
|
|
char *pdfname = "";
|
|
|
ITKCALL(AOM_ask_value_string(word_tags[n], "object_type", &type));
|
|
|
string newtype = Utf8ToGbk(type);
|
|
|
type = (char*)newtype.data();
|
|
|
WriteLog("type值为%s:", type);
|
|
|
|
|
|
ITKCALL(AOM_ask_value_string(word_tags[n], "object_name", &pdfname));
|
|
|
char *name1 = NULL;
|
|
|
char *name2 = NULL;
|
|
|
name1 = pdfname;
|
|
|
name2 = name;
|
|
|
if (strcmp(type, "PDF") == 0 && strcmp(name1, name2) == 0) {
|
|
|
pdf = word_tags[n];
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (pdf == NULLTAG) {
|
|
|
WriteLog("没有找到PDF数据集,开始进行创建\n", lastName);
|
|
|
int rfCount;
|
|
|
tag_t pdfTypeTag = NULLTAG, tool = NULLTAG, relationTag, *rfTags, newrelation;
|
|
|
|
|
|
ITKCALL(AE_find_datasettype2("PDF", &pdfTypeTag));
|
|
|
ITKCALL(AE_create_dataset_with_id(pdfTypeTag, lastName, "", "", "A", &pdf));
|
|
|
ITKCALL(AE_ask_datasettype_def_tool(pdfTypeTag, &tool));
|
|
|
AOM_lock(pdf);
|
|
|
ITKCALL(AE_set_dataset_tool(pdf, tool));
|
|
|
ITKCALL(AE_set_dataset_format2(pdf, "PDF_Reference"));
|
|
|
ITKCALL(AOM_save(pdf));
|
|
|
AOM_unlock(pdf);
|
|
|
if (pdf == NULLTAG) {
|
|
|
WriteLog("创建失败\n");
|
|
|
}
|
|
|
else {
|
|
|
WriteLog("创建成功\n");
|
|
|
ITKCALL(GRM_find_relation_type("IMAN_Rendering", &relationTag));
|
|
|
if (relationTag == NULLTAG) {
|
|
|
WriteLog("1111111111111111111111111111111");
|
|
|
}
|
|
|
ITKCALL(GRM_list_secondary_objects_only(attachments[a], relationTag, &rfCount, &rfTags));
|
|
|
ITKCALL(GRM_create_relation(attachments[a], pdf, relationTag, NULLTAG, &newrelation));
|
|
|
ITKCALL(GRM_save_relation(newrelation));
|
|
|
//ITKCALL(AOM_unload(attachments[a]));
|
|
|
//ITKCALL(AOM_refresh(attachments[a], true));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (pdf != NULL) {
|
|
|
WriteLog("已经存在PDF数据集,开始进行创建 %s\n", lastName);
|
|
|
char namefix[256] = "";
|
|
|
strcpy(namefix, lastName);
|
|
|
strcat(namefix, ".pdf");
|
|
|
ITKCALL(import_dataset_file_binary(pdf, "/tmp/", "PDF_Reference", "pdf", "D:\\11.pdf", namefix));
|
|
|
ITKCALL(remove("D:\\11.pdf"));
|
|
|
WriteLog("删除成功");
|
|
|
|
|
|
tag_t assign_user = NULL_TAG;
|
|
|
tag_t o_group_tag = NULL_TAG;
|
|
|
AOM_ask_owner(attachments[a], &assign_user);
|
|
|
AOM_ask_group(attachments[a], &o_group_tag);
|
|
|
//AOM_lock(pdf);
|
|
|
AOM_set_ownership(pdf, assign_user, o_group_tag);
|
|
|
//AOM_save(pdf);
|
|
|
//AOM_unlock(pdf);
|
|
|
//AOM_refresh(pdf, TRUE);
|
|
|
}
|
|
|
else {
|
|
|
WriteLog("当前版本下没有IMAN_Rendering文件夹");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (strcmp(type, "MSExcelX") == 0) {
|
|
|
if (doc_num > 1) {
|
|
|
char *name = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_name", &name));
|
|
|
char f = name[0];
|
|
|
if (f < 48 || f > 57) {
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
//获取数据集的名称
|
|
|
char* lastName = NULL;
|
|
|
int refCount = 0;
|
|
|
tag_t* refTags;
|
|
|
ITKCALL(AOM_ask_value_tags(doc_tags[i], "ref_list", &refCount, &refTags));
|
|
|
if (refCount > 0) {
|
|
|
ITKCALL(AOM_ask_value_string(refTags[0], "original_file_name", &lastName));
|
|
|
replaceSpecialChars(lastName);
|
|
|
}
|
|
|
else {
|
|
|
printf("没找到引用");
|
|
|
}
|
|
|
WriteLog("type=%s\n", type);
|
|
|
tag_t spec_dataset_rev = NULLTAG, ref_object = NULLTAG;
|
|
|
AE_reference_type_t reference_type;
|
|
|
ITKCALL(AE_ask_dataset_latest_rev(doc_tags[i], &spec_dataset_rev));
|
|
|
char ref_name[WSO_name_size_c + 1] = "excel";
|
|
|
ITKCALL(AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object));
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
char *pathname = "";
|
|
|
ITKCALL(IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname));
|
|
|
char *origin_file_name = "";
|
|
|
ITKCALL(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, "xlsx", 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);
|
|
|
|
|
|
ITKCALL(IMF_export_file(ref_object, temp_file));
|
|
|
char *name = "";
|
|
|
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_name", &name));
|
|
|
char cmd[256] = "";
|
|
|
strcpy(cmd, "D:\\Siemens\\Teamcenter12\\portal\\plugins\\plug\\SubstMacros-MSExcel.wsf");
|
|
|
strcat(cmd, " \"");
|
|
|
strcat(cmd, temp_file);
|
|
|
strcat(cmd, "\" ");
|
|
|
|
|
|
strcat(cmd, "D:\\Siemens\\Teamcenter12\\bin\\PDF.config.txt");
|
|
|
strcat(cmd, " D:\\11.pdf");
|
|
|
WriteLog("\n%s\n", cmd);
|
|
|
system(cmd);
|
|
|
WriteLog("cmd执行完毕");
|
|
|
tag_t *word_tags = NULLTAG;
|
|
|
int word_num = NULL;
|
|
|
ITKCALL(AOM_ask_value_tags(attachments[a], "IMAN_Rendering", &word_num, &word_tags));
|
|
|
tag_t pdf = NULLTAG;
|
|
|
for (int n = 0; n < word_num; n++) {
|
|
|
char *type = "";
|
|
|
char *pdfname = "";
|
|
|
ITKCALL(AOM_ask_value_string(word_tags[n], "object_type", &type));
|
|
|
ITKCALL(AOM_ask_value_string(word_tags[n], "object_name", &pdfname));
|
|
|
char *name1 = NULL;
|
|
|
char *name2 = NULL;
|
|
|
name1 = pdfname;
|
|
|
name2 = name;
|
|
|
if (strcmp(type, "PDF") == 0 && strcmp(name1, name2) == 0) {
|
|
|
pdf = word_tags[n];
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (pdf == NULLTAG) {
|
|
|
WriteLog("没有找到PDF数据集,开始进行创建\n", lastName);
|
|
|
int rfCount;
|
|
|
tag_t pdfTypeTag = NULLTAG, tool = NULLTAG, relationTag, *rfTags, newrelation;
|
|
|
|
|
|
ITKCALL(AE_find_datasettype2("PDF", &pdfTypeTag));
|
|
|
ITKCALL(AE_create_dataset_with_id(pdfTypeTag, lastName, "", "", "A", &pdf));
|
|
|
ITKCALL(AE_ask_datasettype_def_tool(pdfTypeTag, &tool));
|
|
|
AOM_lock(pdf);
|
|
|
ITKCALL(AE_set_dataset_tool(pdf, tool));
|
|
|
ITKCALL(AE_set_dataset_format2(pdf, "PDF_Reference"));
|
|
|
ITKCALL(AOM_save(pdf));
|
|
|
AOM_unlock(pdf);
|
|
|
if (pdf == NULLTAG) {
|
|
|
WriteLog("创建失败\n");
|
|
|
}
|
|
|
else {
|
|
|
WriteLog("创建成功\n");
|
|
|
ITKCALL(GRM_find_relation_type("IMAN_Rendering", &relationTag));
|
|
|
if (relationTag == NULLTAG) {
|
|
|
WriteLog("1111111111111111111");
|
|
|
}
|
|
|
ITKCALL(GRM_list_secondary_objects_only(attachments[a], relationTag, &rfCount, &rfTags));
|
|
|
ITKCALL(GRM_create_relation(attachments[a], pdf, relationTag, NULLTAG, &newrelation));
|
|
|
ITKCALL(GRM_save_relation(newrelation));
|
|
|
//ITKCALL(AOM_unload(attachments[a]));
|
|
|
//ITKCALL(AOM_refresh(attachments[a], true));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (pdf != NULL) {
|
|
|
WriteLog("已经存在PDF数据集,开始进行创建 %s\n", lastName);
|
|
|
char namefix[256] = "";
|
|
|
// 去除特殊字符
|
|
|
|
|
|
strcpy(namefix, lastName);
|
|
|
strcat(namefix, ".pdf");
|
|
|
import_dataset_file_binary(pdf, "/tmp/", "PDF_Reference", "pdf", "D:\\11.pdf", namefix);
|
|
|
remove("D:\\11.pdf");
|
|
|
|
|
|
tag_t assign_user = NULL_TAG;
|
|
|
tag_t o_group_tag = NULL_TAG;
|
|
|
AOM_ask_owner(attachments[a], &assign_user);
|
|
|
AOM_ask_group(attachments[a], &o_group_tag);
|
|
|
//AOM_lock(pdf);
|
|
|
AOM_set_ownership(pdf, assign_user, o_group_tag);
|
|
|
|
|
|
//AOM_save(pdf);
|
|
|
//AOM_unlock(pdf);
|
|
|
|
|
|
//AOM_refresh(pdf, TRUE);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
WriteLog("没有找到文件");
|
|
|
}
|
|
|
//WriteLog("123456789");
|
|
|
|
|
|
}
|
|
|
}
|
|
|
POM_AM__set_application_bypass(false); // 关旁路
|
|
|
WriteLog("——————转换完成——————");
|
|
|
CloseLog();
|
|
|
return ITK_ok;
|
|
|
|
|
|
}
|
|
|
void recursionBOM(tag_t top_line, int level, vector<tag_t>& bomline) {
|
|
|
if (level <= 0) { // 达到指定层级,停止递归
|
|
|
return;
|
|
|
}
|
|
|
int count;
|
|
|
tag_t* children_line;
|
|
|
ITKCALL(BOM_line_ask_all_child_lines(top_line, &count, &children_line));
|
|
|
if (count > 0) {
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
bomline.push_back(children_line[i]); // 添加子对象到 bomline
|
|
|
// 递归调用,传入子对象和 level-1
|
|
|
recursionBOM(children_line[i], level - 1, bomline);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
bool vec_find(vector<char*> ids, char* id) {
|
|
|
for (int i = 0; i < ids.size(); i++) {
|
|
|
if (tc_strcmp(ids[i], id) == 0) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
int Connor_AVIC_Check_GetInfo(EPM_action_message_t msg) {
|
|
|
printf("*******************************************************************************\n");
|
|
|
printf("* Connor_AVIC_Check_GetInfo is comming 0328-03! *\n");
|
|
|
printf("*******************************************************************************\n");
|
|
|
int att_cnt = 0; // att_cnt:选中的对象的数量
|
|
|
int doc_num = NULL;
|
|
|
tag_t task = NULLTAG, rootTask_tag = NULLTAG, * attachments = NULL;
|
|
|
tag_t* doc_tags = NULLTAG;
|
|
|
task = msg.task;
|
|
|
char* description = "", * type = "Ac5_XYJinfo_FM";
|
|
|
int arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
char* Relation = NULL, * CheckProperty = NULL, * Form = NULL, * ChangeProperty = NULL, * Check = NULL, * name = "限用件信息";
|
|
|
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
|
|
|
task = msg.task;
|
|
|
ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
|
|
|
tag_t getform = NULLTAG;
|
|
|
vector<string> propertiesList;
|
|
|
vector<string> valueList;
|
|
|
int result = 0;
|
|
|
vector<string> proList;
|
|
|
bool checkBool = true;
|
|
|
ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
|
|
|
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
|
|
ITKCALL(AOM_ask_value_tags(attachments[0], "IMAN_specification", &doc_num, &doc_tags));
|
|
|
|
|
|
ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
|
|
|
if (arg_cnt > 0)
|
|
|
{
|
|
|
for (int i = 0; i < arg_cnt; i++)
|
|
|
{
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
ITKCALL(ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue));
|
|
|
if (tc_strcmp(argflag, "Relation") == 0) {
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
printf("获取的值%s:", argvalue);
|
|
|
Relation = argvalue;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
if (tc_strcmp(argflag, "CheckProperty") == 0) {
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
printf("获取的值%s:", argvalue);
|
|
|
CheckProperty = argvalue;
|
|
|
}
|
|
|
Split(CheckProperty, ";", propertiesList);
|
|
|
}
|
|
|
if (tc_strcmp(argflag, "Check") == 0) {
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
printf("获取的值%s:", argvalue);
|
|
|
Check = argvalue;
|
|
|
}
|
|
|
}
|
|
|
if (tc_strcmp(argflag, "Form") == 0) {
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
printf("获取的值%s:", argvalue);
|
|
|
Form = argvalue;
|
|
|
}
|
|
|
}
|
|
|
if (tc_strcmp(argflag, "ChangeProperty") == 0) {
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
printf("获取的值%s:", argvalue);
|
|
|
ChangeProperty = argvalue;
|
|
|
}
|
|
|
Split(ChangeProperty, ";", proList);
|
|
|
|
|
|
}
|
|
|
if (tc_strcmp(argflag, "Floor") == 0) {
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
printf("获取的值%s:", argvalue);
|
|
|
char* Floor = argvalue;
|
|
|
sscanf(Floor, "%d", &result);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
printf("开始获取表单\n");
|
|
|
int count = 0;
|
|
|
tag_t* cpp = NULLTAG;
|
|
|
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_reference_attachment, &count, &cpp));
|
|
|
for (int t = 0; t < count; t++) {
|
|
|
char* formtype = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(cpp[t], "object_type", &formtype));
|
|
|
if (tc_strcmp(formtype, Form) == 0) {
|
|
|
getform = cpp[t];
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
printf("开始判断ChangeProperty\n");
|
|
|
int changeCount = 0;
|
|
|
for (int m = 0; m < proList.size(); m++) {
|
|
|
vector<string> changeList;
|
|
|
Split(proList[m], "=", changeList);
|
|
|
char* changeValue;
|
|
|
ITKCALL(AOM_get_value_string(getform, changeList[0].c_str(), &changeValue));
|
|
|
printf("开始比较%s和%s的值\n", changeValue, changeList[1].c_str());
|
|
|
if (tc_strcmp(changeValue, changeList[1].c_str()) == 0) {
|
|
|
printf("相等\n");
|
|
|
changeCount++;
|
|
|
}
|
|
|
}
|
|
|
if (changeCount == proList.size()) {
|
|
|
//表示不是第一次提取限用件信息,不再进行限用件检查
|
|
|
//checkBool = false;
|
|
|
}
|
|
|
printf("开始判断check\n");
|
|
|
vector<string> checks;
|
|
|
vector<boolean> flags;
|
|
|
Split(Check, ";", checks);
|
|
|
for (int b = 0; b < checks.size(); b++) {
|
|
|
vector<string> check1;
|
|
|
Split(checks[b], "=", check1);
|
|
|
char* val = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(getform, check1[0].c_str(), &val));
|
|
|
printf("属性值%s:", val);
|
|
|
if (tc_strcmp(val, check1[1].c_str()) == 0) {
|
|
|
flags.push_back(true);
|
|
|
}
|
|
|
}
|
|
|
if (flags.size() == checks.size()) {
|
|
|
printf("check判断通过,跳出检查\n");
|
|
|
return 0;
|
|
|
}
|
|
|
vector<char*> ids, objnames, guiges, jishus, shengcs, biaojis, paihaos, yuanyins;
|
|
|
for (int t = 0; t < att_cnt; t++) {
|
|
|
char* atta_type = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(attachments[t], "object_type", &atta_type));
|
|
|
printf("atta_type==%s\n", atta_type);
|
|
|
if (tc_strstr(atta_type, "Revision") == NULL || tc_strstr(atta_type, "Master") != NULL
|
|
|
|| tc_strstr(atta_type, "BOMView") != NULL) {
|
|
|
continue;
|
|
|
}
|
|
|
//创建BOMWindow
|
|
|
tag_t top_line = NULLTAG, window = NULLTAG;
|
|
|
printf("创建BOMWindow\n");
|
|
|
ITKCALL(BOM_create_window(&window));
|
|
|
//设置顶层BOM
|
|
|
printf("设置顶层BOM\n");
|
|
|
ITKCALL(BOM_set_window_top_line(window, NULLTAG, attachments[t], NULLTAG, &top_line));
|
|
|
tag_t* children_line = NULLTAG;
|
|
|
char* id = NULL, *objname = NULL, *guige = NULL, *jishu = NULL, *shengc = NULL, *biaoji = NULL, *paihao = NULL, *yuanyin = NULL;
|
|
|
char* type1 = "item", *type2 = "itemrevision", *type3 = "revmaster";
|
|
|
printf("获取子列BOM\n");
|
|
|
if (result != 0) {
|
|
|
//获取Floor的值,开始递归Bom
|
|
|
vector<tag_t> bomline;
|
|
|
// bomline 变量中保存了执行完递归后的结果
|
|
|
recursionBOM(top_line, result, bomline);
|
|
|
count = bomline.size();
|
|
|
children_line = new tag_t[bomline.size()];
|
|
|
// 复制bomline中的值到children_line中
|
|
|
memcpy(children_line, bomline.data(), bomline.size() * sizeof(tag_t));
|
|
|
}
|
|
|
else {
|
|
|
ITKCALL(BOM_line_ask_all_child_lines(top_line, &count, &children_line));
|
|
|
}
|
|
|
for (int j = 0; j < count; j++) {
|
|
|
char* typestr = NULL;
|
|
|
tag_t revobj = NULL;
|
|
|
tag_t itemobj = NULL;
|
|
|
printf("bomline获取版本");
|
|
|
ITKCALL(AOM_ask_value_tag(children_line[j], "bl_line_object", &revobj));
|
|
|
printf("获取item");
|
|
|
ITKCALL(AOM_ask_value_tag(revobj, "items_tag", &itemobj));
|
|
|
printf("获取类型");
|
|
|
ITKCALL(AOM_ask_value_string(itemobj, "object_type", &typestr));
|
|
|
printf("typestr%s:", typestr);
|
|
|
printf("开始循环获取的propertiesList");
|
|
|
for (int n = 0; n < propertiesList.size(); n++) {
|
|
|
tag_t obj = NULL;
|
|
|
Split(propertiesList[n], "=", valueList);
|
|
|
printf("value%s:", valueList[0].c_str());
|
|
|
printf("判断类型");
|
|
|
if (tc_strcmp(typestr, valueList[0].c_str()) == 0) {
|
|
|
printf("判断属性");
|
|
|
if (tc_strcmp(type1, valueList[1].c_str()) == 0) {
|
|
|
ITKCALL(AOM_ask_value_tag(revobj, "items_tag", &obj));
|
|
|
}
|
|
|
else if (tc_strcmp(type2, valueList[1].c_str()) == 0) {
|
|
|
obj = revobj;
|
|
|
}
|
|
|
else if (tc_strcmp(type3, valueList[1].c_str()) == 0) {
|
|
|
tag_t* formobj = NULLTAG;
|
|
|
int numobj = 0;
|
|
|
ITKCALL(AOM_ask_value_tags(revobj, "IMAN_master_form_rev", &numobj, &formobj));
|
|
|
obj = formobj[0];
|
|
|
}
|
|
|
char* getvalue = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(obj, valueList[2].c_str(), &getvalue));
|
|
|
printf("开始获取value值%s", getvalue);
|
|
|
if (tc_strcmp(getvalue, valueList[3].c_str()) == 0) {
|
|
|
printf("获取到限用件");
|
|
|
//获取限用件信息
|
|
|
char* id = NULL, *objname = NULL, *guige = NULL, *jishu = NULL, *shengc = NULL, *biaoji = NULL, *paihao = NULL, *yuanyin = NULL;
|
|
|
tag_t itemobj = NULL;
|
|
|
tag_t revisionobj = NULL;
|
|
|
tag_t* fromobj1 = NULL;
|
|
|
tag_t formobj2 = NULL;
|
|
|
ITKCALL(AOM_ask_value_tag(children_line[j], "bl_line_object", &revisionobj));
|
|
|
ITKCALL(AOM_ask_value_tag(revisionobj, "items_tag", &itemobj));
|
|
|
ITKCALL(AOM_ask_value_string(itemobj, "item_id", &id));
|
|
|
printf("id==%s\n", id);
|
|
|
if (vec_find(ids, id)) {
|
|
|
// 去一下重
|
|
|
continue;
|
|
|
}
|
|
|
printf("ids.push_back(id)");
|
|
|
int numobj = 0;
|
|
|
ITKCALL(AOM_ask_value_tags(revisionobj, "IMAN_master_form_rev", &numobj, &fromobj1));
|
|
|
formobj2 = fromobj1[0];
|
|
|
ITKCALL(AOM_ask_value_string(itemobj, "item_id", &id));
|
|
|
ITKCALL(AOM_ask_value_string(itemobj, "object_name", &objname));
|
|
|
ITKCALL(AOM_ask_value_string(formobj2, "ac5_Specifications", &guige));
|
|
|
ITKCALL(AOM_ask_value_string(formobj2, "ac5_TechnicalConditions", &jishu));
|
|
|
ITKCALL(AOM_ask_value_string(formobj2, "ac5_Manufacturer", &shengc));
|
|
|
ITKCALL(AOM_ask_value_string(formobj2, "ac5_SelectionMarkers", &biaoji));
|
|
|
ITKCALL(AOM_ask_value_string(formobj2, "ac5_Brand", &paihao));
|
|
|
ITKCALL(AOM_ask_value_string(formobj2, "ac5_Reason", &yuanyin));
|
|
|
ids.push_back(id);
|
|
|
objnames.push_back(objname);
|
|
|
guiges.push_back(guige);
|
|
|
jishus.push_back(jishu);
|
|
|
shengcs.push_back(shengc);
|
|
|
biaojis.push_back(biaoji);
|
|
|
paihaos.push_back(paihao);
|
|
|
yuanyins.push_back(yuanyin);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
ITKCALL(BOM_close_window(window));
|
|
|
}
|
|
|
|
|
|
printf("ids==%zd\n", ids.size());
|
|
|
if (ids.size() > 0) {
|
|
|
printf("checkBool==%d\n", checkBool);
|
|
|
if (checkBool) {
|
|
|
printf("存数据\n");
|
|
|
AOM_lock(getform);
|
|
|
printf("更新新增数据之前校验删除数据\n");
|
|
|
int tableNum1 = 0;
|
|
|
tag_t* tableTags1;
|
|
|
ITKCALL(AOM_ask_table_rows(getform, "ac5_XYJinfo", &tableNum1, &tableTags1));
|
|
|
for (int p = tableNum1 - 1; p >= 0; p--) {
|
|
|
tag_t rowTable = tableTags1[p];
|
|
|
char* idRow;
|
|
|
ITKCALL(AOM_ask_value_string(rowTable, "ac5_ID", &idRow));
|
|
|
// 判断是否存在于ids中,不存在则删除,存在则不做处理
|
|
|
printf("idRow==%s\n", idRow);
|
|
|
if (!vec_find(ids, idRow)) {
|
|
|
// 删除对象
|
|
|
printf("delete\n");
|
|
|
ITKCALL(AOM_delete_table_rows(getform, "ac5_XYJinfo", p, 1));
|
|
|
}
|
|
|
}
|
|
|
AOM_save(getform);
|
|
|
int tableNum2 = 0;
|
|
|
tag_t* tableTags2;
|
|
|
ITKCALL(AOM_ask_table_rows(getform, "ac5_XYJinfo", &tableNum2, &tableTags2));
|
|
|
printf("delete:%d==%d\n", tableNum1, tableNum2);
|
|
|
|
|
|
printf("判断是否更新数据还是插入数据\n");
|
|
|
int tableNum = 0;
|
|
|
tag_t* tableTags;
|
|
|
ITKCALL(AOM_ask_table_rows(getform, "ac5_XYJinfo", &tableNum, &tableTags));
|
|
|
for (int d = 0; d < ids.size(); d++) {
|
|
|
//判断是否已经插入过一次
|
|
|
printf("判断%s是否已经存在于表格\n", ids[d]);
|
|
|
bool isTableRow = false;
|
|
|
for (int p = 0; p < tableNum; p++) {
|
|
|
tag_t rowTable = tableTags[p];
|
|
|
char* idRow;
|
|
|
ITKCALL(AOM_ask_value_string(rowTable, "ac5_ID", &idRow));
|
|
|
printf("比较表格数据%s是否相等\n", idRow);
|
|
|
if (tc_strcmp(idRow, ids[d]) == 0) {
|
|
|
printf("开始更新数据\n");
|
|
|
AOM_lock(rowTable);
|
|
|
ITKCALL(AOM_set_value_string(rowTable, "ac5_ID", ids[d]));
|
|
|
ITKCALL(AOM_set_value_string(rowTable, "ac5_Objectname", objnames[d]));
|
|
|
ITKCALL(AOM_set_value_string(rowTable, "ac5_Specifications", guiges[d]));
|
|
|
ITKCALL(AOM_set_value_string(rowTable, "ac5_TechnicalConditions", jishus[d]));
|
|
|
ITKCALL(AOM_set_value_string(rowTable, "ac5_Manufacturer", shengcs[d]));
|
|
|
ITKCALL(AOM_set_value_string(rowTable, "ac5_SelectionMarkers", biaojis[d]));
|
|
|
ITKCALL(AOM_set_value_string(rowTable, "ac5_Brand", paihaos[d]));
|
|
|
ITKCALL(AOM_set_value_string(rowTable, "ac5_Reason", yuanyins[d]));
|
|
|
isTableRow = true;
|
|
|
AOM_save(rowTable);
|
|
|
AOM_unlock(rowTable);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (isTableRow) {
|
|
|
continue;
|
|
|
}
|
|
|
printf("开始插入数据\n");
|
|
|
//插入新的行
|
|
|
tag_t* tableRow = NULL;
|
|
|
ITKCALL(AOM_insert_table_rows(getform, "ac5_XYJinfo", 0, 1, &tableRow));
|
|
|
AOM_lock(tableRow[0]);
|
|
|
ITKCALL(AOM_set_value_string(tableRow[0], "ac5_ID", ids[d]));
|
|
|
ITKCALL(AOM_set_value_string(tableRow[0], "ac5_Objectname", objnames[d]));
|
|
|
ITKCALL(AOM_set_value_string(tableRow[0], "ac5_Specifications", guiges[d]));
|
|
|
ITKCALL(AOM_set_value_string(tableRow[0], "ac5_TechnicalConditions", jishus[d]));
|
|
|
ITKCALL(AOM_set_value_string(tableRow[0], "ac5_Manufacturer", shengcs[d]));
|
|
|
ITKCALL(AOM_set_value_string(tableRow[0], "ac5_SelectionMarkers", biaojis[d]));
|
|
|
ITKCALL(AOM_set_value_string(tableRow[0], "ac5_Brand", paihaos[d]));
|
|
|
ITKCALL(AOM_set_value_string(tableRow[0], "ac5_Reason", yuanyins[d]));
|
|
|
AOM_save(tableRow[0]);
|
|
|
AOM_unlock(tableRow[0]);
|
|
|
|
|
|
}
|
|
|
for (int m = 0; m < proList.size(); m++) {
|
|
|
vector<string> changeList;
|
|
|
Split(proList[m], "=", changeList);
|
|
|
ITKCALL(AOM_set_value_string(getform, changeList[0].c_str(), changeList[1].c_str()));
|
|
|
}
|
|
|
AOM_save(getform);
|
|
|
AOM_unlock(getform);
|
|
|
int tableNum3 = 0;
|
|
|
tag_t* tableTags3;
|
|
|
ITKCALL(AOM_ask_table_rows(getform, "ac5_XYJinfo", &tableNum3, &tableTags3));
|
|
|
printf("ac5_XYJinfo==%d\n", tableNum3);
|
|
|
}
|
|
|
printf("BOM中存在限用物料,请在表单中确认是否通过!\n");
|
|
|
string error = GbkToUtf8("BOM中存在限用物料,请在表单中确认是否通过!");
|
|
|
ITKCALL(EMH_store_error_s1(EMH_severity_user_error, ITK_err, error.c_str()));
|
|
|
return 1;
|
|
|
}
|
|
|
else {
|
|
|
//修改属性 清空表格
|
|
|
printf("修改属性 清空表格\n");
|
|
|
AOM_lock(getform);
|
|
|
ITKCALL(AOM_set_value_string(getform, "ac5_XYJorNot", "false"));
|
|
|
|
|
|
|
|
|
int tableNum1 = 0;
|
|
|
tag_t* tableTags1;
|
|
|
ITKCALL(AOM_ask_table_rows(getform, "ac5_XYJinfo", &tableNum1, &tableTags1));
|
|
|
if (tableNum1 > 0) {
|
|
|
ITKCALL(AOM_delete_table_rows(getform, "ac5_XYJinfo", 0, tableNum1));
|
|
|
}
|
|
|
AOM_save(getform);
|
|
|
AOM_unlock(getform);
|
|
|
}
|
|
|
|
|
|
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//int Connor_AVIC_Check_GetInfo(EPM_action_message_t msg) {
|
|
|
// int att_cnt = 0; // att_cnt:选中的对象的数量
|
|
|
// int doc_num = NULL;
|
|
|
// tag_t task = NULLTAG, rootTask_tag = NULLTAG, * attachments = NULL;
|
|
|
// tag_t* doc_tags = NULLTAG;
|
|
|
// task = msg.task;
|
|
|
// char* description = "", * type = "Ac5_XYJinfo_FM";
|
|
|
// int arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
// char* Relation = NULL, * CheckProperty = NULL, * Form = NULL, * ChangeProperty = NULL, * Check = NULL, * name = "限用件信息";
|
|
|
// int result;
|
|
|
// char* arg = NULL, * argflag = NULL, * argvalue = NULL;
|
|
|
// task = msg.task;
|
|
|
// ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
|
|
|
// tag_t getform = NULLTAG;
|
|
|
// vector<string> propertiesList;
|
|
|
// vector<string> valueList;
|
|
|
//
|
|
|
// vector<string> proList;
|
|
|
//
|
|
|
// ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
|
|
|
// ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
|
|
// ITKCALL(AOM_ask_value_tags(attachments[0], "IMAN_specification", &doc_num, &doc_tags));
|
|
|
//
|
|
|
// ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
|
|
|
// if (arg_cnt > 0)
|
|
|
// {
|
|
|
// for (int i = 0; i < arg_cnt; i++)
|
|
|
// {
|
|
|
// arg = TC_next_argument(msg.arguments);
|
|
|
// ITKCALL(ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue));
|
|
|
// if (strcmp(argflag, "Relation") == 0) {
|
|
|
// if (argvalue != NULL)
|
|
|
// {
|
|
|
// printf("获取的值%s:", argvalue);
|
|
|
// Relation = argvalue;
|
|
|
//
|
|
|
// }
|
|
|
// }
|
|
|
// if (strcmp(argflag, "CheckProperty") == 0) {
|
|
|
// if (argvalue != NULL)
|
|
|
// {
|
|
|
// printf("获取的值%s:", argvalue);
|
|
|
// CheckProperty = argvalue;
|
|
|
// }
|
|
|
// Split(CheckProperty, ";", propertiesList);
|
|
|
// }
|
|
|
// if (strcmp(argflag, "Check") == 0) {
|
|
|
// if (argvalue != NULL)
|
|
|
// {
|
|
|
// printf("获取的值%s:", argvalue);
|
|
|
// Check = argvalue;
|
|
|
// }
|
|
|
// }
|
|
|
// if (strcmp(argflag, "Form") == 0) {
|
|
|
// if (argvalue != NULL)
|
|
|
// {
|
|
|
// printf("获取的值%s:", argvalue);
|
|
|
// Form = argvalue;
|
|
|
// }
|
|
|
// }
|
|
|
// if (strcmp(argflag, "ChangeProperty") == 0) {
|
|
|
// if (argvalue != NULL)
|
|
|
// {
|
|
|
// printf("获取的值%s:", argvalue);
|
|
|
// ChangeProperty = argvalue;
|
|
|
// }
|
|
|
// Split(ChangeProperty, ";", proList);
|
|
|
//
|
|
|
// }
|
|
|
// if (strcmp(argflag, "Floor") == 0) {
|
|
|
// if (argvalue != NULL)
|
|
|
// {
|
|
|
// printf("获取的值%s:", argvalue);
|
|
|
// char* Floor = argvalue;
|
|
|
// sscanf(Floor, "%d", &result);
|
|
|
// }
|
|
|
//
|
|
|
// }
|
|
|
// }
|
|
|
// printf("开始获取表单\n");
|
|
|
// int count = 0;
|
|
|
// tag_t* cpp = NULLTAG;
|
|
|
// ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_reference_attachment, &count, &cpp));
|
|
|
// for (int t = 0; t < count; t++) {
|
|
|
// char* formtype = NULL;
|
|
|
// ITKCALL(AOM_ask_value_string(cpp[t], "object_type", &formtype));
|
|
|
// if (strcmp(formtype, Form) == 0) {
|
|
|
// getform = cpp[t];
|
|
|
// break;
|
|
|
// }
|
|
|
// }
|
|
|
// printf("开始判断check\n");
|
|
|
// vector<string> checks;
|
|
|
// vector<boolean> flags;
|
|
|
// Split(Check, ";", checks);
|
|
|
// for (int b = 0; b < checks.size(); b++) {
|
|
|
// vector<string> check1;
|
|
|
// Split(checks[b], "=", check1);
|
|
|
// char* val = NULL;
|
|
|
// ITKCALL(AOM_ask_value_string(getform, check1[0].c_str(), &val));
|
|
|
// printf("属性值%s:", val);
|
|
|
// if (strcmp(val, check1[1].c_str()) == 0) {
|
|
|
// flags.push_back(true);
|
|
|
// }
|
|
|
// }
|
|
|
// if (flags.size() == checks.size()) {
|
|
|
// printf("check判断通过,跳出检查\n");
|
|
|
// return 0;
|
|
|
// }
|
|
|
// //创建BOMWindow
|
|
|
// tag_t top_line = NULLTAG, window = NULLTAG;
|
|
|
// printf("创建BOMWindow\n");
|
|
|
// ITKCALL(BOM_create_window(&window));
|
|
|
// //设置顶层BOM
|
|
|
// printf("设置顶层BOM\n");
|
|
|
// ITKCALL(BOM_set_window_top_line(window, NULLTAG, attachments[0], NULLTAG, &top_line));
|
|
|
// tag_t* children_line = NULLTAG;
|
|
|
// char* id = NULL, * objname = NULL, * guige = NULL, * jishu = NULL, * shengc = NULL, * biaoji = NULL, * paihao = NULL, * yuanyin = NULL;
|
|
|
// char* type1 = "item", * type2 = "itemrevision", * type3 = "revmaster";
|
|
|
// vector<char*> ids, objnames, guiges, jishus, shengcs, biaojis, paihaos, yuanyins;
|
|
|
// printf("获取子列BOM\n");
|
|
|
// //调整为递归获取BOM层级
|
|
|
// ITKCALL(BOM_line_ask_all_child_lines(top_line, &count, &children_line));
|
|
|
// for (int j = 0; j < count; j++) {
|
|
|
// char* typestr = NULL;
|
|
|
// tag_t revobj = NULL;
|
|
|
// tag_t itemobj = NULL;
|
|
|
// printf("bomline获取版本");
|
|
|
// ITKCALL(AOM_ask_value_tag(children_line[j], "bl_line_object", &revobj));
|
|
|
// printf("获取item");
|
|
|
// ITKCALL(AOM_ask_value_tag(revobj, "items_tag", &itemobj));
|
|
|
// printf("获取类型");
|
|
|
// ITKCALL(AOM_ask_value_string(itemobj, "object_type", &typestr));
|
|
|
// printf("typestr%s:", type);
|
|
|
// printf("开始循环获取的propertiesList");
|
|
|
// for (int n = 0; n < propertiesList.size(); n++) {
|
|
|
// tag_t obj = NULL;
|
|
|
// Split(propertiesList[n], "=", valueList);
|
|
|
// printf("value%s:", valueList[0].c_str());
|
|
|
// printf("判断类型");
|
|
|
// if (strcmp(typestr, valueList[0].c_str()) == 0) {
|
|
|
// printf("判断属性");
|
|
|
// if (strcmp(type1, valueList[1].c_str()) == 0) {
|
|
|
// ITKCALL(AOM_ask_value_tag(revobj, "items_tag", &obj));
|
|
|
// }
|
|
|
// else if (strcmp(type2, valueList[1].c_str()) == 0) {
|
|
|
// obj = revobj;
|
|
|
// }
|
|
|
// else if (strcmp(type3, valueList[1].c_str()) == 0) {
|
|
|
// tag_t* formobj = NULLTAG;
|
|
|
// int numobj = 0;
|
|
|
// ITKCALL(AOM_ask_value_tags(revobj, "IMAN_master_form_rev", &numobj, &formobj));
|
|
|
// obj = formobj[0];
|
|
|
// }
|
|
|
// char* getvalue = NULL;
|
|
|
// ITKCALL(AOM_ask_value_string(obj, valueList[2].c_str(), &getvalue));
|
|
|
// printf("开始获取value值%s", getvalue);
|
|
|
// if (strcmp(getvalue, valueList[3].c_str()) == 0) {
|
|
|
// printf("获取到限用件");
|
|
|
// //获取限用件信息
|
|
|
// char* id = NULL, * objname = NULL, * guige = NULL, * jishu = NULL, * shengc = NULL, * biaoji = NULL, * paihao = NULL, * yuanyin = NULL;
|
|
|
// tag_t itemobj = NULL;
|
|
|
// tag_t revisionobj = NULL;
|
|
|
// tag_t* fromobj1 = NULL;
|
|
|
// tag_t formobj2 = NULL;
|
|
|
// ITKCALL(AOM_ask_value_tag(children_line[j], "bl_line_object", &revisionobj));
|
|
|
// ITKCALL(AOM_ask_value_tag(revisionobj, "items_tag", &itemobj));
|
|
|
// int numobj = 0;
|
|
|
// ITKCALL(AOM_ask_value_tags(revisionobj, "IMAN_master_form_rev", &numobj, &fromobj1));
|
|
|
// formobj2 = fromobj1[0];
|
|
|
// ITKCALL(AOM_ask_value_string(itemobj, "item_id", &id));
|
|
|
// ITKCALL(AOM_ask_value_string(itemobj, "object_name", &objname));
|
|
|
// ITKCALL(AOM_ask_value_string(formobj2, "ac5_Specifications", &guige));
|
|
|
// ITKCALL(AOM_ask_value_string(formobj2, "ac5_TechnicalConditions", &jishu));
|
|
|
// ITKCALL(AOM_ask_value_string(formobj2, "ac5_Manufacturer", &shengc));
|
|
|
// ITKCALL(AOM_ask_value_string(formobj2, "ac5_SelectionMarkers", &biaoji));
|
|
|
// ITKCALL(AOM_ask_value_string(formobj2, "ac5_Brand", &paihao));
|
|
|
// ITKCALL(AOM_ask_value_string(formobj2, "ac5_Reason", &yuanyin));
|
|
|
// ids.push_back(id);
|
|
|
// objnames.push_back(objname);
|
|
|
// guiges.push_back(guige);
|
|
|
// jishus.push_back(jishu);
|
|
|
// shengcs.push_back(shengc);
|
|
|
// biaojis.push_back(biaoji);
|
|
|
// paihaos.push_back(paihao);
|
|
|
// yuanyins.push_back(yuanyin);
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// if (ids.size() > 0) {
|
|
|
// printf("存数据");
|
|
|
// AOM_lock(getform);
|
|
|
// tag_t* tableRow = NULL;
|
|
|
// for (int d = 0; d < ids.size(); d++) {
|
|
|
// ITKCALL(AOM_insert_table_rows(getform, "ac5_XYJinfo", 0, 1, &tableRow));
|
|
|
//
|
|
|
// ITKCALL(AOM_set_value_string(tableRow[0], "ac5_ID", ids[d]));
|
|
|
// ITKCALL(AOM_set_value_string(tableRow[0], "ac5_Objectname", objnames[d]));
|
|
|
// ITKCALL(AOM_set_value_string(tableRow[0], "ac5_Specifications", guiges[d]));
|
|
|
// ITKCALL(AOM_set_value_string(tableRow[0], "ac5_TechnicalConditions", jishus[d]));
|
|
|
// ITKCALL(AOM_set_value_string(tableRow[0], "ac5_Manufacturer", shengcs[d]));
|
|
|
// ITKCALL(AOM_set_value_string(tableRow[0], "ac5_SelectionMarkers", biaojis[d]));
|
|
|
// ITKCALL(AOM_set_value_string(tableRow[0], "ac5_Brand", paihaos[d]));
|
|
|
// ITKCALL(AOM_set_value_string(tableRow[0], "ac5_Reason", yuanyins[d]));
|
|
|
// }
|
|
|
//
|
|
|
// for (int m = 0; m < proList.size(); m++) {
|
|
|
// vector<string> changeList;
|
|
|
// Split(proList[m], "=", changeList);
|
|
|
// ITKCALL(AOM_set_value_string(getform, changeList[0].c_str(), changeList[1].c_str()));
|
|
|
// }
|
|
|
// AOM_save(getform);
|
|
|
// AOM_unlock(getform);
|
|
|
// string error = GbkToUtf8("BOM中存在限用物料,请在表单中确认是否通过!");
|
|
|
// EMH_store_error_s1(EMH_severity_user_error, ITK_err, error.c_str());
|
|
|
// return 1;
|
|
|
// }
|
|
|
//
|
|
|
//
|
|
|
// return ITK_ok;
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//int Cust_Add_BOMLine_Post(METHOD_message_t* msg, va_list args)
|
|
|
//{
|
|
|
// int customError = ITK_ok, pref_count = 0;
|
|
|
// char *parentId = NULL, *ptype = NULL, *revId = NULL, *ctype = NULL, **prefs = NULL;
|
|
|
// tag_t parentRev = NULLTAG, *master = NULLTAG, *revmaster = NULLTAG;
|
|
|
//
|
|
|
// WriteLog("*******************************************************************************\n");
|
|
|
// WriteLog("* Cust_Add_BOMLine_Post is comming ! *\n");
|
|
|
// WriteLog("*******************************************************************************\n");
|
|
|
//
|
|
|
// /*va_list largs;
|
|
|
// va_copy( largs, args );
|
|
|
// new_schedule_tag = va_arg( largs, tag_t );
|
|
|
// isNew = va_arg( largs, logical );
|
|
|
// va_end( largs );*/
|
|
|
// va_list largs;
|
|
|
// va_copy(largs, args);
|
|
|
// tag_t parent = va_arg(largs, tag_t);
|
|
|
// tag_t item = va_arg(largs, tag_t);
|
|
|
// tag_t rev = va_arg(largs, tag_t);
|
|
|
// tag_t bom_view = va_arg(largs, tag_t);
|
|
|
// char *occurrence_type = va_arg(largs, char*);
|
|
|
// tag_t *new_bom_line = va_arg(largs, tag_t *);
|
|
|
// tag_t gde = va_arg(largs, tag_t);
|
|
|
// tag_t occ_create_input = va_arg(largs, tag_t);
|
|
|
// va_end(largs);
|
|
|
// //判断对象是否存在于BOM中
|
|
|
// int sub_cnt = 0, count = 0;
|
|
|
// tag_t *sub_lines = NULL, target = NULLTAG;
|
|
|
// ITKCALL(BOM_line_ask_child_lines(parent, &sub_cnt, &sub_lines));
|
|
|
// //WriteLog("sub_cnt:%d\n", sub_cnt);
|
|
|
// for (int j = 0; j < sub_cnt; j++) {
|
|
|
// char *type = NULL;
|
|
|
// ITKCALL(AOM_ask_value_tag(sub_lines[j], "bl_item", &target));
|
|
|
// ITKCALL(AOM_ask_value_string(target, "object_type", &type));
|
|
|
// //WriteLog("type:%s == %s\n", type, ctype);
|
|
|
// if (strcmp(type, ctype) == 0) {
|
|
|
// count++;
|
|
|
// }
|
|
|
// }
|
|
|
// if (count>0) {
|
|
|
// //存在于BOM中
|
|
|
// //判断是否在首选项配型中
|
|
|
// ITKCALL(PREF_ask_char_values("Connor_AVIC_Check_XYLJ", &pref_count, &prefs));
|
|
|
// if (pref_count == 0) {
|
|
|
// WriteLog("未配置首选项Connor_NHL_Bomlimit");
|
|
|
// return customError;
|
|
|
// }
|
|
|
// else {
|
|
|
// char *typestr = "";
|
|
|
// ITKCALL(AOM_ask_value_string(item, "object_type", &typestr));
|
|
|
// int num = 0;
|
|
|
// for (int j = 0; j < pref_count; j++) {
|
|
|
// if (strcmp(prefs[j], typestr) == 0) {
|
|
|
// num++;
|
|
|
// }
|
|
|
// }
|
|
|
// if (num>0) {
|
|
|
// //存在于首选项
|
|
|
// //if (strcmp("XY", valueform)) {
|
|
|
// // //弹出窗口,待实现
|
|
|
//
|
|
|
// //}
|
|
|
// //else {
|
|
|
// // char *id = "";
|
|
|
// // ITKCALL(AOM_ask_value_string(rev, "item_id", &id));
|
|
|
// // char * error = strcat(id, "为禁用物料,不允许引用");
|
|
|
// // EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", error);
|
|
|
// //}
|
|
|
// int revcount = 0;
|
|
|
// tag_t *revs = NULLTAG;
|
|
|
// ITKCALL(AOM_ask_value_tags(item, "revision_list", &revcount,&revs));
|
|
|
// int xycount = 0;
|
|
|
// int jycount = 0;
|
|
|
// vector<char*>XYids;//XYverctor
|
|
|
// vector<char*>JYids;//JYverctor
|
|
|
// for (int n = 0; n < revcount;n++) {
|
|
|
// tag_t form = NULLTAG;
|
|
|
// ITKCALL(AOM_ask_value_tag(revs[n], "IMAN_master_form_rev", &form));
|
|
|
// if (form != NULLTAG) {
|
|
|
// char *valueform = "";
|
|
|
// ITKCALL(AOM_ask_value_string(form, "ac5_SelectionMarkers", &valueform));
|
|
|
// char *item_id = "";
|
|
|
// ITKCALL(AOM_ask_value_string(revs[n], "item_id", &item_id));
|
|
|
// if (strcat(valueform,"XY") == 0) {
|
|
|
// xycount++;
|
|
|
// XYids.push_back(item_id);
|
|
|
// }
|
|
|
// if (strcat(valueform, "JY") == 0) {
|
|
|
// jycount++;
|
|
|
// JYids.push_back(item_id);
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// if (jycount == revcount) {
|
|
|
// char *id = "";
|
|
|
// ITKCALL(AOM_ask_value_string(rev, "item_id", &id));
|
|
|
// char * error = strcat(id, "组件中存在禁用物料ID1、ID2、ID3,不允许引用");
|
|
|
// EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", error);
|
|
|
// }
|
|
|
// if (xycount>0 && jycount>0) {
|
|
|
//
|
|
|
// }
|
|
|
// tag_t form = NULLTAG;
|
|
|
// ITKCALL(AOM_ask_value_tag(rev, "IMAN_master_form_rev", &form));
|
|
|
// if (form != NULLTAG) {
|
|
|
// char *valueform = "";
|
|
|
// ITKCALL(AOM_ask_value_string(form, "ac5_SelectionMarkers", &valueform));
|
|
|
// if (valueform != NULL) {
|
|
|
// if (strcmp("JY", valueform)==0) {
|
|
|
// char *id = "";
|
|
|
// ITKCALL(AOM_ask_value_string(rev, "item_id", &id));
|
|
|
// char * error = strcat(id, "组件中存在禁用物料ID1、ID2、ID3,不允许引用");
|
|
|
// EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", error);
|
|
|
// }
|
|
|
// else {
|
|
|
// return 0;
|
|
|
// }
|
|
|
// }
|
|
|
// else {
|
|
|
// return 0;
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// else {
|
|
|
// //不存在于BOM中
|
|
|
// //判断是否在首选项配型中
|
|
|
// ITKCALL(PREF_ask_char_values("Connor_AVIC_Check_XYLJ", &pref_count, &prefs));
|
|
|
// if (pref_count == 0) {
|
|
|
// WriteLog("未配置首选项Connor_NHL_Bomlimit");
|
|
|
// return customError;
|
|
|
// }
|
|
|
// else {
|
|
|
// char *typestr = "";
|
|
|
// ITKCALL(AOM_ask_value_string(item, "object_type", &typestr));
|
|
|
// int num = 0;
|
|
|
// for (int j = 0; j < pref_count; j++) {
|
|
|
// if (strcmp(prefs[j], typestr) == 0) {
|
|
|
// num++;
|
|
|
// }
|
|
|
// }
|
|
|
// if (num>0) {
|
|
|
// //已存在
|
|
|
// tag_t form = NULLTAG;
|
|
|
// ITKCALL(AOM_ask_value_tag(rev, "IMAN_master_form_rev", &form));
|
|
|
// if (form != NULLTAG) {
|
|
|
// char *valueform = "";
|
|
|
// ITKCALL(AOM_ask_value_string(form, "ac5_SelectionMarkers", &valueform));
|
|
|
// if (valueform != NULL) {
|
|
|
// if (strcmp("XY", valueform)==0 || strcmp("JY", valueform)==0) {
|
|
|
// if (strcmp("XY", valueform)==0) {
|
|
|
// //弹出窗口,待实现
|
|
|
// }
|
|
|
// else {
|
|
|
// char *id = "";
|
|
|
// ITKCALL(AOM_ask_value_string(rev, "item_id", &id));
|
|
|
// char * error = strcat(id, "为禁用物料,不允许引用");
|
|
|
// EMH_store_error_s2(EMH_severity_error,ITK_err,"提示", error);
|
|
|
// }
|
|
|
// }
|
|
|
// else {
|
|
|
// return 0;
|
|
|
// }
|
|
|
// }
|
|
|
// else {
|
|
|
// return 0;
|
|
|
// }
|
|
|
// }
|
|
|
// else {
|
|
|
// return 0;
|
|
|
// }
|
|
|
// }
|
|
|
// else {
|
|
|
// //不存在
|
|
|
// return 0;
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
//}
|