20240419lidy代码上传

master
李冬阳 1 year ago
parent 6a474871ff
commit 161e19925c

@ -0,0 +1,211 @@
#include "cJSON.h"
#include <tc/tc.h>
#include "epm_handler_common.h"
#include <ict/ict_userservice.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <tccore/aom.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <bom/bom.h>
#include "ps/ps.h";
#include "ps/vrule.h"
#include "sstream"
#include <tccore/grm.h>
#include "epm/epm.h"
#include "sa/sa.h"
#include "libxl.h"
#include <map>
#include "epm/signoff.h"
#include <ctime>
#include <vector>
#include <locale>
#include <codecvt>
#include "ae/dataset.h"
#include <iostream>
#include <stdlib.h>
#include <tccore/aom.h>
#include <tc/emh.h>
#include <ict/ict_userservice.h>
#include <tc/tc.h>
#include <tccore/tctype.h>
#include <sa/tcfile.h>
#include <ss/ss_errors.h>
#include <ae/datasettype.h>
#include "chint_Handler.h"
#include <regex>
#include <ics/ics.h>
#include "ado.h"
#include "ocilib.h"
#include <property/nr.h>
#include "CRUL_server_call_httpserver.h"
#include "common_itk_util.h"
#define EPM_HANDLER_COMMON
#define MAX_PATH_LENGTH 200
#define MAX_PRINTLINE_LENGTH 400000
void WriteLog3(logical debug, const char* format, ...)
{
va_list arg;
char tmp[MAX_PRINTLINE_LENGTH];
char date_string[MAX_PATH_LENGTH];
time_t now;
struct tm* p;
//get the message
memset(tmp, 0, sizeof(tmp));
va_start(arg, format);
vsprintf(tmp, format, arg);
va_end(arg);
//----------print to command window for trace--------//
//printf("%s\n", tmp);
printf("%s\n", tmp);
//print message to log file
TC_write_syslog("%s\n", tmp);
}
int CHINT_DRAWING_TO_SRM(EPM_action_message_t msg) {
tag_t task_tag = NULL_TAG,
root_task_tag = NULLTAG,
* attachments;;
task_tag = msg.task;
int att_cnt = 0, ifail = 0;
int c_sql_value_count = 0;
char** c_sql_values;
ITKCALL(PREF_ask_char_values("CHINT_SRM_SQL_CONNECT", &c_sql_value_count, &c_sql_values));
WriteLog3(true, "------------------------------------------------------------------------------------");
WriteLog3(true, "=========================");
WriteLog3(true, "CHINT_SRM_SQL_CONNECT start");
WriteLog3(true, "=========================");
EPM_ask_root_task(task_tag, &root_task_tag);
EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments);
WriteLog3(true, "流程目标下的对象数量:%d", att_cnt);
for (int i = 0; i < att_cnt; i++)
{
tag_t tagt = NULLTAG;
tagt = attachments[i];
char* type1;
//获取版本下的数据集
int dataset_num = 0;
tag_t* dataset_tags = NULL;
char* tempValue = NULL;
char taskpuid[56] = "\0";
ITK__convert_tag_to_uid(task_tag, &tempValue);
tc_strcpy(taskpuid, tempValue);
ITKCALL(AOM_ask_value_string(tagt, "object_type", &type1));
printf("object_type=%s\n", type1);
//获取当前登入人组
char* groupName = NULL;
tag_t t_group = NULLTAG;
ITKCALL(POM_ask_group(&groupName, &t_group));
printf("g=%s\n", groupName);
//获取当前登入人的名称和id
char* name;
char* id;
tag_t user;
POM_get_user(&name, &user);
POM_get_user_id(&id);
printf("name================%s\n", name);
printf("id================%s\n", id);
if (strcmp("ZT2_ProcureRevision", type1) == 0) {
//判断是否存在dwg文件
//获取版本下的数据集
char* file_name;
char* origin_file_name;
tag_t* ref_object = NULL;
int n_found = 0;
ITKCALL(AOM_ask_value_tags(tagt, "IMAN_specification", &dataset_num, &dataset_tags));
for (int k = 0; k < dataset_num; k++)
{
ITKCALL(AOM_ask_value_string(dataset_tags[k], "object_name", &file_name));
printf("file_name=%s\n", file_name);
if (strstr(file_name, "pdf") || strstr(file_name, "PDF")) {
//获取数据集文件名称
ITKCALL(AOM_ask_value_string(dataset_tags[k], "current_name", &origin_file_name));
ITKCALL(AE_ask_dataset_named_refs(dataset_tags[k], &n_found, &ref_object));
printf("n_found=%d\n", n_found);
if (n_found > 0) {
//存在.dwg数据集
//DFL_ DRAWING_TO_SRM_TASK存储信息
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 ifail;
}
else {
printf("提示:中间数据表访问成功\n");
char sql1[1024] = "\0";
sprintf(sql1, "insert into CHINT_DRAWING_TO_SRM_TASK(tasksource,flowid,status,factory,username,userid) values ('%s','%s','%s','%s','%s','%s')", "工作流程", taskpuid, "未开始", groupName, name, id);
printf("提示:sql1==%s\n", sql1);
if (ExecuteSQLNoInputParam(sql1) == -1)
{
printf("提示:数据插入 失败, %s \n", sql1);
ifail = 1;
}
else {
ExecuteSQLNoInputParam("commit");
}
break;
}
}
}
}
break;//如果发起多个对象,只写一条数据
}
else if (strcmp("ZT2_Design3DRevision", type1) == 0) {
//判断是否存在物料
int material_num = 0;
tag_t* material_tags = NULL;
ITKCALL(AOM_ask_value_tags(tagt, "representation_for", &material_num, &material_tags));
if (material_num > 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 ifail;
}
else {
printf("提示:中间数据表访问成功\n");
char sql1[1024] = "\0";
sprintf(sql1, "insert into CHINT_DRAWING_TO_SRM_TASK(tasksource,flowid,status,factory,username,userid) values ('%s','%s','%s','%s','%s','%s')", "工作流程", taskpuid, "未开始", groupName, name, id);
printf("提示:sql1==%s\n", sql1);
if (ExecuteSQLNoInputParam(sql1) == -1)
{
printf("提示:数据插入 失败, %s \n", sql1);
ifail = 1;
}
else {
ExecuteSQLNoInputParam("commit");
}
break;
}
}
}
}
if (ifail == 1)
{
EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, "插入数据失败\n"); //错误弹窗
}
DOFREE(attachments);
WriteLog3(true, "=========================");
WriteLog3(true, "DFL_DRAWING_TO_SRM end");
WriteLog3(true, "=========================");
return ifail;
}

@ -17,6 +17,7 @@ string callHttpserver(string signinfoJsonString, string url){
CURLcode res; CURLcode res;
curl = curl_easy_init(); curl = curl_easy_init();
std::stringstream out; std::stringstream out;
string result = "";
if (curl) { if (curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
@ -32,13 +33,18 @@ string callHttpserver(string signinfoJsonString, string url){
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if (res != 0) { if (res != 0) {
string errMessage = curl_easy_strerror(res); string errMessage = curl_easy_strerror(res);
result.append("errMessage =>").append(errMessage);
} }
printf("·µ»ØÖµ£º%d\n", res); printf("·µ»ØÖµ£º%d\n", res);
char code[16] = "";
sprintf(code, "%d", res);
result.append("\n·µ»ØÖµ =>").append(code);
} }
string str_json = out.str(); string str_json = out.str();
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
printf("str_json===>%s\n", str_json.c_str()); printf("str_json===>%s\n", str_json.c_str());
return str_json; result.append("\nstr_json =>").append(str_json);
return result;
} }
string sendOA() { string sendOA() {

@ -185,13 +185,13 @@ string getCshVal(string name,string code) {
string schVal = ""; string schVal = "";
//cmdÖ¸Áî //cmdÖ¸Áî
char cmd[256] = ""; char cmd[256] = "";
strcpy(cmd, "java -jar \""); strcpy(cmd, "java -jar ");
//strcat(cmd, jar_file); //strcat(cmd, jar_file);
strcat(cmd, getenv("TC_ROOT")); strcat(cmd, getenv("TC_ROOT"));
strcat(cmd, "\\bin\\findCshSql.jar"); strcat(cmd, "\\bin\\findCshSql.jar");
strcat(cmd, "\" "); strcat(cmd, "\" \"");
strcat(cmd, name.c_str()); strcat(cmd, name.c_str());
strcat(cmd, "\" "); strcat(cmd, "\" \"");
strcat(cmd, code.c_str()); strcat(cmd, code.c_str());
printf("·¾¶:\n%s\n", cmd); printf("·¾¶:\n%s\n", cmd);
char buf[8000] = { 0 }; char buf[8000] = { 0 };
@ -311,7 +311,8 @@ void setZljyx(string gxbm2, string th,string lastId,string name,tag_t towGx) {
} }
} }
else if (!parameterization.empty()) { else if (!parameterization.empty()) {
string csh = getCshVal(lastId, code); //string csh = getCshVal(lastId, code);
string csh = getCshVal(lastId, parameterization);
bean.mentResult = csh; bean.mentResult = csh;
} }
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -58,7 +58,7 @@ bool isTcm(tag_t mantr) {
int releaseCount = 0; int releaseCount = 0;
tag_t* releaseTags = NULL; tag_t* releaseTags = NULL;
//判断子件是否发布 //判断子件是否发布
AOM_ask_value_tags(mantr, "release_status_list", &releaseCount, &releaseTags); ITKCALL(AOM_ask_value_tags(mantr, "release_status_list", &releaseCount, &releaseTags));
if (releaseCount > 0) { if (releaseCount > 0) {
return true; return true;
} }
@ -71,7 +71,7 @@ bool isBomViewTcm(tag_t mantr) {
int structs = 0; int structs = 0;
tag_t *structure_revisions; tag_t *structure_revisions;
//版本有BOM视图且发布 //版本有BOM视图且发布
AOM_ask_value_tags(mantr, "structure_revisions", &structs, &structure_revisions); ITKCALL(AOM_ask_value_tags(mantr, "structure_revisions", &structs, &structure_revisions));
if (structs > 0) { if (structs > 0) {
return isTcm(structure_revisions[0]); return isTcm(structure_revisions[0]);
} }
@ -322,13 +322,13 @@ void askLineVal(NodeBean& bean, tag_t bom_line, tag_t designRev, string& errBuff
if (part != NULLTAG) { if (part != NULLTAG) {
//BOM_writer //BOM_writer
char* name, *partId, **sealeds, **factorys, *matnr, **procureType; char* name, *partId, **sealeds, **factorys, *matnr, **procureType;
AOM_refresh(part, false); ITKCALL(AOM_refresh(part, false));
AOM_ask_value_string(part, "object_name", &name); ITKCALL(AOM_ask_value_string(part, "object_name", &name));
printf("name%s\n", name); printf("name%s\n", name);
int cnt2, numFac, cnt3; int cnt2, numFac, cnt3;
//检查物料是否可用 //检查物料是否可用
ITKCALL(AOM_ask_value_string(part, "item_id", &partId)); ITKCALL(AOM_ask_value_string(part, "item_id", &partId));
AOM_ask_value_string(part, "zt2_MaterialNo", &matnr); ITKCALL(AOM_ask_value_string(part, "zt2_MaterialNo", &matnr));
if (strcmp(matnr, "") == 0) { if (strcmp(matnr, "") == 0) {
string buffErr = ""; string buffErr = "";
buffErr.append("物料:").append(partId).append("/").append(name).append("没有物料编码.\n"); buffErr.append("物料:").append(partId).append("/").append(name).append("没有物料编码.\n");
@ -340,9 +340,9 @@ void askLineVal(NodeBean& bean, tag_t bom_line, tag_t designRev, string& errBuff
//return; //return;
} }
boolean numFlag = true; boolean numFlag = true;
AOM_ask_value_strings(part, "zt2_SZSealedornot", &cnt2, &sealeds); ITKCALL(AOM_ask_value_strings(part, "zt2_SZSealedornot", &cnt2, &sealeds));
AOM_ask_value_strings(part, "zt2_SZFactory", &numFac, &factorys); ITKCALL(AOM_ask_value_strings(part, "zt2_SZFactory", &numFac, &factorys));
AOM_ask_value_strings(part, "zt2_SZProcuretype", &cnt3, &procureType); //°üº¬×ÔÖÆ ITKCALL(AOM_ask_value_strings(part, "zt2_SZProcuretype", &cnt3, &procureType)); //包含自制
for (int i = 0; i < numFac; i++) { for (int i = 0; i < numFac; i++) {
if (strcmp(factorys[i], "M060") == 0) { if (strcmp(factorys[i], "M060") == 0) {
numFlag = false; numFlag = false;
@ -495,7 +495,7 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName
ITKCALL(AOM_ask_value_string(designRev, "object_name", &object_name)); ITKCALL(AOM_ask_value_string(designRev, "object_name", &object_name));
//printf("type===>%s\n", type); //printf("type===>%s\n", type);
if (strcmp(type, "ZT2_Design3DRevision") == 0) { if (strcmp(type, "ZT2_Design3DRevision") == 0) {
AOM_ask_value_string(designRev, "zt2_Diagram", &zt2_Diagram); ITKCALL(AOM_ask_value_string(designRev, "zt2_Diagram", &zt2_Diagram));
if (strcmp(zt2_Diagram, "Y") == 0 || strcmp(zt2_Diagram, "") == 0) { if (strcmp(zt2_Diagram, "Y") == 0 || strcmp(zt2_Diagram, "") == 0) {
return; return;
} }
@ -517,8 +517,8 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName
askLineVal(pBean, bom_line, designRev, errBuff, flagMat); askLineVal(pBean, bom_line, designRev, errBuff, flagMat);
tag_t tagUser; tag_t tagUser;
char *tagId; char *tagId;
AOM_ask_value_tag(designRev, "owning_user", &tagUser); ITKCALL(AOM_ask_value_tag(designRev, "owning_user", &tagUser));
AOM_ask_value_string(tagUser, "user_id", &tagId); ITKCALL(AOM_ask_value_string(tagUser, "user_id", &tagId));
//检查权限 //检查权限
if (strcmp(type, "ZT2_Design3DRevision") == 0 && strcmp(loginUserId, tagId) != 0 && strstr(itemId, "2ZD") == NULL) { if (strcmp(type, "ZT2_Design3DRevision") == 0 && strcmp(loginUserId, tagId) != 0 && strstr(itemId, "2ZD") == NULL) {
pBean.isOutBuy = true; pBean.isOutBuy = true;
@ -535,7 +535,7 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName
} }
} }
if (strstr(itemId, "1ZD") != NULL) { if (strstr(itemId, "1ZD") != NULL) {
AOM_ask_value_string(designRev, "zt2_Source", &source); ITKCALL(AOM_ask_value_string(designRev, "zt2_Source", &source));
if (strcmp(source, "S2") == 0 || strcmp(source, "外购") == 0) { if (strcmp(source, "S2") == 0 || strcmp(source, "外购") == 0) {
pBean.isOutBuy = true; pBean.isOutBuy = true;
return; return;
@ -557,7 +557,7 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName
strstr(itemId, "2ZD") != NULL || strstr(itemId, "4ZD") != NULL)) { strstr(itemId, "2ZD") != NULL || strstr(itemId, "4ZD") != NULL)) {
//原材料展开 //原材料展开
char *zt2_MaterialMark; char *zt2_MaterialMark;
AOM_ask_value_string(designRev, "zt2_MaterialMark", &zt2_MaterialMark); ITKCALL(AOM_ask_value_string(designRev, "zt2_MaterialMark", &zt2_MaterialMark));
//String zt2_MaterialMark = rev.getProperty("zt2_MaterialMark") //String zt2_MaterialMark = rev.getProperty("zt2_MaterialMark")
string sql = "select materialno, materialutilization, materialunit FROM %s where materialmark = '%s'"; string sql = "select materialno, materialutilization, materialunit FROM %s where materialmark = '%s'";
char selectRxfs[500]; char selectRxfs[500];
@ -581,8 +581,8 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName
string materialutilization = outputValue1[t][1]; string materialutilization = outputValue1[t][1];
string materialunit = outputValue1[t][2]; string materialunit = outputValue1[t][2];
tag_t material, materialRev; tag_t material, materialRev;
ITEM_find_item(materialno.c_str(), &material); ITKCALL(ITEM_find_item(materialno.c_str(), &material));
ITEM_ask_latest_rev(material, &materialRev); ITKCALL(ITEM_ask_latest_rev(material, &materialRev));
string bl_qty = getTyjZl(bom_line, materialutilization, designRev, errBuff); string bl_qty = getTyjZl(bom_line, materialutilization, designRev, errBuff);
printf("bl_qty%s\n", bl_qty.c_str()); printf("bl_qty%s\n", bl_qty.c_str());
NodeBean cBean; NodeBean cBean;
@ -602,20 +602,20 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName
bool ret = regex_match(item_id, result, qq_reg2); bool ret = regex_match(item_id, result, qq_reg2);
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
logical suppressed; logical suppressed;
AOM_ask_value_logical(c_line_tags[i], "bl_is_occ_suppressed", &suppressed); ITKCALL(AOM_ask_value_logical(c_line_tags[i], "bl_is_occ_suppressed", &suppressed));
if (suppressed) { if (suppressed) {
continue; continue;
} }
//修改过之后之前已经是解包的状态了 //修改过之后之前已经是解包的状态了
logical flag; logical flag;
BOM_line_is_packed(c_line_tags[i], &flag); ITKCALL(BOM_line_is_packed(c_line_tags[i], &flag));
//printf("flag===>%d\n", flag); //printf("flag===>%d\n", flag);
if (flag) { if (flag) {
int count = 0; int count = 0;
char *topNum; char *topNum;
AOM_ask_value_string(c_line_tags[i], "bl_quantity", &topNum); ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_quantity", &topNum));
tag_t* packLines; tag_t* packLines;
BOM_line_ask_packed_lines(c_line_tags[i], &count, &packLines); ITKCALL(BOM_line_ask_packed_lines(c_line_tags[i], &count, &packLines));
for (int t = 0; t < count; t++) { for (int t = 0; t < count; t++) {
tag_t c_Rev; tag_t c_Rev;
ITKCALL(AOM_ask_value_tag(packLines[t], "bl_line_object", &c_Rev)); ITKCALL(AOM_ask_value_tag(packLines[t], "bl_line_object", &c_Rev));
@ -1239,9 +1239,11 @@ string createEbom(NodeBean topBean, boolean isTop, string &hasChange, map<string
int bvr_count; int bvr_count;
ITKCALL(ITEM_rev_list_bom_view_revs(mantr, &bvr_count, &bvr_list)); ITKCALL(ITEM_rev_list_bom_view_revs(mantr, &bvr_count, &bvr_list));
//没有BOM视图创建 //没有BOM视图创建
POM_AM__set_application_bypass(true);
if (bvr_count == 0) { if (bvr_count == 0) {
tag_t newView, newViewBvr, pitem, dsuser; tag_t newView, newViewBvr, pitem, dsuser;
ITKCALL(ITEM_ask_item_of_rev(mantr, &pitem)); ITKCALL(ITEM_ask_item_of_rev(mantr, &pitem));
POM_AM__set_application_bypass(true);
ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView));
ITKCALL(AOM_save(newView)); ITKCALL(AOM_save(newView));
ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, mantr, &newViewBvr)); ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, mantr, &newViewBvr));
@ -1297,7 +1299,7 @@ string createEbom(NodeBean topBean, boolean isTop, string &hasChange, map<string
printf("bom_line%s\n", bom_string); printf("bom_line%s\n", bom_string);
ITKCALL(BOM_line_add(bom_line, NULL, cBean.mantr, NULL, &cLine)); ITKCALL(BOM_line_add(bom_line, NULL, cBean.mantr, NULL, &cLine));
if (cLine != NULLTAG) { if (cLine != NULLTAG) {
ITKCALL(AOM_lock(cLine)); AOM_lock(cLine);
if (cBean.packNum > 0) { if (cBean.packNum > 0) {
string num = cBean.bl_quantity; string num = cBean.bl_quantity;
num = to_string(cBean.topNum / cBean.packNum); num = to_string(cBean.topNum / cBean.packNum);
@ -1312,10 +1314,10 @@ string createEbom(NodeBean topBean, boolean isTop, string &hasChange, map<string
ITKCALL(AOM_set_value_string(cLine, "bl_plmxml_occ_xform", cBean.bl_plmxml_occ_xform)); ITKCALL(AOM_set_value_string(cLine, "bl_plmxml_occ_xform", cBean.bl_plmxml_occ_xform));
ITKCALL(AOM_set_value_string(cLine, "bl_sequence_no", cBean.bl_sequence_no.c_str())); ITKCALL(AOM_set_value_string(cLine, "bl_sequence_no", cBean.bl_sequence_no.c_str()));
ITKCALL(AOM_set_value_string(cLine, "bl_occ_zt2_DtoE", "DBOM转换")); ITKCALL(AOM_set_value_string(cLine, "bl_occ_zt2_DtoE", "DBOM转换"));
ITKCALL(AOM_save(cLine)); (AOM_save(cLine));
//最后unlock //最后unlock
ITKCALL(AOM_unlock(cLine)); (AOM_unlock(cLine));
ITKCALL(AOM_refresh(cLine, FALSE)); (AOM_refresh(cLine, FALSE));
} }
else { else {
printf("搭建BOM失败\n"); printf("搭建BOM失败\n");
@ -1586,8 +1588,29 @@ int DbomToEMethod(void* returnValue) {
} }
if (needAs && !flag) { if (needAs && !flag) {
printf("=======TEST======\n"); printf("=======TEST======\n");
//Éý°æ²¢·¢²¼ tag_t* bvr_list = NULL;
ITKCALL(ITEM_copy_rev(mantr, NULL, &mantr)); int bvr_count = 0;
ITKCALL(ITEM_rev_list_bom_view_revs(mantr, &bvr_count, &bvr_list));
if (isTcm(bvr_list[0])) {
if (isTcm(mantr)) {
ITKCALL(ITEM_copy_rev(mantr, NULL, &mantr));
}
else {
char *os = NULL;
ITKCALL(AOM_ask_value_string(mantr, "object_string", &os));
POM_AM__set_application_bypass(false);
close();
printf("释放数据库成功\n");
printf("子line数量 %d \n", topBean.childs.size());
string buff = errBuff;
buff.append(os).append(" 版本未发布,无法升版\n");
printf("buff===>%s\n", buff.c_str());
*((char**)returnValue) = (char*)MEM_alloc((strlen(buff.c_str()) + 1) * sizeof(char));
tc_strcpy(*((char**)returnValue), buff.c_str());
return ifail;
}
}
TCMAndOwner(mantr); TCMAndOwner(mantr);
//return; //return;
} }

@ -264,14 +264,14 @@ tag_t send1(tag_t rev, string now,
//for (it = general_maps.begin(); it != general_maps.end(); it++) { //for (it = general_maps.begin(); it != general_maps.end(); it++) {
char* item_id, *object_name, *zt2_DrawingNo1, *zt2_MaterialMark, *zt2_ProductModel char* item_id, *object_name, *zt2_DrawingNo1, *zt2_MaterialMark, *zt2_ProductModel
, *object_desc, *zt2_SurfaceTreatment, *zt2_Source; , *object_desc, *zt2_SurfaceTreatment, *zt2_Source;
AOM_ask_value_string(rev, "item_id", &item_id); //groupId ITKCALL(AOM_ask_value_string(rev, "item_id", &item_id)); //groupId
AOM_ask_value_string(rev, "object_name", &object_name); ITKCALL(AOM_ask_value_string(rev, "object_name", &object_name));
AOM_ask_value_string(rev, "zt2_DrawingNo", &zt2_DrawingNo1); ITKCALL(AOM_ask_value_string(rev, "zt2_DrawingNo", &zt2_DrawingNo1));
AOM_ask_value_string(rev, "zt2_MaterialMark", &zt2_MaterialMark); ITKCALL(AOM_ask_value_string(rev, "zt2_MaterialMark", &zt2_MaterialMark));
AOM_ask_value_string(rev, "zt2_ProductModel", &zt2_ProductModel); ITKCALL(AOM_ask_value_string(rev, "zt2_ProductModel", &zt2_ProductModel));
AOM_ask_value_string(rev, "object_desc", &object_desc); ITKCALL(AOM_ask_value_string(rev, "object_desc", &object_desc));
AOM_ask_value_string(rev, "zt2_SurfaceTreatment", &zt2_SurfaceTreatment); ITKCALL(AOM_ask_value_string(rev, "zt2_SurfaceTreatment", &zt2_SurfaceTreatment));
AOM_UIF_ask_value(rev, "zt2_Source", &zt2_Source); ITKCALL(AOM_UIF_ask_value(rev, "zt2_Source", &zt2_Source));
PMPC m_pmpc; PMPC m_pmpc;
vector<PRD> m_prds; vector<PRD> m_prds;
//if (strcmp(item_id, "1ZDB") == 0) { //if (strcmp(item_id, "1ZDB") == 0) {
@ -282,7 +282,7 @@ tag_t send1(tag_t rev, string now,
string pmpcCode = m_pmpc.m_code; string pmpcCode = m_pmpc.m_code;
string prhCode = m_pmpc.pmpcPrhCode; string prhCode = m_pmpc.pmpcPrhCode;
string pmpcType = m_pmpc.pmpcMType; string pmpcType = m_pmpc.pmpcMType;
printf("pmpcType===>%s\n", pmpcType.c_str()); WriteTcLog("pmpcType===>%s\n", pmpcType.c_str());
if (pmpcType.length() == 0) { if (pmpcType.length() == 0) {
return NULLTAG; return NULLTAG;
} }
@ -315,7 +315,7 @@ tag_t send1(tag_t rev, string now,
char* qry_entries[1] = { "描述" }, *qry_values[1] = { (char *)queryMsg.c_str() }; char* qry_entries[1] = { "描述" }, *qry_values[1] = { (char *)queryMsg.c_str() };
int n_found; int n_found;
ITKCALL(QRY_execute(query, 1, qry_entries, qry_values, &n_found, &tags)); ITKCALL(QRY_execute(query, 1, qry_entries, qry_values, &n_found, &tags));
printf("n_found===>%d %s \n", n_found, queryMsg.c_str()); WriteTcLog("n_found===>%d %s \n", n_found, queryMsg.c_str());
if (n_found > 0) { if (n_found > 0) {
return tags[0]; return tags[0];
} }
@ -350,7 +350,7 @@ tag_t send1(tag_t rev, string now,
if (count2 > 0) { if (count2 > 0) {
projn = outputValue2[0][0]; projn = outputValue2[0][0];
} }
printf("projn===>%s\n", projn); WriteTcLog("projn===>%s\n", projn);
json.append("\"Code\":\"").append(projn).append("\","); json.append("\"Code\":\"").append(projn).append("\",");
//string spec = specs[i]; // 非必填 //string spec = specs[i]; // 非必填
string feature = "\"Feature\":{"; string feature = "\"Feature\":{";
@ -394,11 +394,11 @@ tag_t send1(tag_t rev, string now,
data.append("\"Data\":[{"); data.append("\"Data\":[{");
data.append("\"PrhCode").append("\":\"").append(prhCode).append("\","); data.append("\"PrhCode").append("\":\"").append(prhCode).append("\",");
data.append("\"PmpcCode").append("\":\"").append(pmpcCode).append("\","); data.append("\"PmpcCode").append("\":\"").append(pmpcCode).append("\",");
data.append("\"PmpcType").append("\":\"").append(pmpcType).append("\","); data.append("\"PmpcType").append("\":\"").append("ZPFG").append("\",");//pmpcType
data.append("\"UnitCode").append("\":\"").append(unitCode).append("\","); data.append("\"UnitCode").append("\":\"").append(unitCode).append("\",");
data.append("\"CompanyCode").append("\":\"").append(companyCode).append("\","); data.append("\"CompanyCode").append("\":\"").append(companyCode).append("\",");
data.append("\"UserCode").append("\":\"").append(user).append("\","); data.append("\"UserCode").append("\":\"").append(user).append("\",");
data.append("\"MP").append("\":\"").append(mp).append("\","); data.append("\"MP").append("\":\"").append("M").append("\",");//mp
data.append(feature); data.append(feature);
data.append("\"ProductGroupCode").append("\":\"").append("\","); data.append("\"ProductGroupCode").append("\":\"").append("\",");
data.append("\"AssistUnitCode").append("\":\"").append("\","); data.append("\"AssistUnitCode").append("\":\"").append("\",");
@ -431,6 +431,7 @@ tag_t send1(tag_t rev, string now,
char selectGyId[400]; char selectGyId[400];
sprintf(selectGyId, insertSql.c_str(), projn, newUid, pmpcCode.c_str(), "", goodsName.c_str(), "ST", companyCode.c_str(), sprintf(selectGyId, insertSql.c_str(), projn, newUid, pmpcCode.c_str(), "", goodsName.c_str(), "ST", companyCode.c_str(),
bpNo.c_str(), spec.c_str(), "", "", user_id, now.c_str(), "审核中", ""); bpNo.c_str(), spec.c_str(), "", "", user_id, now.c_str(), "审核中", "");
WriteTcLog("selectGyId===>%s", selectGyId);
ExecuteSQLNoInputParam(selectGyId); ExecuteSQLNoInputParam(selectGyId);
ExecuteSQLNoInputParam("commit"); ExecuteSQLNoInputParam("commit");
return newRev; return newRev;
@ -600,7 +601,7 @@ void replaceBom(EBomBean& childPm, map<string, tag_t>& map, int len, tag_t dcpro
tag_t ebom_window = NULLTAG; tag_t ebom_window = NULLTAG;
tag_t bom_line = NULLTAG, *c_line_tags; tag_t bom_line = NULLTAG, *c_line_tags;
tag_t* bvr_list = NULL; tag_t* bvr_list = NULL;
(ITEM_rev_list_bom_view_revs(axqPmatnr, &bvr_count, &bvr_list)); ITKCALL(ITEM_rev_list_bom_view_revs(axqPmatnr, &bvr_count, &bvr_list));
printf("bvr_count=%d\n", bvr_count); printf("bvr_count=%d\n", bvr_count);
//没有物料视图的时候需要创建一个 //没有物料视图的时候需要创建一个
if (bvr_count == 0) { if (bvr_count == 0) {
@ -612,24 +613,24 @@ void replaceBom(EBomBean& childPm, map<string, tag_t>& map, int len, tag_t dcpro
AOM_save(newViewBvr); AOM_save(newViewBvr);
AOM_save(axqPmatnr); AOM_save(axqPmatnr);
tag_t dsuser, *structure_revisions, *bom_view_tags; tag_t dsuser, *structure_revisions, *bom_view_tags;
AOM_ask_value_tag(tzRev, "owning_user", &dsuser); ITKCALL(AOM_ask_value_tag(tzRev, "owning_user", &dsuser));
tag_t defGroup; tag_t defGroup;
ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup));
ITKCALL(AOM_set_ownership(newView, dsuser, defGroup)); ITKCALL(AOM_set_ownership(newView, dsuser, defGroup));
ITKCALL(AOM_set_ownership(newViewBvr, dsuser, defGroup)); ITKCALL(AOM_set_ownership(newViewBvr, dsuser, defGroup));
//return; //return;
(ITEM_rev_list_bom_view_revs(axqPmatnr, &bvr_count, &bvr_list)); ITKCALL(ITEM_rev_list_bom_view_revs(axqPmatnr, &bvr_count, &bvr_list));
} }
(BOM_create_window(&ebom_window)); ITKCALL(BOM_create_window(&ebom_window));
(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //¶¥²ãbom»ñÈ¡ ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //¶¥²ãbom»ñÈ¡
//ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &mantr)); //ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &mantr));
//线圈转PBOM时候的特殊处理:申请物料 A、B、C项线圈 然后把原来的线圈的子项拆分数量复制 //线圈转PBOM时候的特殊处理:申请物料 A、B、C项线圈 然后把原来的线圈的子项拆分数量复制
ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags));
printf("int===>%d\n", len); WriteTcLog("int===>%d\n", len);
vector<tag_t> newPAmatnrs; vector<tag_t> newPAmatnrs;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
//创建A项物料 //创建A项物料
printf("names[i]===>%s\n", names[i]); WriteTcLog("names[i]===>%s\n", names[i]);
tag_t newPAmatnr = send1(tzRev, now1, user_id, jsons, grpId, specs[0], names[i], idss[i], dcproxy); tag_t newPAmatnr = send1(tzRev, now1, user_id, jsons, grpId, specs[0], names[i], idss[i], dcproxy);
newPAmatnrs.push_back(newPAmatnr); newPAmatnrs.push_back(newPAmatnr);
//如果名称中包含 线的 拆分后多余的放到最后 //如果名称中包含 线的 拆分后多余的放到最后
@ -651,11 +652,12 @@ void replaceBom(EBomBean& childPm, map<string, tag_t>& map, int len, tag_t dcpro
ITKCALL(BOM_save_window(ebom_window)); ITKCALL(BOM_save_window(ebom_window));
ITKCALL(BOM_close_window(ebom_window)); ITKCALL(BOM_close_window(ebom_window));
for (int i = 0; i < jsons.size(); i++) { for (int i = 0; i < jsons.size(); i++) {
printf("jsons ===> %s \n", jsons[i].c_str()); WriteTcLog("jsons ===> %s \n", jsons[i].c_str());
string url = "http://10.128.20.35:9002/Post/PLM_Goods"; string url = "http://10.128.20.35:9002/Post/PLM_Goods";
string jsonUf = G2U222(jsons[i].c_str()); string jsonUf = G2U222(jsons[i].c_str());
//调用接口申请物料 //调用接口申请物料
string msg = callHttpserver(jsonUf, url); string msg = callHttpserver(jsonUf, url);
WriteTcLog("result===>%s\n", msg.c_str());
} }
} }
} }
@ -1114,10 +1116,12 @@ tag_t saveAsUpdate(tag_t eRev, tag_t newChild) {
void createAXxq(tag_t eRev, tag_t pRev, int len, tag_t dcproxy) { void createAXxq(tag_t eRev, tag_t pRev, int len, tag_t dcproxy) {
tag_t owning_group, owning_user; tag_t owning_group, owning_user;
char* grpId, *user_id; char* grpId = NULL, *user_id = NULL, *os = NULL;
int num = 0; int num = 0;
tag_t* mantrs, designRev; tag_t* mantrs, designRev;
string errBuff; string errBuff;
ITKCALL(AOM_ask_value_string(eRev, "object_string", &os));
WriteTcLog("createAXxq:%s", os);
ITKCALL(AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs)); ITKCALL(AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs));
if (num > 0) { if (num > 0) {
tag_t tzRev = mantrs[0]; tag_t tzRev = mantrs[0];
@ -1127,7 +1131,7 @@ void createAXxq(tag_t eRev, tag_t pRev, int len, tag_t dcproxy) {
ITKCALL(AOM_ask_value_string(owning_user, "user_id", &user_id)); ITKCALL(AOM_ask_value_string(owning_user, "user_id", &user_id));
vector<string> specs; vector<string> specs;
getSpecs(tzRev, specs); getSpecs(tzRev, specs);
printf("»ñÈ¡¹æ¸ñ½áÊø \n"); WriteTcLog("»ñÈ¡¹æ¸ñ½áÊø:%zd\n", specs.size());
time_t now; time_t now;
struct tm* p; struct tm* p;
time(&now); time(&now);
@ -1144,8 +1148,8 @@ void createAXxq(tag_t eRev, tag_t pRev, int len, tag_t dcproxy) {
tag_t ebom_window = NULLTAG; tag_t ebom_window = NULLTAG;
tag_t bom_line = NULLTAG, *c_line_tags; tag_t bom_line = NULLTAG, *c_line_tags;
tag_t* bvr_list = NULL; tag_t* bvr_list = NULL;
(ITEM_rev_list_bom_view_revs(axqPmatnr, &bvr_count, &bvr_list)); ITKCALL(ITEM_rev_list_bom_view_revs(axqPmatnr, &bvr_count, &bvr_list));
printf("bvr_count=%d\n", bvr_count); WriteTcLog("bvr_count=%d\n", bvr_count);
if (bvr_count == 0) { if (bvr_count == 0) {
tag_t newView, newViewBvr, pitem; tag_t newView, newViewBvr, pitem;
@ -1157,22 +1161,22 @@ void createAXxq(tag_t eRev, tag_t pRev, int len, tag_t dcproxy) {
AOM_save(axqPmatnr); AOM_save(axqPmatnr);
//return; //return;
tag_t dsuser, *structure_revisions, *bom_view_tags; tag_t dsuser, *structure_revisions, *bom_view_tags;
AOM_ask_value_tag(tzRev, "owning_user", &dsuser); ITKCALL(AOM_ask_value_tag(tzRev, "owning_user", &dsuser));
tag_t defGroup; tag_t defGroup;
ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup));
ITKCALL(AOM_set_ownership(newView, dsuser, defGroup)); ITKCALL(AOM_set_ownership(newView, dsuser, defGroup));
ITKCALL(AOM_set_ownership(newViewBvr, dsuser, defGroup)); ITKCALL(AOM_set_ownership(newViewBvr, dsuser, defGroup));
(ITEM_rev_list_bom_view_revs(axqPmatnr, &bvr_count, &bvr_list)); ITKCALL(ITEM_rev_list_bom_view_revs(axqPmatnr, &bvr_count, &bvr_list));
} }
(BOM_create_window(&ebom_window)); ITKCALL(BOM_create_window(&ebom_window));
(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //¶¥²ãbom»ñÈ¡ ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //¶¥²ãbom»ñÈ¡
//ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &mantr)); //ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &mantr));
ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags));
printf("int===>%d\n", len); WriteTcLog("int===>%d\n", len);
vector<tag_t> newPAmatnrs; vector<tag_t> newPAmatnrs;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
//创建A项物料 idss[i] //创建A项物料 idss[i]
printf("names[i]===>%s\n", names[i]); WriteTcLog("names[i]===>%s\n", names[i]);
tag_t newPAmatnr = send1(tzRev, now1, user_id, jsons, grpId, specs[0], names[i], idss[i], dcproxy); tag_t newPAmatnr = send1(tzRev, now1, user_id, jsons, grpId, specs[0], names[i], idss[i], dcproxy);
newPAmatnrs.push_back(newPAmatnr); newPAmatnrs.push_back(newPAmatnr);
boolean lastFlag = false; boolean lastFlag = false;
@ -1193,10 +1197,11 @@ void createAXxq(tag_t eRev, tag_t pRev, int len, tag_t dcproxy) {
ITKCALL(BOM_save_window(ebom_window)); ITKCALL(BOM_save_window(ebom_window));
ITKCALL(BOM_close_window(ebom_window)); ITKCALL(BOM_close_window(ebom_window));
for (int i = 0; i < jsons.size(); i++) { for (int i = 0; i < jsons.size(); i++) {
printf("jsons ===> %s \n", jsons[i].c_str()); WriteTcLog("jsons ===> %s \n", jsons[i].c_str());
string url = "http://10.128.20.35:9002/Post/PLM_Goods"; string url = "http://10.128.20.35:9002/Post/PLM_Goods";
string jsonUf = G2U222(jsons[i].c_str()); string jsonUf = G2U222(jsons[i].c_str());
string msg = callHttpserver(jsonUf, url); string msg = callHttpserver(jsonUf, url);
WriteTcLog("result===>%s\n", msg.c_str());
} }
} }
} }
@ -1438,8 +1443,8 @@ tag_t saveAsMaterial(EBomUpBean topBean, boolean isTop,
printf("dddd=====\n"); printf("dddd=====\n");
return pMaterial; return pMaterial;
} }
printf("dBomMesg[%d]", dBomMesg.size()); printf("eBomMesg[%d]", dBomMesg.size());
printf("eBomMesg[%d]\n", eBomMesg.size()); printf("pBomMesg[%d]\n", eBomMesg.size());
boolean needAs = false; boolean needAs = false;
if (dBomMesg.size() != eBomMesg.size()) { if (dBomMesg.size() != eBomMesg.size()) {
//升版 + 发布 //升版 + 发布
@ -1664,17 +1669,23 @@ void copyBomLine(tag_t matnrTop, tag_t otherPbom) {
ITKCALL(BOM_create_window(&ebom_window2)); ITKCALL(BOM_create_window(&ebom_window2));
ITKCALL(BOM_set_window_top_line_bvr(ebom_window2, bvr_list2[0], &bom_line2)); //顶层bom获取 ITKCALL(BOM_set_window_top_line_bvr(ebom_window2, bvr_list2[0], &bom_line2)); //顶层bom获取
ITKCALL(BOM_line_ask_all_child_lines(bom_line2, &c_line_count2, &c_line_tags2)); ITKCALL(BOM_line_ask_all_child_lines(bom_line2, &c_line_count2, &c_line_tags2));
POM_AM__set_application_bypass(true);
for (int i = 0; i < c_line_count2; i++) { for (int i = 0; i < c_line_count2; i++) {
BOM_line_cut(c_line_tags2[i]); ITKCALL(BOM_line_cut(c_line_tags2[i]));
} }
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
tag_t newChild; tag_t newChild = NULLTAG;
char *bl_seqNo; char *bl_seqNo = NULL;
ITKCALL(BOM_line_copy(bom_line2, c_line_tags[i], NULLTAG, &newChild)); ITKCALL(BOM_line_copy(bom_line2, c_line_tags[i], NULLTAG, &newChild));
char* pos = NULL;
ITKCALL(AOM_ask_value_string(c_line_tags[i], "object_string", &pos));
printf("copyBomLine:%s\n", pos);
ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &bl_seqNo)); ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &bl_seqNo));
ITKCALL(AOM_lock(newChild)); AOM_lock(newChild);
ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", bl_seqNo)); ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", bl_seqNo));
ITKCALL(AOM_save(newChild)); AOM_save(newChild);
//最后unlock //最后unlock
AOM_unlock(newChild); AOM_unlock(newChild);
} }
@ -1693,7 +1704,11 @@ int EbomToPMethod(void* returnValue) {
tag_t matnrRev1; tag_t matnrRev1;
ITKCALL(ifail = USERARG_get_string_argument(&revUid)); ITKCALL(ifail = USERARG_get_string_argument(&revUid));
ITK__convert_uid_to_tag(revUid, &matnrRev1); ITK__convert_uid_to_tag(revUid, &matnrRev1);
string log_path = "D:\\Siemens\\logs\\material\\";
log_path.append(getNow("yyyyMMdd")).append(".log");
CreateTcLogFile(log_path.c_str());
WriteTcLog("******************* EbomToPMethod start %s *******************", getNow("LOG").c_str());
//链接mdm数据库获取物料申请需要的信息 //链接mdm数据库获取物料申请需要的信息
if (open("PLMUser", "PLMUser", "BDP2020", "10.128.20.35")) { if (open("PLMUser", "PLMUser", "BDP2020", "10.128.20.35")) {
printf("链接SQLSERVER失败\n"); printf("链接SQLSERVER失败\n");
@ -1988,6 +2003,8 @@ int EbomToPMethod(void* returnValue) {
//ITKCALL(BOM_save_window(ebom_window2)); //ITKCALL(BOM_save_window(ebom_window2));
////ITKCALL(AOM_unlock(ebom_window2)); ////ITKCALL(AOM_unlock(ebom_window2));
//ITKCALL(BOM_close_window(ebom_window2)); //ITKCALL(BOM_close_window(ebom_window2));
char* oldUid = NULL;
ITK__convert_tag_to_uid(pBomTop, &oldUid);
ITKCALL(BOM_close_window(ebom_window)); ITKCALL(BOM_close_window(ebom_window));
printf("keyNum===>%s\n", keyNum.c_str()); printf("keyNum===>%s\n", keyNum.c_str());
@ -2004,8 +2021,10 @@ int EbomToPMethod(void* returnValue) {
int structs = 0, statusNum = 0; int structs = 0, statusNum = 0;
tag_t* structure_revisions, *release_status_list; tag_t* structure_revisions, *release_status_list;
ITKCALL(AOM_ask_value_tags(newRev, "structure_revisions", &structs, &structure_revisions)); ITKCALL(AOM_ask_value_tags(newRev, "structure_revisions", &structs, &structure_revisions));
if (structs > 0 && hasChange.compare("true") != 0) { printf("structs%d hasChange=>%s\n", structs, hasChange.c_str());
if (structs > 0 && hasChange.compare("true") == 0) {// && hasChange.compare("true") != 0
ITKCALL(AOM_ask_value_tags(structure_revisions[0], "release_status_list", &statusNum, &release_status_list)); ITKCALL(AOM_ask_value_tags(structure_revisions[0], "release_status_list", &statusNum, &release_status_list));
printf("statusNum===>%d\n", statusNum);
if (statusNum > 0) { if (statusNum > 0) {
int revNum = 0; int revNum = 0;
tag_t *mantrsAs, dsuser; tag_t *mantrsAs, dsuser;
@ -2023,7 +2042,18 @@ int EbomToPMethod(void* returnValue) {
} }
} }
} }
copyBomLine(pBomTop, newRev); tag_t newP = NULLTAG;
if (saveAsMap[oldUid] == NULL) {
newP = pBomTop;
}
else {
newP = saveAsMap[oldUid];
}
char* pos = NULL, *nos = NULL;
ITKCALL(AOM_ask_value_string(newP, "object_string", &pos));
ITKCALL(AOM_ask_value_string(newRev, "object_string", &nos));
printf("copyBomLine:%s ==> %s\n", pos, nos);
copyBomLine(newP, newRev);
} }
} }
@ -2034,6 +2064,7 @@ int EbomToPMethod(void* returnValue) {
if (buff.empty()) { if (buff.empty()) {
buff = "succ"; buff = "succ";
} }
CloseTcLog();
*((char**)returnValue) = (char*)MEM_alloc((strlen(buff.c_str()) + 1) * sizeof(char)); *((char**)returnValue) = (char*)MEM_alloc((strlen(buff.c_str()) + 1) * sizeof(char));
tc_strcpy(*((char**)returnValue), buff.c_str()); tc_strcpy(*((char**)returnValue), buff.c_str());
return ifail; return ifail;

@ -181,8 +181,11 @@
<ClCompile Include="ChintSendMessage.cpp" /> <ClCompile Include="ChintSendMessage.cpp" />
<ClCompile Include="chintSignChange.cpp" /> <ClCompile Include="chintSignChange.cpp" />
<ClCompile Include="chint_add_to_workflow.cpp" /> <ClCompile Include="chint_add_to_workflow.cpp" />
<ClCompile Include="chint_changenotice.cpp" />
<ClCompile Include="chint_check_exist_ebom.cpp" /> <ClCompile Include="chint_check_exist_ebom.cpp" />
<ClCompile Include="chint_check_materialstatus.cpp" />
<ClCompile Include="CHINT_cossheet_upgrade.cpp" /> <ClCompile Include="CHINT_cossheet_upgrade.cpp" />
<ClCompile Include="CHINT_DRAWING_TO_SRM.cpp" />
<ClCompile Include="CHINT_Ecn_SendOA.cxx" /> <ClCompile Include="CHINT_Ecn_SendOA.cxx" />
<ClCompile Include="chint_ecn_signoff.cxx" /> <ClCompile Include="chint_ecn_signoff.cxx" />
<ClCompile Include="CHINT_GetFrock.cpp" /> <ClCompile Include="CHINT_GetFrock.cpp" />
@ -221,6 +224,7 @@
<ClCompile Include="Remove_Release_Status.cpp" /> <ClCompile Include="Remove_Release_Status.cpp" />
<ClCompile Include="SendToPi.cpp" /> <ClCompile Include="SendToPi.cpp" />
<ClCompile Include="string_utils.cxx" /> <ClCompile Include="string_utils.cxx" />
<ClCompile Include="tc_log.cxx" />
<ClCompile Include="tc_util.cpp" /> <ClCompile Include="tc_util.cpp" />
<ClCompile Include="tinyxml2.cpp" /> <ClCompile Include="tinyxml2.cpp" />
<ClCompile Include="UpdateEtoP.cpp" /> <ClCompile Include="UpdateEtoP.cpp" />

@ -221,5 +221,17 @@
<ClCompile Include="chint_ecn_signoff.cxx"> <ClCompile Include="chint_ecn_signoff.cxx">
<Filter>epm-handler</Filter> <Filter>epm-handler</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="CHINT_DRAWING_TO_SRM.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="tc_log.cxx">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="chint_changenotice.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="chint_check_materialstatus.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -0,0 +1,328 @@
#include "cJSON.h"
#include <tc/tc.h>
#include "epm_handler_common.h"
#include <ict/ict_userservice.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <tccore/aom.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <bom/bom.h>
#include "ps/ps.h";
#include "ps/vrule.h"
#include "sstream"
#include <tccore/grm.h>
#include "epm/epm.h"
#include "sa/sa.h"
#include "libxl.h"
#include <map>
#include "epm/signoff.h"
#include <ctime>
#include <vector>
#include <locale>
#include <codecvt>
#include "ae/dataset.h"
#include <iostream>
#include <stdlib.h>
#include <tccore/aom.h>
#include <tc/emh.h>
#include <ict/ict_userservice.h>
#include <tc/tc.h>
#include <tccore/tctype.h>
#include <sa/tcfile.h>
#include <ss/ss_errors.h>
#include <ae/datasettype.h>
#include "chint_Handler.h"
#include <regex>
#include <ics/ics.h>
#include "ado.h"
#include "ocilib.h"
#include <property/nr.h>
#include "CRUL_server_call_httpserver.h"
#include "common_itk_util.h"
#define EPM_HANDLER_COMMON
#define MAX_PATH_LENGTH 200
#define MAX_PRINTLINE_LENGTH 400000
char* utog(const char* src_str)
{
int len = MultiByteToWideChar(CP_UTF8, 0, src_str, -1, NULL, 0);
wchar_t* wszGBK = (wchar_t*)MEM_alloc((len + 1) * sizeof(wchar_t));
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 = (char*)MEM_alloc((len + 1) * sizeof(char));
memset(szGBK, 0, len + 1);
WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, szGBK, len, NULL, NULL);
return szGBK;
}
char* gtou(const char* src_str)
{
int len = MultiByteToWideChar(CP_ACP, 0, src_str, -1, NULL, 0);
wchar_t* wstr = (wchar_t*)MEM_alloc((len + 1) * sizeof(wchar_t));
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 = (char*)MEM_alloc((len + 1) * sizeof(char));
memset(str, 0, len + 1);
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);
return str;
}
// 写入回调函数实现
size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp) {
size_t totalSize = size * nmemb;
char* buffer = (char*)userp;
// 追加内容到缓冲区
strncat(buffer, (char*)contents, totalSize);
return totalSize; // 返回实际接收的字节数
}
void feishuSplit(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;
}
}
}
void WriteLog4(logical debug, const char* format, ...)
{
va_list arg;
char tmp[MAX_PRINTLINE_LENGTH];
char date_string[MAX_PATH_LENGTH];
time_t now;
struct tm* p;
//get the message
memset(tmp, 0, sizeof(tmp));
va_start(arg, format);
vsprintf(tmp, format, arg);
va_end(arg);
//----------print to command window for trace--------//
//printf("%s\n", tmp);
printf("%s\n", tmp);
//print message to log file
TC_write_syslog("%s\n", tmp);
}
int chint_changenotice(EPM_action_message_t msg) {
tag_t task_tag = NULL_TAG,
root_task_tag = NULLTAG,
* attachments;;
task_tag = msg.task;
int att_cnt = 0, ifail = 0;
int c_sql_value_count = 0;
char** c_sql_values = NULL;
ITKCALL(PREF_ask_char_values("CHINT_ChangeNotice", &c_sql_value_count, &c_sql_values));
WriteLog4(true, "------------------------------------------------------------------------------------");
WriteLog4(true, "=========================");
WriteLog4(true, "chint_changenotice start");
WriteLog4(true, "=========================");
EPM_ask_root_task(task_tag, &root_task_tag);
EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments);
WriteLog4(true, "流程目标下的对象数量:%d", att_cnt);
//分割首选项
std::map<std::string, std::string> prefMap;//统计集合
for (int j = 0; j < c_sql_value_count; j++) {
/*值:第一行为通知信息。
:;
M060shaojq@chint.com
M060 : shaojq*/
if (j != 0) {
vector<string> ans;
feishuSplit(c_sql_values[j], ":", ans);
prefMap[ans[0]] = ans[1];
}
}
WriteLog4(true, "首选项条数:%d", prefMap.size());
for (int i = 0; i < att_cnt; i++)
{
tag_t tagt = NULLTAG;
tagt = attachments[i];
char* type;
//获取版本下的数据集
int dataset_num = 0;
tag_t* dataset_tags = NULL;
char* tempValue = NULL;
char taskpuid[56] = "\0";
ITK__convert_tag_to_uid(task_tag, &tempValue);
tc_strcpy(taskpuid, tempValue);
ITKCALL(AOM_ask_value_string(tagt, "object_type", &type));
printf("object_type=%s\n", type);
//获取当前登入人组
//char* groupName = NULL;
//tag_t t_group = NULLTAG;
//ITKCALL(POM_ask_group(&groupName, &t_group));
//printf("g=%s\n", groupName);
//获取当前登入人的名称和id
tag_t group;
char* group_name;
AOM_ask_value_tag(tagt, "owning_group", &group);
AOM_ask_value_string(group, "name", &group_name);
char* name;
char* id;
tag_t user;
POM_get_user(&name, &user);
POM_get_user_id(&id);
printf("name================%s\n", name);
printf("id================%s\n", id);
string users = "";
//判断组是否在首选项中存在
for (auto it = prefMap.begin(); it != prefMap.end(); it++) {
//当前组和首选项中组匹配
if (strcmp(it->first.c_str(), group_name) == 0) {
users = it->second;
break;
}
}
printf("users================%s\n", users);
if (strcmp(users.c_str(), "") != 0) {
//判断目标下是否存在 ZT2_Change
if (strcmp("ZT2_Change", type) == 0) {
//拼接json
char* json = NULL;
string contentStr;
cJSON* top = cJSON_CreateObject();
cJSON* emails = cJSON_CreateArray();
cJSON* mobiles = cJSON_CreateArray();
//拼接emails
vector<string> usersVector;
feishuSplit(users, ";", usersVector);
for (int h = 0; h < usersVector.size(); h++) {
cJSON* new_string = cJSON_CreateString(usersVector[h].c_str());
cJSON_AddItemToArray(emails, new_string);
}
//拼接content
tag_t user;
char* duser,* itemId;
AOM_ask_value_string(tagt, "item_id", &itemId);
AOM_ask_value_tag(tagt, "owning_user", &user);
AOM_ask_value_string(user, "user_name", &duser);
contentStr.append(duser).append(" 发起的").append(itemId).append(c_sql_values[0]);
cJSON_AddStringToObject(top, "content", contentStr.c_str());
//sms
cJSON_AddStringToObject(top, "sms", "false");
cJSON_AddItemToObject(top, "emails", emails);
cJSON_AddItemToObject(top, "mobiles", mobiles);
json = cJSON_Print(top);
printf("json================%s\n", json);
//调用接口
CURL* curl;
CURLcode res;
char readBuffer[10000];
memset(readBuffer, 0, 10000);
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "http://10.128.10.170/api/feishu/Message/sendMessages");
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");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
//const char* data = "{\"emails\":[\"shaojq@chint.com\",\"zouy5@chint.com\"],\"mobiles\":[],\"sms\":false,\"content\":\"项目编号:P2303344售前资料已经获取完毕请 登陆PLM系统查看。\"}";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, gtou(json));
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
char* gbk_readBuffer = utog(readBuffer);
printf("json================%s\n", gbk_readBuffer);
cJSON* result_json = cJSON_Parse(gbk_readBuffer);
cJSON* code = cJSON_GetObjectItem(result_json, "code");
int code_int = code->valueint;
if (code_int != 0) {
printf("发送飞书失败\n");
}
}
}
}
DOFREE(attachments);
WriteLog4(true, "=========================");
WriteLog4(true, "chint_changenotice end");
WriteLog4(true, "=========================");
return ifail;
}

@ -0,0 +1,299 @@
#include "cJSON.h"
#include <tc/tc.h>
#include "epm_handler_common.h"
#include <ict/ict_userservice.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <tccore/aom.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <bom/bom.h>
#include "ps/ps.h";
#include "ps/vrule.h"
#include "sstream"
#include <tccore/grm.h>
#include "epm/epm.h"
#include "sa/sa.h"
#include "libxl.h"
#include <map>
#include "epm/signoff.h"
#include <ctime>
#include <vector>
#include <locale>
#include <codecvt>
#include "ae/dataset.h"
#include <iostream>
#include <stdlib.h>
#include <tccore/aom.h>
#include <tc/emh.h>
#include <ict/ict_userservice.h>
#include <tc/tc.h>
#include <tccore/tctype.h>
#include <sa/tcfile.h>
#include <ss/ss_errors.h>
#include <ae/datasettype.h>
#include "chint_Handler.h"
#include <regex>
#include <ics/ics.h>
#include "ado.h"
#include "ocilib.h"
#include <property/nr.h>
#include "CRUL_server_call_httpserver.h"
#include "common_itk_util.h"
#define EPM_HANDLER_COMMON
#define MAX_PATH_LENGTH 200
#define MAX_PRINTLINE_LENGTH 400000
using namespace std;
void WriteLog5(logical debug, const char* format, ...)
{
va_list arg;
char tmp[MAX_PRINTLINE_LENGTH];
char date_string[MAX_PATH_LENGTH];
time_t now;
struct tm* p;
//get the message
memset(tmp, 0, sizeof(tmp));
va_start(arg, format);
vsprintf(tmp, format, arg);
va_end(arg);
//----------print to command window for trace--------//
//printf("%s\n", tmp);
printf("%s\n", tmp);
//print message to log file
TC_write_syslog("%s\n", tmp);
}
int chint_check_materialstatus(EPM_action_message_t msg) {
tag_t task_tag = NULL_TAG,
root_task_tag = NULLTAG,
* attachments;;
task_tag = msg.task;
int att_cnt = 0, ifail = 0;
int count = 1;
WriteLog5(true, "------------------------------------------------------------------------------------");
WriteLog5(true, "=========================");
WriteLog5(true, "chint_check_materialstatus start");
WriteLog5(true, "=========================");
EPM_ask_root_task(task_tag, &root_task_tag);
EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments);
WriteLog5(true, "流程目标下的对象数量:%d", att_cnt);
//停用集合
std::map<std::string, std::string> tyMap;
//封存集合
std::map<std::string, std::string> fcMap;
for (int i = 0; i < att_cnt; i++)
{
tag_t target = NULLTAG;
target = attachments[i];
char* objectType = NULL;
char* fcStr = NULL,* tyStr = NULL,* zt2_State = NULL;
//三种处理逻辑 物料 物料bom 图纸
ITKCALL(AOM_ask_value_string(target, "object_type", &objectType));
//物料
printf("objectType======%s\n", objectType);
if (strcmp(objectType,"Part Revision") == 0) {
//获取物料编码和物料名称
char* zt2_MaterialNo = NULL;
char* object_name = NULL;
ITKCALL(AOM_ask_value_string(target, "object_name", &object_name));
ITKCALL(AOM_ask_value_string(target, "zt2_MaterialNo", &zt2_MaterialNo));
ITKCALL(AOM_ask_value_string(target, "object_desc", &tyStr));
ITKCALL(AOM_UIF_ask_value(target, "zt2_State", &zt2_State));
printf("tyStr======%s\n", tyStr);
if (strstr(tyStr,"停用")) {
//放入停用map
tyMap[zt2_MaterialNo] = object_name;
continue;
}
else if (strstr(zt2_State, "封存")) {
//放入封存map
fcMap[zt2_MaterialNo] = object_name;
continue;
}
}
//物料bom :获取第一层
if (strcmp(objectType, "BOMView Revision") == 0) {
//获取第一层
////遍历子BOM获取属性
//tag_t window_0_;
//tag_t top_bom_line;
//tag_t* childs;
//int childNum;
//char* json = NULL;
////遍历BOM结构
//ITKCALL(BOM_create_window(&window_0_));
//tag_t topRev = NULLTAG;
////bomline
//int top_bl_line_object;
//ITKCALL(BOM_line_look_up_attribute("bl_line_object", &top_bl_line_object));
//ITKCALL(BOM_line_ask_attribute_tag(target, top_bl_line_object, &topRev));
//ITKCALL(BOM_set_window_top_line(window_0_, NULLTAG, topRev, NULLTAG, &top_bom_line));
//获取子
tag_t bom_window_tag = NULLTAG,
top_line_tag = NULLTAG;
ITKCALL(BOM_create_window(&bom_window_tag));//创建window视图
ITKCALL(BOM_set_window_top_line_bvr(bom_window_tag, target, &top_line_tag));//获取顶层bomline
tag_t* childs;
int childNum;
ITKCALL(BOM_line_ask_child_lines(top_line_tag, &childNum, &childs));
printf("childNum======%d\n", childNum);
for (int i = 0; i < childNum; i++) {
tag_t rev = NULLTAG;
//bomline
int bl_line_object;
ITKCALL(BOM_line_look_up_attribute("bl_line_object", &bl_line_object));
ITKCALL(BOM_line_ask_attribute_tag(childs[i], bl_line_object, &rev));
char* objectType_rev = NULL;
//获取rev属性判断
ITKCALL(AOM_ask_value_string(rev, "object_type", &objectType_rev));
//物料
if (strcmp(objectType_rev, "Part Revision") == 0) {
//获取物料编码和物料名称
char* zt2_MaterialNo = NULL;
char* object_name = NULL;
ITKCALL(AOM_ask_value_string(rev, "object_name", &object_name));
ITKCALL(AOM_ask_value_string(rev, "zt2_MaterialNo", &zt2_MaterialNo));
ITKCALL(AOM_ask_value_string(rev, "object_desc", &tyStr));
ITKCALL(AOM_UIF_ask_value(rev, "zt2_State", &zt2_State));
if (strstr(tyStr, "停用")) {
//放入停用map
tyMap[zt2_MaterialNo] = object_name;
continue;
}
else if (strstr(zt2_State, "封存")) {
//放入封存map
fcMap[zt2_MaterialNo] = object_name;
continue;
}
}
}
}
////图纸
//if (strcmp(objectType, "ZT2_Design3DRevision") == 0) {
// //获取关系文件夹下的物料
// int gxNum; tag_t* gxTags; char* object_string = NULL;
// ITKCALL(AOM_ask_value_tags(target, "pseudo_folder", &gxNum, &gxTags));
// for (int i = 0; i < gxNum; i++) {
// ITKCALL(AOM_ask_value_string(gxTags[i], "object_string", &object_string));
// if (strcmp(object_string,"物料")) {
// //获取物料文件夹下的对象
// int wlNum; tag_t* wlTags;
// ITKCALL(AOM_ask_value_tags(target, "representation_for", &wlNum, &wlTags));
// for (int j = 0; j < gxNum; j++) {
// //获取rev属性判断
// char* objectType_rev = NULL;
// ITKCALL(AOM_ask_value_string(wlTags[j], "object_type", &objectType_rev));
// //物料
// if (strcmp(objectType_rev, "Part Revision") == 0) {
// //获取物料编码和物料名称
// char* zt2_MaterialNo = NULL;
// char* object_name = NULL;
// ITKCALL(AOM_ask_value_string(wlTags[j], "object_name", &object_name));
// ITKCALL(AOM_ask_value_string(wlTags[j], "zt2_MaterialNo", &zt2_MaterialNo));
// ITKCALL(AOM_ask_value_string(wlTags[j], "object_desc", &tyStr));
// ITKCALL(AOM_UIF_ask_value(wlTags[j], "zt2_State", &zt2_State));
// if (strstr(tyStr, "停用")) {
// //放入停用map
// tyMap[zt2_MaterialNo] = object_name;
// continue;
// }
// else if (strstr(zt2_State, "封存")) {
// //放入封存map
// fcMap[zt2_MaterialNo] = object_name;
// continue;
// }
// }
// }
// }
// }
//}
//图纸
if (strcmp(objectType, "ZT2_Design3DRevision") == 0) {
//获取关系文件夹下的物料
int wlNum; tag_t* wlTags;
ITKCALL(AOM_ask_value_tags(target, "representation_for", &wlNum, &wlTags));
printf("wlNum======%d\n", wlNum);
for (int j = 0; j < wlNum; j++) {
//获取rev属性判断
char* objectType_rev = NULL;
ITKCALL(AOM_ask_value_string(wlTags[j], "object_type", &objectType_rev));
//物料
printf("objectType_rev======%s\n", objectType_rev);
if (strcmp(objectType_rev, "Part Revision") == 0) {
//获取物料编码和物料名称
char* zt2_MaterialNo = NULL;
char* object_name = NULL;
ITKCALL(AOM_ask_value_string(wlTags[j], "object_name", &object_name));
ITKCALL(AOM_ask_value_string(wlTags[j], "zt2_MaterialNo", &zt2_MaterialNo));
ITKCALL(AOM_ask_value_string(wlTags[j], "object_desc", &tyStr));
ITKCALL(AOM_UIF_ask_value(wlTags[j], "zt2_State", &zt2_State));
printf("zt2_State======%s\n", zt2_State);
if (strstr(tyStr, "停用")) {
//放入停用map
tyMap[zt2_MaterialNo] = object_name;
printf("00000000000000000000000000\n");
continue;
}
else if (strstr(zt2_State, "封存")) {
//放入封存map
fcMap[zt2_MaterialNo] = object_name;
printf("11111111111111111111111111\n");
continue;
}
}
}
}
}
//收集完map数据进行拼接报错
string errMsg = "";
for (auto it = tyMap.begin(); it != tyMap.end(); it++) {
errMsg.append(std::to_string(count++)).append(".").append(it->first).append("-").append(it->second).append(":物料已停用\n");
}
for (auto it = fcMap.begin(); it != fcMap.end(); it++) {
errMsg.append(std::to_string(count++)).append(".").append(it->first).append("-").append(it->second).append(":物料已封存\n");
}
if (fcMap.size() > 0) {
EMH_store_error_s1(EMH_severity_error, EMH_USER_error_base, errMsg.c_str()); //错误弹窗
return -1;
}
if (tyMap.size() > 0) {
EMH_store_error_s1(EMH_severity_warning, EMH_USER_error_base, errMsg.c_str()); //错误弹窗
}
DOFREE(attachments);
WriteLog5(true, "=========================");
WriteLog5(true, "chint_check_materialstatus end");
WriteLog5(true, "=========================");
return ifail;
}

@ -45,238 +45,238 @@ using namespace std;
//电子签名 //电子签名
int chint_pdf_signoff(EPM_action_message_t msg) { int chint_pdf_signoff(EPM_action_message_t msg) {
int ifail = ITK_ok; int ifail = ITK_ok;
/**/
//流程节点相关 //流程节点相关
tag_t root_task = NULLTAG, *sub_tasks = NULL, current_task = NULLTAG, type_tag = NULLTAG; //tag_t root_task = NULLTAG, *sub_tasks = NULL, current_task = NULLTAG, type_tag = NULLTAG;
int sub_task_count = 0; //int sub_task_count = 0;
char root_task_name[128] = "", task_name[128] = ""; //char root_task_name[128] = "", task_name[128] = "";
int occur_of_counts = 0; //int occur_of_counts = 0;
tag_t* taskAttches = NULLTAG; //tag_t* taskAttches = NULLTAG;
char tgt_type[WSO_name_size_c + 1] = "", *type_class; //char tgt_type[WSO_name_size_c + 1] = "", *type_class;
////循环内部变量 //////循环内部变量
tag_t cur_task = NULLTAG; //tag_t cur_task = NULLTAG;
//循环变量 ////循环变量
int count = 0; //int count = 0;
//节点循环处理变量 ////节点循环处理变量
tag_t itemrevision = NULLTAG, master_form_rel_type = NULLTAG; //tag_t itemrevision = NULLTAG, master_form_rel_type = NULLTAG;
int form_count = 0; //int form_count = 0;
tag_t* form_list = NULL, master_form = NULLTAG; //tag_t* form_list = NULL, master_form = NULLTAG;
current_task = msg.task; //current_task = msg.task;
//CreateLogFile("PLA8_signoff",&txtfile); ////CreateLogFile("PLA8_signoff",&txtfile);
ECHO("=========================================================\n"); //ECHO("=========================================================\n");
ECHO("电子签名 开始执行\n"); //ECHO("电子签名 开始执行\n");
ECHO("=========================================================\n"); //ECHO("=========================================================\n");
//参数相关 ////参数相关
POM_AM__set_application_bypass(true); //POM_AM__set_application_bypass(true);
int url_num = 0; //int url_num = 0;
char** url_vals = NULL; //char** url_vals = NULL;
PREF_ask_char_values("CHINT_SignPic", &url_num, &url_vals); //PREF_ask_char_values("CHINT_SignPic", &url_num, &url_vals);
tag_t group; //tag_t group;
char *groupId; //char *groupId;
AOM_ask_value_tag(msg.task, "owning_group", &group); //AOM_ask_value_tag(msg.task, "owning_group", &group);
AOM_ask_value_string(group,"name", &groupId); //AOM_ask_value_string(group,"name", &groupId);
printf("groupId==>%s\n", groupId); //printf("groupId==>%s\n", groupId);
map<string, tag_t> typeUidMap; //map<string, tag_t> typeUidMap;
for (int i = 0; i < url_num;i++) { //for (int i = 0; i < url_num;i++) {
vector<string> vec2; // vector<string> vec2;
Split(url_vals[i], ";", vec2); // Split(url_vals[i], ";", vec2);
if (vec2.size() == 3 && vec2[0].compare(groupId)==0) { // if (vec2.size() == 3 && vec2[0].compare(groupId)==0) {
tag_t tz_target; // tag_t tz_target;
ITK__convert_uid_to_tag(vec2[2].c_str(), &tz_target); // ITK__convert_uid_to_tag(vec2[2].c_str(), &tz_target);
typeUidMap[vec2[1]] = tz_target; // typeUidMap[vec2[1]] = tz_target;
} // }
} //}
//获取属性 ////获取属性
EPM_ask_root_task(msg.task, &root_task); //EPM_ask_root_task(msg.task, &root_task);
EPM_ask_sub_tasks(root_task, &sub_task_count, &sub_tasks); //EPM_ask_sub_tasks(root_task, &sub_task_count, &sub_tasks);
EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches); //EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches);
ECHO("%d target attachment found", occur_of_counts); //ECHO("%d target attachment found", occur_of_counts);
for (count = 0; count < occur_of_counts; count++) //for (count = 0; count < occur_of_counts; count++)
{ //{
ITKCALL(TCTYPE_ask_object_type(taskAttches[count], &type_tag)); // ITKCALL(TCTYPE_ask_object_type(taskAttches[count], &type_tag));
ITKCALL(ifail = TCTYPE_ask_class_name2(type_tag, &type_class)); // ITKCALL(ifail = TCTYPE_ask_class_name2(type_tag, &type_class));
//过滤掉非版本对象 // //过滤掉非版本对象
if (typeUidMap.count(type_class)>0) // if (typeUidMap.count(type_class)>0)
{ // {
tag_t tz_target = typeUidMap[type_class]; // tag_t tz_target = typeUidMap[type_class];
char tz_path[512] = ""; // char tz_path[512] = "";
int target_count = 0; // int target_count = 0;
tag_t* target_tags = NULL; // tag_t* target_tags = NULL;
char* target_type; // char* target_type;
ITKCALL(AOM_ask_value_tags(tz_target, "ref_list", &target_count, &target_tags)); // 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)); // ITKCALL(AOM_ask_value_string(target_tags[0], "file_ext", &target_type));
time_t now; // time_t now;
struct tm* p; // struct tm* p;
time(&now); // time(&now);
p = localtime(&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); // 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); // IMF_export_file(target_tags[0], tz_path);
itemrevision = taskAttches[count]; // itemrevision = taskAttches[count];
ITKCALL(GRM_find_relation_type(TC_master_form_rtype, &master_form_rel_type)); // 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)); // ITKCALL(GRM_list_secondary_objects_only(itemrevision, master_form_rel_type, &form_count, &form_list));
//获得数据集 // //获得数据集
tag_t relation_type = NULLTAG; // tag_t relation_type = NULLTAG;
//tag_t attach_relation_type = NULLTAG; // //tag_t attach_relation_type = NULLTAG;
ITKCALL(GRM_find_relation_type(TC_specification_rtype, &relation_type)); // ITKCALL(GRM_find_relation_type(TC_specification_rtype, &relation_type));
tag_t* secondary_objects = NULLTAG; // tag_t* secondary_objects = NULLTAG;
int ds_count = 0; // int ds_count = 0;
char* dataset_type = NULL, *desc_value = NULL, *file_path = NULL, *desc_path; // 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)); // ITKCALL(GRM_list_secondary_objects_only(itemrevision, relation_type, &ds_count, &secondary_objects));
for (int j = 0; j < ds_count; j++) // for (int j = 0; j < ds_count; j++)
{ // {
printf("进1\n"); // printf("进1\n");
ITKCALL(AOM_ask_value_string(secondary_objects[j], "object_type", &dataset_type)); // ITKCALL(AOM_ask_value_string(secondary_objects[j], "object_type", &dataset_type));
int des_count = 0; // int des_count = 0;
tag_t* dess = NULL; // tag_t* dess = NULL;
printf("dataset_type=%s\n", dataset_type); // printf("dataset_type=%s\n", dataset_type);
if (strcmp(dataset_type, "PDF") != 0) { // if (strcmp(dataset_type, "PDF") != 0) {
if (dataset_type != NULL) { // if (dataset_type != NULL) {
MEM_free(dataset_type); // MEM_free(dataset_type);
dataset_type = NULL; // dataset_type = NULL;
} // }
continue; // continue;
} // }
ITKCALL(AOM_ask_value_tags(secondary_objects[j], "ref_list", &des_count, &dess)); // ITKCALL(AOM_ask_value_tags(secondary_objects[j], "ref_list", &des_count, &dess));
if (des_count < 1) { // if (des_count < 1) {
printf("该数据集引用数量错误\n"); // printf("该数据集引用数量错误\n");
continue; // continue;
} // }
else { // else {
char* sizeFile; // char* sizeFile;
AOM_ask_value_string(dess[0], "file_size", &sizeFile); // AOM_ask_value_string(dess[0], "file_size", &sizeFile);
printf("sizeFile %s \n", sizeFile); // printf("sizeFile %s \n", sizeFile);
if (strcmp(sizeFile, "0 bytes") == 0) { // if (strcmp(sizeFile, "0 bytes") == 0) {
printf("文件大小是0bytes\n"); // printf("文件大小是0bytes\n");
continue; // continue;
} // }
} // }
tag_t spec_dataset_rev = NULLTAG, // tag_t spec_dataset_rev = NULLTAG,
ref_object = NULLTAG; // ref_object = NULLTAG;
char* ref_object_name = NULL; // char* ref_object_name = NULL;
AE_reference_type_t reference_type; // AE_reference_type_t reference_type;
char* datasetName = NULL; // char* datasetName = NULL;
char* pathname; // char* pathname;
char* origin_file_name; // char* origin_file_name;
vector<string> type_vec; // vector<string> type_vec;
printf("开始判断类型\n"); // printf("开始判断类型\n");
if (strcmp(dataset_type, "PDF") == 0) { // if (strcmp(dataset_type, "PDF") == 0) {
printf("pdf类型\n"); // printf("pdf类型\n");
AOM_ask_value_string(secondary_objects[j], "object_name", &datasetName); // AOM_ask_value_string(secondary_objects[j], "object_name", &datasetName);
AE_ask_dataset_latest_rev(secondary_objects[j], &spec_dataset_rev); // AE_ask_dataset_latest_rev(secondary_objects[j], &spec_dataset_rev);
AOM_ask_value_string(spec_dataset_rev, "object_name", &ref_object_name); // AOM_ask_value_string(spec_dataset_rev, "object_name", &ref_object_name);
printf("ref_object_name=%s\n", ref_object_name); // printf("ref_object_name=%s\n", ref_object_name);
char ref_name[WSO_name_size_c + 1] = "PDF_Reference"; // char ref_name[WSO_name_size_c + 1] = "PDF_Reference";
AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object); // AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object);
if (ref_object == NULLTAG) // if (ref_object == NULLTAG)
{ // {
printf("\nref_object is NULLTAG\n"); // printf("\nref_object is NULLTAG\n");
return ITK_ok; // return ITK_ok;
} // }
printf("reference_type=%d\n", reference_type); // printf("reference_type=%d\n", reference_type);
if (reference_type == AE_PART_OF) // if (reference_type == AE_PART_OF)
{ // {
ITKCALL(IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname)); // ITKCALL(IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname));
IMF_ask_original_file_name2(ref_object, &origin_file_name); // IMF_ask_original_file_name2(ref_object, &origin_file_name);
char new_ds_name[WSO_name_size_c + 1] = ""; // 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* new_file_name = USER_new_file_name(new_ds_name, ref_name, "pdf", 0);
char* temp_dir = getenv("temp"); // char* temp_dir = getenv("temp");
char temp_file[SS_MAXPATHLEN] = ""; // char temp_file[SS_MAXPATHLEN] = "";
char temp_file2[SS_MAXPATHLEN] = ""; // char temp_file2[SS_MAXPATHLEN] = "";
strcpy(temp_file, temp_dir); // strcpy(temp_file, temp_dir);
strcat(temp_file, "\\"); // strcat(temp_file, "\\");
strcat(temp_file, new_file_name); // strcat(temp_file, new_file_name);
IMF_export_file(ref_object, temp_file); // IMF_export_file(ref_object, temp_file);
//
if (strstr(new_file_name, ".pdf") != NULL) { // if (strstr(new_file_name, ".pdf") != NULL) {
sprintf(temp_file2, "%s\\1%s", temp_dir, new_file_name); // sprintf(temp_file2, "%s\\1%s", temp_dir, new_file_name);
} // }
else { // else {
sprintf(temp_file2, "%s\\1%s.pdf", temp_dir, new_file_name); // sprintf(temp_file2, "%s\\1%s.pdf", temp_dir, new_file_name);
} // }
//sprintf(temp_file2, "%s.pdf", temp_file); // //sprintf(temp_file2, "%s.pdf", temp_file);
printf("\ntemp_file=%s\n", temp_file); // printf("\ntemp_file=%s\n", temp_file);
char cmd[256] = ""; // char cmd[256] = "";
char* tc_root_dir = getenv("tc_root"); // char* tc_root_dir = getenv("tc_root");
strcpy(cmd, "java -jar "); // strcpy(cmd, "java -jar ");
strcat(cmd, tc_root_dir); // strcat(cmd, tc_root_dir);
strcat(cmd, "\\bin\\CHINT_PDFSignoff.jar"); // strcat(cmd, "\\bin\\CHINT_PDFSignoff.jar");
strcat(cmd, " \""); // strcat(cmd, " \"");
/*strcat(cmd, path); // /*strcat(cmd, path);
strcat(cmd, "\" \"");*/ // strcat(cmd, "\" \"");*/
strcat(cmd, temp_file); // strcat(cmd, temp_file);
strcat(cmd, "\" \""); // strcat(cmd, "\" \"");
strcat(cmd, temp_file2); // strcat(cmd, temp_file2);
strcat(cmd, "\" \""); // strcat(cmd, "\" \"");
strcat(cmd, tz_path); // strcat(cmd, tz_path);
strcat(cmd, "\""); // strcat(cmd, "\"");
printf("\n%s\n", cmd); // printf("\n%s\n", cmd);
system(cmd); // system(cmd);
/*char txtPath[256] = ""; // /*char txtPath[256] = "";
strcpy(txtPath, "DEL /f "); // strcpy(txtPath, "DEL /f ");
strcat(txtPath, path); // strcat(txtPath, path);
system(txtPath);*/ // system(txtPath);*/
tag_t new_file_tag = NULLTAG; // tag_t new_file_tag = NULLTAG;
IMF_file_t file_descriptor; // IMF_file_t file_descriptor;
if (temp_file2 != NULL) { // if (temp_file2 != NULL) {
IMF_import_file(temp_file2, 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);
} // }
else // else
{ // {
IMF_import_file(temp_file, new_file_name, SS_BINARY, &new_file_tag, &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_set_original_file_name2(new_file_tag, origin_file_name);
IMF_close_file(file_descriptor); // IMF_close_file(file_descriptor);
AOM_save(new_file_tag); // AOM_save(new_file_tag);
AOM_unlock(new_file_tag); // AOM_unlock(new_file_tag);
AOM_lock(spec_dataset_rev); // AOM_lock(spec_dataset_rev);
AE_remove_dataset_named_ref_by_tag2(spec_dataset_rev, ref_name, ref_object); // 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); // AE_add_dataset_named_ref2(spec_dataset_rev, ref_name, AE_PART_OF, new_file_tag);
AOM_save(spec_dataset_rev); // AOM_save(spec_dataset_rev);
AOM_unlock(spec_dataset_rev); // AOM_unlock(spec_dataset_rev);
char tempPath[256] = ""; // char tempPath[256] = "";
char tempPath2[256] = ""; // char tempPath2[256] = "";
char tempPath3[256] = ""; // char tempPath3[256] = "";
strcpy(tempPath, "DEL /f "); // strcpy(tempPath, "DEL /f ");
strcat(tempPath, temp_file); // strcat(tempPath, temp_file);
system(tempPath); // system(tempPath);
strcpy(tempPath2, "DEL /f "); // strcpy(tempPath2, "DEL /f ");
strcat(tempPath2, temp_file2); // strcat(tempPath2, temp_file2);
system(tempPath2); // system(tempPath2);
/*strcpy(tempPath3, "DEL /f "); // /*strcpy(tempPath3, "DEL /f ");
strcat(tempPath3, tz_path); // strcat(tempPath3, tz_path);
system(tempPath3);*/ // system(tempPath3);*/
//ITKCALL(ifail = import_dataset_file(secondary_objects[j], "T2_DWG", "dwg", temp_file, datasetName)); // //ITKCALL(ifail = import_dataset_file(secondary_objects[j], "T2_DWG", "dwg", temp_file, datasetName));
} // }
} // }
MEM_free(dataset_type); // MEM_free(dataset_type);
} // }
DOFREE(secondary_objects); // DOFREE(secondary_objects);
} // }
} //}
POM_AM__set_application_bypass(false); //POM_AM__set_application_bypass(false);
DOFREE(taskAttches); //DOFREE(taskAttches);
ECHO("=========================================================\n"); //ECHO("=========================================================\n");
ECHO("电子签名 结束\n"); //ECHO("电子签名 结束\n");
ECHO("=========================================================\n"); //ECHO("=========================================================\n");
return ifail; return ifail;
} }

@ -61,6 +61,10 @@ int CHINT_yptask_complete(EPM_action_message_t msg);
int chint_ecn_signoff(EPM_action_message_t msg); int chint_ecn_signoff(EPM_action_message_t msg);
int chint_ecn_assign(EPM_action_message_t msg); int chint_ecn_assign(EPM_action_message_t msg);
int CHINT_DRAWING_TO_SRM(EPM_action_message_t msg);
int chint_changenotice(EPM_action_message_t msg);
int chint_check_materialstatus(EPM_action_message_t msg);
//user service end //user service end
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -120,28 +120,28 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar
} else { } else {
printf("Registering action handler chintP failed %d\n", ifail); printf("Registering action handler chintP failed %d\n", ifail);
}*/ }*/
ifail = EPM_register_action_handler("chintProperty", "chintProperty", (EPM_action_handler_t)chintProperty); ITKCALL(ifail = EPM_register_action_handler("chintProperty", "chintProperty", (EPM_action_handler_t)chintProperty));
if(ifail==0) { if(ifail==0) {
printf("Registering action handler chintProperty successful\n"); printf("Registering action handler chintProperty successful\n");
} else { } else {
printf("Registering action handler chintProperty failed %d\n", ifail); printf("Registering action handler chintProperty failed %d\n", ifail);
} }
ifail = EPM_register_action_handler("chintSignChange", "chintSignChange", (EPM_action_handler_t)chintSignChange); ITKCALL(ifail = EPM_register_action_handler("chintSignChange", "chintSignChange", (EPM_action_handler_t)chintSignChange));
if(ifail==0) { if(ifail==0) {
printf("Registering action handler chintSignChange successful\n"); printf("Registering action handler chintSignChange successful\n");
} else { } else {
printf("Registering action handler chintSignChange failed %d\n", ifail); printf("Registering action handler chintSignChange failed %d\n", ifail);
} }
ifail = EPM_register_action_handler("chint_signoff_dataset", "chint_signoff_dataset", (EPM_action_handler_t)chint_signoff_dataset); ITKCALL(ifail = EPM_register_action_handler("chint_signoff_dataset", "chint_signoff_dataset", (EPM_action_handler_t)chint_signoff_dataset));
if(ifail==0) { if(ifail==0) {
printf("Registering action handler chint_signoff_dataset successful\n"); printf("Registering action handler chint_signoff_dataset successful\n");
} else { } else {
printf("Registering action handler chint_signoff_dataset failed %d\n", ifail); printf("Registering action handler chint_signoff_dataset failed %d\n", ifail);
} }
ifail = EPM_register_action_handler("chint_getChgOrde", "chint_getChgOrde", (EPM_action_handler_t)chint_getChgOrde); ITKCALL(ifail = EPM_register_action_handler("chint_getChgOrde", "chint_getChgOrde", (EPM_action_handler_t)chint_getChgOrde));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler chint_getChgOrde successful\n"); printf("Registering action handler chint_getChgOrde successful\n");
} }
@ -149,7 +149,7 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar
printf("Registering action handler chint_getChgOrde failed %d\n", ifail); printf("Registering action handler chint_getChgOrde failed %d\n", ifail);
} }
ifail = EPM_register_action_handler("chint_getProduct", "chint_getProduct", (EPM_action_handler_t)chint_getProduct); ITKCALL(ifail = EPM_register_action_handler("chint_getProduct", "chint_getProduct", (EPM_action_handler_t)chint_getProduct));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler chint_getProduct successful\n"); printf("Registering action handler chint_getProduct successful\n");
} }
@ -157,7 +157,7 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar
printf("Registering action handler chint_getProduct failed %d\n", ifail); printf("Registering action handler chint_getProduct failed %d\n", ifail);
} }
ifail = EPM_register_action_handler("chint_DesignProcess", "chint_DesignProcess", (EPM_action_handler_t)chint_DesignProcess); ITKCALL(ifail = EPM_register_action_handler("chint_DesignProcess", "chint_DesignProcess", (EPM_action_handler_t)chint_DesignProcess));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler chint_DesignProcess successful\n"); printf("Registering action handler chint_DesignProcess successful\n");
} }
@ -165,35 +165,35 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar
printf("Registering action handler chint_DesignProcess failed %d\n", ifail); printf("Registering action handler chint_DesignProcess failed %d\n", ifail);
} }
ifail = EPM_register_action_handler("chint_pdf_signoff", "chint_pdf_signoff", (EPM_action_handler_t)chint_pdf_signoff); ITKCALL(ifail = EPM_register_action_handler("chint_pdf_signoff", "chint_pdf_signoff", (EPM_action_handler_t)chint_pdf_signoff));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler chint_pdf_signoff successful\n"); printf("Registering action handler chint_pdf_signoff successful\n");
} }
else { else {
printf("Registering action handler chint_pdf_signoff failed %d\n", ifail); printf("Registering action handler chint_pdf_signoff failed %d\n", ifail);
} }
ifail = EPM_register_action_handler("chint_updateToPi", "chint_updateToPi", (EPM_action_handler_t)chint_updateToPi); ITKCALL(ifail = EPM_register_action_handler("chint_updateToPi", "chint_updateToPi", (EPM_action_handler_t)chint_updateToPi));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler chint_updateToPi successful\n"); printf("Registering action handler chint_updateToPi successful\n");
} }
else { else {
printf("Registering action handler chint_updateToPi failed %d\n", ifail); printf("Registering action handler chint_updateToPi failed %d\n", ifail);
} }
ifail = EPM_register_action_handler("chint_add_to_workflow", "chint_add_to_workflow", (EPM_action_handler_t)chint_add_to_workflow); ITKCALL(ifail = EPM_register_action_handler("chint_add_to_workflow", "chint_add_to_workflow", (EPM_action_handler_t)chint_add_to_workflow));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler chint_add_to_workflow successful\n"); printf("Registering action handler chint_add_to_workflow successful\n");
} }
else { else {
printf("Registering action handler chint_add_to_workflow failed %d\n", ifail); printf("Registering action handler chint_add_to_workflow failed %d\n", ifail);
} }
ifail = EPM_register_action_handler("chint_remove_other_deisgndata", "chint_remove_other_deisgndata", (EPM_action_handler_t)chint_remove_other_deisgndata); ITKCALL(ifail = EPM_register_action_handler("chint_remove_other_deisgndata", "chint_remove_other_deisgndata", (EPM_action_handler_t)chint_remove_other_deisgndata));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler chint_remove_other_deisgndata successful\n"); printf("Registering action handler chint_remove_other_deisgndata successful\n");
} }
else { else {
printf("Registering action handler chint_remove_other_deisgndata failed %d\n", ifail); printf("Registering action handler chint_remove_other_deisgndata failed %d\n", ifail);
} }
ifail = EPM_register_action_handler("chint_check_exist_ebom", "chint_check_exist_ebom", (EPM_action_handler_t)chint_check_exist_ebom); ITKCALL(ifail = EPM_register_action_handler("chint_check_exist_ebom", "chint_check_exist_ebom", (EPM_action_handler_t)chint_check_exist_ebom));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler chint_check_exist_ebom successful\n"); printf("Registering action handler chint_check_exist_ebom successful\n");
} }
@ -201,7 +201,7 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar
printf("Registering action handler chint_check_exist_ebom failed %d\n", ifail); printf("Registering action handler chint_check_exist_ebom failed %d\n", ifail);
} }
ifail = EPM_register_action_handler("chint_backCheckTable", "chint_backCheckTable", (EPM_action_handler_t)chint_backCheckTable); ITKCALL(ifail = EPM_register_action_handler("chint_backCheckTable", "chint_backCheckTable", (EPM_action_handler_t)chint_backCheckTable));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler chint_backCheckTable successful\n"); printf("Registering action handler chint_backCheckTable successful\n");
} }
@ -209,7 +209,7 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar
printf("Registering action handler chint_backCheckTable failed %d\n", ifail); printf("Registering action handler chint_backCheckTable failed %d\n", ifail);
} }
ifail = EPM_register_action_handler("chint_CheckTable_State", "chint_CheckTable_State", (EPM_action_handler_t)chint_CheckTable_State); ITKCALL(ifail = EPM_register_action_handler("chint_CheckTable_State", "chint_CheckTable_State", (EPM_action_handler_t)chint_CheckTable_State));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler chint_CheckTable_State successful\n"); printf("Registering action handler chint_CheckTable_State successful\n");
} }
@ -217,7 +217,7 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar
printf("Registering action handler chint_CheckTable_State failed %d\n", ifail); printf("Registering action handler chint_CheckTable_State failed %d\n", ifail);
} }
ifail = EPM_register_action_handler("chint_check_ZC_ZJ_BOM", "chint_check_ZC_ZJ_BOM", (EPM_action_handler_t)chint_check_ZC_ZJ_BOM); ITKCALL(ifail = EPM_register_action_handler("chint_check_ZC_ZJ_BOM", "chint_check_ZC_ZJ_BOM", (EPM_action_handler_t)chint_check_ZC_ZJ_BOM));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler chint_check_ZC_ZJ_BOM successful\n"); printf("Registering action handler chint_check_ZC_ZJ_BOM successful\n");
} }
@ -225,14 +225,14 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar
printf("Registering action handler chint_check_ZC_ZJ_BOM failed %d\n", ifail); printf("Registering action handler chint_check_ZC_ZJ_BOM failed %d\n", ifail);
} }
ifail = EPM_register_action_handler("CHINT_task_complete", "CHINT_task_complete", (EPM_action_handler_t)CHINT_task_complete); ITKCALL(ifail = EPM_register_action_handler("CHINT_task_complete", "CHINT_task_complete", (EPM_action_handler_t)CHINT_task_complete));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler CHINT_task_complete successful\n"); printf("Registering action handler CHINT_task_complete successful\n");
} }
else { else {
printf("Registering action handler CHINT_task_complete failed %d\n", ifail); printf("Registering action handler CHINT_task_complete failed %d\n", ifail);
} }
ifail = EPM_register_action_handler("CHINT_yptask_complete", "CHINT_yptask_complete", (EPM_action_handler_t)CHINT_yptask_complete); ITKCALL(ifail = EPM_register_action_handler("CHINT_yptask_complete", "CHINT_yptask_complete", (EPM_action_handler_t)CHINT_yptask_complete));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler CHINT_yptask_complete successful\n"); printf("Registering action handler CHINT_yptask_complete successful\n");
} }
@ -240,14 +240,14 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar
printf("Registering action handler CHINT_yptask_complete failed %d\n", ifail); printf("Registering action handler CHINT_yptask_complete failed %d\n", ifail);
} }
ifail = EPM_register_action_handler("CHINT_cossheet_upgrade", "CHINT_cossheet_upgrade", (EPM_action_handler_t)CHINT_cossheet_upgrade); ITKCALL(ifail = EPM_register_action_handler("CHINT_cossheet_upgrade", "CHINT_cossheet_upgrade", (EPM_action_handler_t)CHINT_cossheet_upgrade));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler CHINT_cossheet_upgrade successful\n"); printf("Registering action handler CHINT_cossheet_upgrade successful\n");
} }
else { else {
printf("Registering action handler CHINT_cossheet_upgrade failed %d\n", ifail); printf("Registering action handler CHINT_cossheet_upgrade failed %d\n", ifail);
} }
ifail = EPM_register_action_handler("CHINT_SendOAMaterial", "CHINT_SendOAMaterial", (EPM_action_handler_t)CHINT_SendOAMaterial); ITKCALL(ifail = EPM_register_action_handler("CHINT_SendOAMaterial", "CHINT_SendOAMaterial", (EPM_action_handler_t)CHINT_SendOAMaterial));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler CHINT_SendOAMaterial successful\n"); printf("Registering action handler CHINT_SendOAMaterial successful\n");
} }
@ -255,7 +255,7 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar
printf("Registering action handler CHINT_SendOAMaterial failed %d\n", ifail); printf("Registering action handler CHINT_SendOAMaterial failed %d\n", ifail);
} }
//oa 版本加入流程 //oa 版本加入流程
ifail = EPM_register_action_handler("CHINT_GetFrock", "CHINT_GetFrock", (EPM_action_handler_t)CHINT_GetFrock); ITKCALL(ifail = EPM_register_action_handler("CHINT_GetFrock", "CHINT_GetFrock", (EPM_action_handler_t)CHINT_GetFrock));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler CHINT_GetFrock successful\n"); printf("Registering action handler CHINT_GetFrock successful\n");
} }
@ -263,7 +263,7 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar
printf("Registering action handler CHINT_GetFrock failed %d\n", ifail); printf("Registering action handler CHINT_GetFrock failed %d\n", ifail);
} }
//oa 变更传递OA //oa 变更传递OA
ifail = EPM_register_action_handler("chint_ecn_to_oa", "chint_ecn_to_oa", (EPM_action_handler_t)CHINT_ECN_SendOA); ITKCALL(ifail = EPM_register_action_handler("chint_ecn_to_oa", "chint_ecn_to_oa", (EPM_action_handler_t)CHINT_ECN_SendOA));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler chint_ecn_to_oa successful\n"); printf("Registering action handler chint_ecn_to_oa successful\n");
} }
@ -271,7 +271,7 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar
printf("Registering action handler chint_ecn_to_oa failed %d\n", ifail); printf("Registering action handler chint_ecn_to_oa failed %d\n", ifail);
} }
//3.9.2.2.1流程指派人员自动获取 //3.9.2.2.1流程指派人员自动获取
ifail = EPM_register_action_handler("CHINT_Assignment", "CHINT_Assignment", (EPM_action_handler_t)CHINT_Assignment); ITKCALL(ifail = EPM_register_action_handler("CHINT_Assignment", "CHINT_Assignment", (EPM_action_handler_t)CHINT_Assignment));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler CHINT_Assignment successful\n"); printf("Registering action handler CHINT_Assignment successful\n");
} }
@ -279,7 +279,7 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar
printf("Registering action handler CHINT_Assignment failed %d\n", ifail); printf("Registering action handler CHINT_Assignment failed %d\n", ifail);
} }
//更改通知单新版excel文件签名 //更改通知单新版excel文件签名
ifail = EPM_register_action_handler("chint_ecn_signoff", "chint_ecn_signoff", (EPM_action_handler_t)chint_ecn_signoff); ITKCALL(ifail = EPM_register_action_handler("chint_ecn_signoff", "chint_ecn_signoff", (EPM_action_handler_t)chint_ecn_signoff));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler chint_ecn_signoff successful\n"); printf("Registering action handler chint_ecn_signoff successful\n");
} }
@ -287,14 +287,38 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar
printf("Registering action handler chint_ecn_signoff failed %d\n", ifail); printf("Registering action handler chint_ecn_signoff failed %d\n", ifail);
} }
//指派变更会签节点 //指派变更会签节点
ifail = EPM_register_action_handler("chint_ecn_assign", "chint_ecn_assign", (EPM_action_handler_t)chint_ecn_assign); ITKCALL(ifail = EPM_register_action_handler("chint_ecn_assign", "chint_ecn_assign", (EPM_action_handler_t)chint_ecn_assign));
if (ifail == 0) { if (ifail == 0) {
printf("Registering action handler chint_ecn_assign successful\n"); printf("Registering action handler chint_ecn_assign successful\n");
} }
else { else {
printf("Registering action handler chint_ecn_assign failed %d\n", ifail); printf("Registering action handler chint_ecn_assign failed %d\n", ifail);
} }
//SRM
ITKCALL(ifail = EPM_register_action_handler("CHINT_DRAWING_TO_SRM", "CHINT_DRAWING_TO_SRM", (EPM_action_handler_t)CHINT_DRAWING_TO_SRM));
if (ifail == 0) {
printf("Registering action handler CHINT_DRAWING_TO_SRM successful\n");
}
else {
printf("Registering action handler CHINT_DRAWING_TO_SRM failed %d\n", ifail);
}
//飞书通知
ITKCALL(ifail = EPM_register_action_handler("chint_changenotice", "chint_changenotice", (EPM_action_handler_t)chint_changenotice));
if (ifail == 0) {
printf("Registering action handler chint_changenotice successful\n");
}
else {
printf("Registering action handler chint_changenotice failed %d\n", ifail);
}
//BOM物料封存停用状态
ITKCALL(ifail = EPM_register_action_handler("chint_check_materialstatus", "chint_check_materialstatus", (EPM_action_handler_t)chint_check_materialstatus));
if (ifail == 0) {
printf("Registering action handler chint_check_materialstatus successful\n");
}
else {
printf("Registering action handler chint_check_materialstatus failed %d\n", ifail);
}
return ifail; return ifail;
} }

@ -0,0 +1,157 @@
/**
* @file common_itk_util.cpp
* @brief itk warpper utility function
* @author James
* @history
* ===================================================================================
* Date Name Description of Change
* 18-July-2008 Ray
*/
//#include <tc/tc.h>
#include <tc/tc_util.h>
#include <tc/tc_arguments.h>
#include <base_utils/mem.h>
#include <fclasses/tc_string.h>
#include <stdlib.h>
#include <string>
#include <stdio.h>
#include <time.h>
using namespace std;
//
#ifdef WIN32
#include <io.h>
#include <direct.h>
#else
#include <unistd.h>
#endif
//
#include "tc_log.h"
#define ARGS_LENGTH 200
#define MAX_PRINTLINE_LENGTH 2000
#define MAX_PATH_LENGTH 2000
#define MAX_ARGUMENT_LENGTH 400
#define MAX_PARAMNAME_LENGTH 50
#define MAX_FILE_EXT_LENGTH 10
#define TRUE_FLAG 1
#define FALSE_FLAG 0
#define DETAILLOG 1
#define DOFREE(obj) \
{ \
if(obj) \
{ \
MEM_free(obj); \
obj = NULL; \
} \
}
FILE* log_file = NULL;
char *log_path = NULL;
void CreateTcLogFile(const char* logFileName)
{
int i=0;
log_file = NULL;
if (log_path) {
MEM_free(log_path);
log_path = NULL;
}
log_path = (char*)MEM_alloc((strlen(logFileName) + 1) * sizeof(char*));
strcpy(log_path, logFileName);
//get lidy_logFileName
//sprintf(lidy_logFileName, "%s", lidy_logFileName);
printf("log file name: %s\n", logFileName);
//create log file
if((log_file = fopen(logFileName, "a"))==NULL)
{
printf("log file create failed\n");
}
}
void WriteTcLog(const char* format, ...)
{
va_list arg;
char tmp[8192];
if(log_file)
{
//get the message
memset(tmp, 0, sizeof(tmp));
va_start(arg, format);
vsprintf(tmp, format, arg);
va_end(arg);
//----------print to command window for trace--------//
printf("%s\n", tmp);
//print message to log file
fprintf(log_file, "%s\n", tmp);
fflush(log_file);
}
else
{
printf("*!Error!*: Log File Not Exist\n");
}
}
void CloseTcLog(void)
{
if(log_file)
{
fclose(log_file);
log_file = NULL;
}
if (log_path) {
MEM_free(log_path);
log_path = NULL;
}
}
void log_open(void) {
if (log_path) {
if ((log_file = fopen(log_path, "a")) == NULL) {
printf("log file create failed\n");
}
}
}
void log_close(void) {
if (log_file) {
fclose(log_file);
log_file = NULL;
}
}
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;
}

@ -7,6 +7,7 @@
* Date Name Description of Change * Date Name Description of Change
* 09-July-2008 Ray * 09-July-2008 Ray
*/ */
#ifndef TC_LOG_H #ifndef TC_LOG_H
#define TC_LOG_H #define TC_LOG_H
@ -14,10 +15,16 @@
extern "C" { extern "C" {
#endif #endif
//void CreateLogFile(char* logFileName); void CreateTcLogFile(const char* logFileName);
//void WriteLog(const char* format, ...); void WriteTcLog(const char* format, ...);
//void CloseLog(void); void CloseTcLog(void);
void log_open(void);
void log_close(void);
string getNow(char* format);
//int FindDatasetReferenceExt( tag_t datasettype, const char *datasettype_ref, char ext[10] );
//int CompareDate( date_t date1, date_t date2 );
//int GetRandomTempFile( char tempFile[256] );
//logical IsItemRevisionType( char object_type[WSO_name_size_c + 1] );
#ifdef __cplusplus #ifdef __cplusplus
} }

Loading…
Cancel
Save