20240806代码上传

master
李冬阳 11 months ago
parent bdcac11b43
commit 2891a6fbf2

@ -272,6 +272,7 @@ void autoFeedLike(tag_t towGxLine, StBomBean& pBean, vector<StBomBean>& stBomlin
//std::chrono::duration<double> elapsed2 = time2 - time1; //std::chrono::duration<double> elapsed2 = time2 - time1;
//printf("%s,time2£º%f\n", bl_quantity.c_str(), elapsed2.count()); //printf("%s,time2£º%f\n", bl_quantity.c_str(), elapsed2.count());
POM_AM__set_application_bypass(true);
ITKCALL(BOM_line_copy(towGxLine, pBean.bomline, NULLTAG, &newChild)); ITKCALL(BOM_line_copy(towGxLine, pBean.bomline, NULLTAG, &newChild));
char *uid = NULL, *os = NULL, *os2 = NULL; char *uid = NULL, *os = NULL, *os2 = NULL;
ITKCALL(AOM_ask_value_string(newChild, "object_string", &uid)); ITKCALL(AOM_ask_value_string(newChild, "object_string", &uid));
@ -757,6 +758,7 @@ int AutoFeeding(void *returnValue) {
char*** outputValue2 = NULL; char*** outputValue2 = NULL;
printf("search1"); printf("search1");
QuerySQLNoInputParam((char*)sql22.c_str(), &colmun2, &count2, &outputValue2);*/ QuerySQLNoInputParam((char*)sql22.c_str(), &colmun2, &count2, &outputValue2);*/
POM_AM__set_application_bypass(true);
char *loginId; char *loginId;
ITKCALL(POM_get_user_id(&loginId)); ITKCALL(POM_get_user_id(&loginId));
int ifail = ITK_ok; int ifail = ITK_ok;
@ -866,6 +868,7 @@ int AutoFeeding(void *returnValue) {
readPbomMsg(bom_line, errBuffer, drawMap, nameMap, loginId, isback); readPbomMsg(bom_line, errBuffer, drawMap, nameMap, loginId, isback);
ITKCALL(BOM_close_window(ebom_window)); ITKCALL(BOM_close_window(ebom_window));
POM_AM__set_application_bypass(false);
auto end = std::chrono::high_resolution_clock::now(); auto end = std::chrono::high_resolution_clock::now();
// ¼ÆËãʱ¼ä¼ä¸ô // ¼ÆËãʱ¼ä¼ä¸ô

@ -47,16 +47,25 @@ int CHINT_CHANGEBOM_TO_SRM(EPM_action_message_t msg) {
ECHO("CHINT_CHANGEBOM_TO_SRM ¿ªÊ¼Ö´ÐÐ\n"); ECHO("CHINT_CHANGEBOM_TO_SRM ¿ªÊ¼Ö´ÐÐ\n");
ECHO("=========================================================\n"); ECHO("=========================================================\n");
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, occur_of_counts = 0, url_num; int sub_task_count = 0, occur_of_counts = 0, url_num = 0;
tag_t* taskAttches = NULLTAG; tag_t* taskAttches = NULLTAG;
tag_t cur_task = NULLTAG; tag_t cur_task = NULLTAG;
char* jobName = NULL, **url_vals = NULL; char* jobName = NULL;
current_task = msg.task; current_task = msg.task;
ITKCALL(AOM_ask_value_string(current_task, "job_name", &jobName)); ITKCALL(AOM_ask_value_string(current_task, "job_name", &jobName));
ITKCALL(EPM_ask_root_task(msg.task, &root_task)); ITKCALL(EPM_ask_root_task(msg.task, &root_task));
ITKCALL(EPM_ask_sub_tasks(root_task, &sub_task_count, &sub_tasks)); ITKCALL(EPM_ask_sub_tasks(root_task, &sub_task_count, &sub_tasks));
ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches)); ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches));
char** url_vals = NULL;
ITKCALL(PREF_ask_char_values("database_tc", &url_num, &url_vals));
string sqlurl = url_vals[0];
sqlurl.append("/").append(url_vals[2]);
printf("sqlurl ==> %s \n", sqlurl.c_str());
if (ConnServer(url_vals[3], url_vals[4], (char*)sqlurl.c_str()) == -1) {
ITKCALL(EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, "错误:TC数据库连接失败"));
return EMH_USER_error_base;
}
//»ñÈ¡urlµØÖ· //»ñÈ¡urlµØÖ·
int url_cnt = 0; int url_cnt = 0;
char** url = NULL, *urlId = NULL;// char** url = NULL, *urlId = NULL;//
@ -66,12 +75,12 @@ int CHINT_CHANGEBOM_TO_SRM(EPM_action_message_t msg) {
vector<string> vec1, vec2; vector<string> vec1, vec2;
Split(url[i], "=", vec1); Split(url[i], "=", vec1);
Split(vec1[0], ":", vec2); Split(vec1[0], ":", vec2);
if (tc_strcmp(vec2[0].c_str(), "1") == 0) { if (tc_strcmp(vec2[1].c_str(), "1") == 0) {
urls.push_back(vec1[1]); urls.push_back(vec1[1]);
} }
} }
if (urls.size() == 0) { if (urls.size() == 0) {
printf("CHINT_ChangeURL首选项中未找到可用地址\n"); printf("CHINT_ChangeBOMURL首选项中未找到可用地址\n");
return ifail; return ifail;
} }
ITKCALL(PREF_ask_char_value("CHINT_OAUserID_RUL", 0, &urlId)); ITKCALL(PREF_ask_char_value("CHINT_OAUserID_RUL", 0, &urlId));
@ -255,11 +264,6 @@ int CHINT_CHANGEBOM_TO_SRM(EPM_action_message_t msg) {
cJSON_AddItemToArray(datas, data); cJSON_AddItemToArray(datas, data);
} }
string email = userId;
email.append("@chint.com");
string userXML = getUserIdOA(email, urlId);
string userCode = readXmlId(userXML);
char *json_to_char = cJSON_Print(datas); char *json_to_char = cJSON_Print(datas);
//lidy20240710 //lidy20240710
string xml = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" "; string xml = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" ";
@ -267,13 +271,14 @@ int CHINT_CHANGEBOM_TO_SRM(EPM_action_message_t msg) {
xml.append(json_to_char); xml.append(json_to_char);
xml.append("</m:data></m:ChangeDifferenceSync></SOAP-ENV:Body></SOAP-ENV:Envelope>"); xml.append("</m:data></m:ChangeDifferenceSync></SOAP-ENV:Body></SOAP-ENV:Envelope>");
//WriteLog("\nworkflowCode=EH_TE_ChangeNotice\nuserCode=%s\nfinishStart=true\n", userCode.c_str()); //WriteLog("\nworkflowCode=EH_TE_ChangeNotice\nuserCode=%s\nfinishStart=true\n", userCode.c_str());
WriteLog("组织之后的XMLJSON\n %s\n", xml.c_str()); WriteLog("组织之后的XMLJSON\n%s\n", xml.c_str());
string returnMsg = "";// ecnSendOA(userCode.c_str(), json_to_char, url); string returnMsg = "";// ecnSendOA(userCode.c_str(), json_to_char, url);
for (int i = 0; i < urls.size(); i++) { for (int i = 0; i < urls.size(); i++) {
returnMsg.append(ecnSendOA(xml, urls[i])); returnMsg.append(ecnSendSRM(xml, urls[i]));
} }
WriteLog("回传信息\n %s\n", returnMsg.c_str()); WriteLog("解析结果:\n%s", returnMsg.c_str());
if (!returnMsg.empty()) { //if (returnMsg.size() != 0) {
if (tc_strcmp(returnMsg.c_str(), "S") != 0) {
ITKCALL(EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, returnMsg.c_str())); ITKCALL(EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, returnMsg.c_str()));
} }
} }

@ -0,0 +1,225 @@
#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 WriteLog21(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_CHANGETZCG_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));
WriteLog21(true, "------------------------------------------------------------------------------------");
WriteLog21(true, "=========================");
WriteLog21(true, "CHINT_CHANGETZCG_TO_SRM start");
WriteLog21(true, "=========================");
EPM_ask_root_task(task_tag, &root_task_tag);
EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments);
WriteLog21(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_Change", type1) == 0) {
int ZT2_ChangeAfter_num = 0;
tag_t* ZT2_ChangeAfter_tags = NULL;
ITKCALL(AOM_ask_value_tags(tagt, "ZT2_ChangeAfter", &ZT2_ChangeAfter_num, &ZT2_ChangeAfter_tags));
for (int z = 0; z < ZT2_ChangeAfter_num; z++)
{
char* type2;
ITKCALL(AOM_ask_value_string(ZT2_ChangeAfter_tags[z], "object_type", &type2));
if (strcmp("ZT2_ProcureRevision", type2) == 0) {
//判断是否存在dwg文件
//获取版本下的数据集
char* file_name;
char* origin_file_name;
tag_t* ref_object = NULL;
int n_found = 0;
ITKCALL(AOM_ask_value_tags(ZT2_ChangeAfter_tags[z], "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", type2) == 0) {
//判断是否存在物料
int material_num = 0;
tag_t* material_tags = NULL;
ITKCALL(AOM_ask_value_tags(ZT2_ChangeAfter_tags[z], "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);
WriteLog21(true, "=========================");
WriteLog21(true, "CHINT_CHANGETZCG_TO_SRM end");
WriteLog21(true, "=========================");
return ifail;
}

@ -0,0 +1,220 @@
#include "epm/epm.h"
#include <tc/preferences.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <ics/ics.h>
#include <ics/ics2.h>
#include "ocilib.h"
#include "string_utils.h"
#include "epm_handler_common.h"
#include "tc_util.h"
/*获取分类属性
classId ID
value
id ID
disValue
*/
void getClassValue(char* classId, char* value, int id, char** disValue) {
printf("===================================\n");
printf("获取分类属性 开始\n");
printf("===================================\n");
int count = 0;
int* ids;
int* arraySize;
int* formats;
int* options;
char** names;
char** shortNames;
char** annotations;
char** unit;
char** minValues;
char** maxValues;
char** defaultValues;
char** descriptions;
ITKCALL(ICS_class_describe_attributes(classId, &count, &ids, &names, &shortNames, &annotations, &arraySize,
&formats, &unit, &minValues, &maxValues, &defaultValues, &descriptions, &options));
char* format = NULL;
ITKCALL(ICS_attribute_ask_property(id, "FORMAT1", &format));
printf(">> Format: %s\n", format);
if (format != NULL && strcmp("", format) != 0 && strcmp(" ", format) != 0) {
char* key_lov_name;
int options = 0;
int n_lov_entries = 0;
char** lov_keys;
char** lov_values;
logical* deprecated_staus;
char* owning_site;
int n_shared_sites = 0;
char** shared_sites;
ITKCALL(ICS_keylov_get_keylov(format, &key_lov_name, &options, &n_lov_entries, &lov_keys, &lov_values, &deprecated_staus,
&owning_site, &n_shared_sites, &shared_sites));
printf(">> 下拉值数量: %d\n", n_lov_entries);
if (n_lov_entries == 0) {
*disValue = value;
}
else {
for (int j = 0; j < n_lov_entries; j++) {
if (strcmp(value, lov_keys[j]) == 0) {
printf("lov的选值=>:[%s]\n", lov_values[j]);
*disValue = lov_values[j];
break;
}
}
if (key_lov_name != NULL) {
DOFREE(key_lov_name);
}
if (lov_keys != NULL) {
DOFREE(lov_keys);
}
if (lov_values != NULL) {
DOFREE(lov_values);
}
if (deprecated_staus != NULL) {
DOFREE(deprecated_staus);
}
if (owning_site != NULL) {
DOFREE(owning_site);
}
if (shared_sites != NULL) {
DOFREE(shared_sites);
}
}
}
if (format != NULL) {
DOFREE(format);
}
printf("===================================\n");
printf("获取分类属性 结束\n");
printf("===================================\n");
}
string getCshVal2(string name, string code) {
string strResult = "", schVal = "";
//cmd指令
char cmd[256] = "";
strcpy(cmd, "java -jar \"");
//strcat(cmd, jar_file);
strcat(cmd, getenv("TC_ROOT"));
strcat(cmd, "\\bin\\findCshSql.jar");
strcat(cmd, "\" \"");
strcat(cmd, name.c_str());
strcat(cmd, "\" \"");
strcat(cmd, code.c_str());
strcat(cmd, "\"");
printf("cmd%s\n", cmd);
char buf[8000] = { 0 };
FILE* pf = NULL;
if ((pf = _popen(cmd, "r")) == NULL) {
printf("接口返回1");
}
while (fgets(buf, sizeof buf, pf)) {
strResult += buf;
}
printf("接口返回:%s", strResult.c_str());
_pclose(pf);
return strResult;
}
EPM_decision_t chint_csh_check(EPM_rule_message_t msg) {
printf("********************* chint_csh_check is comming *********************\n");
EPM_decision_t customError = EPM_go;
int url_num = 0;
char** url_vals = NULL;
ITKCALL(PREF_ask_char_values("database_tc", &url_num, &url_vals));
string url = url_vals[0];
url.append("/").append(url_vals[2]);
printf("url ==> %s \n", url.c_str());
if (ConnServer(url_vals[3], url_vals[4], (char*)url.c_str()) == -1)
{
ITKCALL(EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, "错误:TC数据库连接失败"));
customError = EPM_nogo;
return customError;
}
tag_t pRoot = NULLTAG;
ITKCALL(EPM_ask_root_task(msg.task, &pRoot));
int target_count = 0;
tag_t *targets = NULL;
ITKCALL(EPM_ask_attachments(pRoot, EPM_target_attachment, &target_count, &targets));
//map<string, string> map;
string msgs = "";
for (int t = 0; t < target_count; t++) {
char* type = NULL;
ITKCALL(WSOM_ask_object_type2(targets[t], &type));
if (tc_strcmp(type, "ZT2_Design3DRevision") != 0) {
continue;
}
char* item_id = NULL;
ITKCALL(AOM_ask_value_string(targets[t], "item_id", &item_id));
string id = item_id;
//总装图号为前四位+300000P 拼接-后的尾缀
string topID = id.substr(0, 4);
topID.append("300000P").append(id.substr(11));
tag_t top_classificationObject = NULLTAG, topItem = NULLTAG;
ITKCALL(ITEM_find_item(topID.c_str(), &topItem));
ITKCALL(ICS_ask_classification_object(topItem, &top_classificationObject));
if (top_classificationObject == NULLTAG) {
msgs.append(id).append("总装图未发送分类;\n");
continue;
}
//找到总装图的分类属性:是否参数化设计,如果值为是,则进行下述的判断逻辑,如果为否,则跳过,无法检查
int n_attrs = 0;
char** attr_names = NULL, ** attr_vals = NULL;
ITKCALL(ICS_ask_attributes_of_classification_obj(top_classificationObject, &n_attrs, &attr_names, &attr_vals));
boolean weihu = true;
for (int ii = 0; ii < n_attrs; ii++) {
if (strcmp(attr_names[ii], "是否参数化设计") == 0) {
weihu = false;
printf("是否参数化设计==>%s\n", attr_vals[ii]);
if (!attr_vals[ii] || tc_strlen(attr_vals[ii]) == 0) {
//没维护的话,提示让维护总装图分类属性:是否参数化设计
msgs.append("请维护总装图分类属性:是否参数化设计;\n");
}
else if (strcmp(attr_vals[ii], "") == 0) {
char selectRxfs[200];
sprintf(selectRxfs, "select param_code from CHINT_CSH_CHECK_RULE where drawingno='%s'", id.substr(0, 11).c_str());
int outputColumn3 = 0, outputValueCount3 = 0;
char*** outputValue3 = NULL;
printf("search CHINT_CSH_CHECK_RULE ===> %s\n", selectRxfs);
QuerySQLNoInputParam(selectRxfs, &outputColumn3, &outputValueCount3, &outputValue3);
if (outputValueCount3 == 0) {
//errs.append(id).append("");
msgs.append(id).append("图纸未查询到参数代号;\n");
}
else {
string errs = "";
for (int i = 0; i < outputValueCount3; i++) {
string val = getCshVal2(id.substr(12).c_str(), outputValue3[i][0]);
if (val.size() == 0) {
errs.append(outputValue3[i][0]).append(";");
}
}
if (errs.size() > 0) {
msgs.append(id).append("图纸所需的参数化数据:").append(errs).append("缺少数据,请先去参数化软件提交后,再执行流程提交;\n");
}
}
}
break;
}
}
if (weihu) {
//没维护的话,提示让维护总装图分类属性:是否参数化设计
msgs.append("请维护总装图分类属性:是否参数化设计;\n");
}
}
printf("msgs%s\n", msgs.c_str());
DisConnServer();
if (msgs.size() > 0) {
ITKCALL(EMH_store_error_s1(EMH_severity_user_error, 919502, msgs.c_str()));
customError = EPM_nogo;
}
return customError;
}

@ -4,9 +4,12 @@
#include <tccore/aom_prop.h> #include <tccore/aom_prop.h>
#include <tccore/item.h> #include <tccore/item.h>
#include <ics/ics.h> #include <ics/ics.h>
#include <ics/ics2.h>
#include "ocilib.h" #include "ocilib.h"
#include "string_utils.h" #include "string_utils.h"
#include "epm_handler_common.h" #include "epm_handler_common.h"
#include "tc_util.h"
string getCshVal2(string name, string code) { string getCshVal2(string name, string code) {
@ -32,7 +35,7 @@ string getCshVal2(string name, string code) {
while (fgets(buf, sizeof buf, pf)) { while (fgets(buf, sizeof buf, pf)) {
strResult += buf; strResult += buf;
} }
printf("接口返回:%s", strResult.c_str()); printf("接口返回:%s\n", strResult.c_str());
_pclose(pf); _pclose(pf);
return strResult; return strResult;
@ -55,6 +58,11 @@ EPM_decision_t chint_csh_check(EPM_rule_message_t msg) {
customError = EPM_nogo; customError = EPM_nogo;
return customError; return customError;
} }
//获取登陆组
tag_t group = NULLTAG;
char *groupName = NULL;
ITKCALL(POM_ask_group(&groupName, &group));
ITKCALL(AOM_ask_value_string(group, PROP_GROUP_NAME, &groupName));
tag_t pRoot = NULLTAG; tag_t pRoot = NULLTAG;
ITKCALL(EPM_ask_root_task(msg.task, &pRoot)); ITKCALL(EPM_ask_root_task(msg.task, &pRoot));
@ -83,36 +91,35 @@ EPM_decision_t chint_csh_check(EPM_rule_message_t msg) {
continue; continue;
} }
//找到总装图的分类属性:是否参数化设计,如果值为是,则进行下述的判断逻辑,如果为否,则跳过,无法检查 //找到总装图的分类属性:是否参数化设计,如果值为是,则进行下述的判断逻辑,如果为否,则跳过,无法检查
int n_attrs; char* value = NULL;
char** attr_names = NULL, ** attr_vals = NULL; ITKCALL(ICS_ask_attribute_value(top_classificationObject, "是否参数化设计", &value));
ITKCALL(ICS_ask_attributes_of_classification_obj(top_classificationObject, &n_attrs, &attr_names, &attr_vals)); printf("是否参数化设计==>%s\n", value);
for (int ii = 0; ii < n_attrs; ii++) { if (!value || tc_strlen(value) == 0) {
if (strcmp(attr_names[ii], "是否参数化设计") == 0) { //没维护的话,提示让维护总装图分类属性:是否参数化设计
if (strcmp(attr_vals[ii], "") == 0) { msgs.append("请维护总装图分类属性:是否参数化设计;\n");
char selectRxfs[200]; }
sprintf(selectRxfs, "select param_code from CHINT_CSH_CHECK_RULE where drawingno='%s'", id.substr(0, 11).c_str()); else if (strcmp(value, "") == 0) {
int outputColumn3 = 0, outputValueCount3 = 0; char selectRxfs[200];
char*** outputValue3 = NULL; sprintf(selectRxfs, "select \"param_code\" from CHINT_CSH_CHECK_RULE where \"factory\"='%s' and \"drawingno\"='%s'", groupName, id.substr(0, 11).c_str());
printf("search CHINT_CSH_CHECK_RULE ===> %s\n", selectRxfs); int outputColumn3 = 0, outputValueCount3 = 0;
QuerySQLNoInputParam(selectRxfs, &outputColumn3, &outputValueCount3, &outputValue3); char*** outputValue3 = NULL;
if (outputValueCount3 == 0) { printf("search CHINT_CSH_CHECK_RULE ===> %s\n", selectRxfs);
//errs.append(id).append(""); QuerySQLNoInputParam(selectRxfs, &outputColumn3, &outputValueCount3, &outputValue3);
msgs.append(id).append("图纸未查询到参数代号;\n"); if (outputValueCount3 == 0) {
} //errs.append(id).append("");
else { //msgs.append(id).append("图纸未查询到参数代号;\n");
string errs = ""; }
for (int i = 0; i < outputValueCount3; i++) { else {
string val = getCshVal2(id.substr(12).c_str(), outputValue3[i][0]); string errs = "";
if (val.size() == 0) { for (int i = 0; i < outputValueCount3; i++) {
errs.append(outputValue3[i][0]).append(";"); string val = getCshVal2(id.substr(12).c_str(), outputValue3[i][0]);
} if (val.size() == 0) {
} errs.append(outputValue3[i][0]).append(";");
if (errs.size() > 0) {
msgs.append(id).append("图纸所需的参数化数据:").append(errs).append("缺少数据,请先去参数化软件提交后,再执行流程提交;\n");
}
} }
} }
break; if (errs.size() > 0) {
msgs.append(id).append("图纸所需的参数化数据:").append(errs).append("缺少数据,请先去参数化软件提交后,再执行流程提交;\n");
}
} }
} }
} }

@ -67,7 +67,7 @@ int CHINT_DRAWING_TO_SRM(EPM_action_message_t msg) {
tag_t task_tag = NULL_TAG, tag_t task_tag = NULL_TAG,
root_task_tag = NULLTAG, root_task_tag = NULLTAG,
* attachments;; *attachments;;
task_tag = msg.task; task_tag = msg.task;
int att_cnt = 0, ifail = 0; int att_cnt = 0, ifail = 0;
int c_sql_value_count = 0; int c_sql_value_count = 0;

@ -98,10 +98,11 @@ cJSON* getDrawingInform(tag_t changeTag) {
} }
return infomations; return infomations;
} }
cJSON* getEHDepart(string ecnCode,string section,string &uuid) {
cJSON* getEHDepart(string ecnCode, string section, string &uuid) {
string searchSql = "SELECT \"actionstatement\",\"result\",\"pctime\",\"remark\",\"principal\" FROM CHINT_ECN_NOTIFICATION where \"ecncode\" = '%s' and \"section\" = '%s' order by \"no\""; string searchSql = "SELECT \"actionstatement\",\"result\",\"pctime\",\"remark\",\"principal\" FROM CHINT_ECN_NOTIFICATION where \"ecncode\" = '%s' and \"section\" = '%s' order by \"no\"";
char selectRecord2[400]; char selectRecord2[2048];
sprintf(selectRecord2, searchSql.c_str(), ecnCode.c_str(), section); sprintf(selectRecord2, searchSql.c_str(), ecnCode.c_str(), section);
int outputColumn1 = 0, outputValueCount1 = 0; int outputColumn1 = 0, outputValueCount1 = 0;
char*** outputValue1 = NULL; char*** outputValue1 = NULL;
@ -113,6 +114,7 @@ cJSON* getEHDepart(string ecnCode,string section,string &uuid) {
if (i == 0) { if (i == 0) {
vector<string> uuidVec; vector<string> uuidVec;
Split(outputValue1[i][4],";", uuidVec); Split(outputValue1[i][4],";", uuidVec);
printf("outputValue %zd===> %s\n", uuidVec.size(), uuidVec[1].c_str());
if (uuidVec.size() > 1 && strstr(uuidVec[1].c_str(),"null") == NULL) { if (uuidVec.size() > 1 && strstr(uuidVec[1].c_str(),"null") == NULL) {
uuid = uuidVec[1]; uuid = uuidVec[1];
} }
@ -219,7 +221,7 @@ int CHINT_ECN_SendOA(EPM_action_message_t msg) {
char* log_file = NULL; char* log_file = NULL;
CreateLogFile("CHINT_ECN_SendOA", &log_file); // CreateLogFile("CHINT_ECN_SendOA", &log_file); //
//获取当前流程目标 //获取当前流程目标
connectSql(); //connectSql();
//获取登陆组 //获取登陆组
tag_t group; tag_t group;
char *groupName, *taskUid; char *groupName, *taskUid;
@ -273,9 +275,9 @@ int CHINT_ECN_SendOA(EPM_action_message_t msg) {
/*S_ProductFeature 产品特性 字符串 A; B; C /*S_ProductFeature 产品特性 字符串 A; B; C
S_GCFeeature A; B; C*/ S_GCFeeature A; B; C*/
cJSON_AddStringToObject(paramValue, S_GCDM, groupName);//工厂 cJSON_AddStringToObject(paramValue, S_GCDM, groupName);//工厂
cJSON_AddStringToObject(paramValue, "S_ChangeCode", itemId);//更改申请单号 cJSON_AddStringToObject(paramValue, "S_ChangeCode", changeRequestNo);//更改申请单号
cJSON_AddStringToObject(paramValue, "S_PLMCode", taskUid); cJSON_AddStringToObject(paramValue, "S_PLMCode", taskUid);
cJSON_AddStringToObject(paramValue, "S_ChangeNotificationCode", changeRequestNo); cJSON_AddStringToObject(paramValue, "S_ChangeNotificationCode", itemId);
string productFeature, changeTypeStr; string productFeature, changeTypeStr;
if (processCnt > 0) { if (processCnt > 0) {
char *type = processTypes[0]; char *type = processTypes[0];
@ -359,7 +361,7 @@ int CHINT_ECN_SendOA(EPM_action_message_t msg) {
} }
DisConnServer(); DisConnServer();
closeConn(); //closeConn();
CloseLog(); CloseLog();
//string str = uploadMinio("uploadMinio.jar", log_file); //string str = uploadMinio("uploadMinio.jar", log_file);
char date_string[MAX_PATH_LENGTHE], logFileName[MAX_PATH_LENGTHE];; char date_string[MAX_PATH_LENGTHE], logFileName[MAX_PATH_LENGTHE];;
@ -384,16 +386,26 @@ int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg) {
ECHO("CHINT_CHANGEITEM_TO_SRM 开始执行\n"); ECHO("CHINT_CHANGEITEM_TO_SRM 开始执行\n");
ECHO("=========================================================\n"); ECHO("=========================================================\n");
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, occur_of_counts = 0, url_num; int sub_task_count = 0, occur_of_counts = 0;
tag_t* taskAttches = NULLTAG; tag_t* taskAttches = NULLTAG;
tag_t cur_task = NULLTAG; tag_t cur_task = NULLTAG;
char* jobName = NULL, **url_vals = NULL; char* jobName = NULL;
current_task = msg.task; current_task = msg.task;
ITKCALL(AOM_ask_value_string(current_task, "job_name", &jobName)); ITKCALL(AOM_ask_value_string(current_task, "job_name", &jobName));
ITKCALL(EPM_ask_root_task(msg.task, &root_task)); ITKCALL(EPM_ask_root_task(msg.task, &root_task));
ITKCALL(EPM_ask_sub_tasks(root_task, &sub_task_count, &sub_tasks)); ITKCALL(EPM_ask_sub_tasks(root_task, &sub_task_count, &sub_tasks));
ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches)); ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches));
int url_num = 0;
char** url_vals = NULL;
ITKCALL(PREF_ask_char_values("database_tc", &url_num, &url_vals));
string sqlurl = url_vals[0];
sqlurl.append("/").append(url_vals[2]);
printf("sqlurl ==> %s \n", sqlurl.c_str());
if (ConnServer(url_vals[3], url_vals[4], (char*)sqlurl.c_str()) == -1) {
ITKCALL(EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, "错误:TC数据库连接失败"));
return EMH_USER_error_base;
}
//获取url地址 //获取url地址
int url_cnt = 0; int url_cnt = 0;
char** url = NULL, *urlId = NULL;// char** url = NULL, *urlId = NULL;//
@ -403,7 +415,7 @@ int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg) {
vector<string> vec1, vec2; vector<string> vec1, vec2;
Split(url[i], "=", vec1); Split(url[i], "=", vec1);
Split(vec1[0], ":", vec2); Split(vec1[0], ":", vec2);
if (tc_strcmp(vec2[0].c_str(), "1") == 0) { if (tc_strcmp(vec2[1].c_str(), "1") == 0) {
urls.push_back(vec1[1]); urls.push_back(vec1[1]);
} }
} }
@ -420,6 +432,29 @@ int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg) {
char *groupName, *taskUid; char *groupName, *taskUid;
ITKCALL(POM_ask_group(&groupName, &group)); ITKCALL(POM_ask_group(&groupName, &group));
ITKCALL(AOM_ask_value_string(group, PROP_GROUP_NAME, &groupName)); ITKCALL(AOM_ask_value_string(group, PROP_GROUP_NAME, &groupName));
//如果发放部门的采购勾选了那么需要找首选项CHINT_ChangeNoticeBM中的对应的人员加到字段S_CGBZRR
int pref_cnt = 0;
char **prefs = NULL;
ITKCALL(PREF_ask_char_values("CHINT_ChangeNoticeBM", &pref_cnt, &prefs));
vector<string> bms;
for (int i = 0; i < pref_cnt; i++) {
vector<string> v1;
Split(prefs[i], "|", v1);
if (tc_strcmp(v1[0].c_str(), groupName) != 0) {
continue;
}
vector<string> v2;
Split(v1[1], ";", v2);
for (int j = 0; j < v2.size(); j++) {
vector<string> v3;
Split(v2[j], ":", v3);
if (tc_strcmp(v3[0].c_str(), "采购") == 0) {
Split(v3[1], ",", bms);
break;
}
}
break;
}
ITK__convert_tag_to_uid(msg.task, &taskUid); //流程uid ITK__convert_tag_to_uid(msg.task, &taskUid); //流程uid
for (int count = 0; count < occur_of_counts; count++) { for (int count = 0; count < occur_of_counts; count++) {
char *type; char *type;
@ -475,8 +510,19 @@ int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg) {
ecnuid = uid; ecnuid = uid;
} }
} }
bool iffilechange = false;
tag_t *afters = NULLTAG;
ITKCALL(AOM_ask_value_tags(taskTag, "ZT2_ChangeAfter", &ref_cnt, &afters));
for (int i = 0; i < ref_cnt; i++) {
char *type = NULL;
ITKCALL(WSOM_ask_object_type2(afters[i], &type));
if (tc_strcmp(type, "ZT2_Desiqn3DRevision") == 0 || tc_strcmp(type, "ZT2_ProcureRevision") == 0) {
iffilechange = true;
break;
}
}
cJSON_AddStringToObject(paramValue, "ifbomchange", ifbomchange ? "Y" : "N"); cJSON_AddStringToObject(paramValue, "ifbomchange", ifbomchange ? "Y" : "N");
cJSON_AddStringToObject(paramValue, "iffilechange", ecnuid.size() > 0 ? "Y" : "N"); cJSON_AddStringToObject(paramValue, "iffilechange", iffilechange ? "Y" : "N");
cJSON_AddStringToObject(paramValue, "ecnuid", ecnuid.c_str()); cJSON_AddStringToObject(paramValue, "ecnuid", ecnuid.c_str());
cJSON_AddStringToObject(paramValue, "releasedate", releasedate); cJSON_AddStringToObject(paramValue, "releasedate", releasedate);
@ -515,9 +561,9 @@ int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg) {
} }
cJSON_AddStringToObject(paramValue, "S_FFBM", ffbm.c_str());//changeUnits[0] cJSON_AddStringToObject(paramValue, "S_FFBM", ffbm.c_str());//changeUnits[0]
cJSON_AddStringToObject(paramValue, "S_FFBMOther", ""); cJSON_AddStringToObject(paramValue, "S_FFBMOther", "");
cJSON_AddStringToObject(paramValue, "S_ChangeCode", itemId);//更改申请单号 cJSON_AddStringToObject(paramValue, "S_ChangeCode", changeRequestNo);//更改申请单号
cJSON_AddStringToObject(paramValue, "S_PLMCode", taskUid); cJSON_AddStringToObject(paramValue, "S_PLMCode", taskUid);
cJSON_AddStringToObject(paramValue, "S_ChangeNotificationCode", changeRequestNo); cJSON_AddStringToObject(paramValue, "S_ChangeNotificationCode", itemId);
//EH_DrawingInformation图样信息 //EH_DrawingInformation图样信息
cJSON* infomations = getDrawingInform(taskTag); cJSON* infomations = getDrawingInform(taskTag);
cJSON_AddItemToObject(paramValue, "EH_DrawingInformation", infomations); cJSON_AddItemToObject(paramValue, "EH_DrawingInformation", infomations);
@ -541,35 +587,37 @@ int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg) {
cJSON_AddStringToObject(paramValue, "S_GYBZRR", gybUUid.c_str()); cJSON_AddStringToObject(paramValue, "S_GYBZRR", gybUUid.c_str());
cJSON_AddStringToObject(paramValue, "S_ZLBZRR", zlbUUid.c_str()); cJSON_AddStringToObject(paramValue, "S_ZLBZRR", zlbUUid.c_str());
cJSON_AddStringToObject(paramValue, "S_SCBZRR", scbUUid.c_str()); cJSON_AddStringToObject(paramValue, "S_SCBZRR", scbUUid.c_str());
if (tc_strstr(ffbm.c_str(), "采购") != NULL && bms.size() > 0) {
//拼接发放部门对应配置的首选项CHINT_ChangeNoticeBM的人员最终去重以;拼接,写入此字段
if (find(bms.begin(), bms.end(), cgbUUid) != bms.end()) {
cgbUUid = "";
}
for (int i = 0; i < bms.size(); i++) {
if (cgbUUid.size() > 0)
cgbUUid.append(";");
cgbUUid.append(bms[i]);
}
}
cJSON_AddStringToObject(paramValue, "S_CGBZRR", cgbUUid.c_str()); cJSON_AddStringToObject(paramValue, "S_CGBZRR", cgbUUid.c_str());
cJSON_AddStringToObject(paramValue, "S_XSZXZRR", xszxUUid.c_str()); cJSON_AddStringToObject(paramValue, "S_XSZXZRR", xszxUUid.c_str());
cJSON_AddStringToObject(paramValue, "S_CWBZRR", cwbUUid.c_str()); cJSON_AddStringToObject(paramValue, "S_CWBZRR", cwbUUid.c_str());
//ITKCALL(POM_get_user_id(&userId));
tag_t user = NULLTAG;
char* userId = NULL;
ITKCALL(AOM_ask_value_tag(taskTag, "owning_user", &user));
ITKCALL(AOM_ask_value_string(user, "user_id", &userId));
string email = userId;
email.append("@chint.com");
string userXML = getUserIdOA(email, urlId);
string userCode = readXmlId(userXML);
char *json_to_char = cJSON_Print(paramValue); char *json_to_char = cJSON_Print(paramValue);
//lidy20240710 //lidy20240710
string xml = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" "; string xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" ";
xml.append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><SOAP-ENV:Body><m:ChangeNotificationSync xmlns:m=\"http://tempuri.org/\"><m:data>"); xml.append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><SOAP-ENV:Body><m:ChangeNotificationSync xmlns:m=\"http://tempuri.org/\"><m:data>");
xml.append(json_to_char); xml.append(json_to_char);
xml.append("</m:data></m:ChangeNotificationSync></SOAP-ENV:Body></SOAP-ENV:Envelope>"); xml.append("</m:data></m:ChangeNotificationSync></SOAP-ENV:Body></SOAP-ENV:Envelope>");
//WriteLog("\nworkflowCode=EH_TE_ChangeNotice\nuserCode=%s\nfinishStart=true\n", userCode.c_str()); //WriteLog("\nworkflowCode=EH_TE_ChangeNotice\nuserCode=%s\nfinishStart=true\n", userCode.c_str());
WriteLog("组织之后的XMLJSON\n %s\n", xml.c_str()); WriteLog("组织之后的XMLJSON\n%s\n", xml.c_str());
string returnMsg = "";// ecnSendOA(userCode.c_str(), json_to_char, url); string returnMsg = "";// ecnSendOA(userCode.c_str(), json_to_char, url);
for (int i = 0; i < urls.size(); i++) { for (int i = 0; i < urls.size(); i++) {
returnMsg.append(ecnSendOA(xml, urls[i])).append("\n"); returnMsg.append(ecnSendSRM(xml, urls[i]));//.append("\n")
} }
WriteLog("回传信息\n %s\n", returnMsg.c_str()); WriteLog("解析结果:\n%s", returnMsg.c_str());
if (!returnMsg.empty()) { //printf("解析结果:%zd\n", returnMsg.size());
if (tc_strcmp(returnMsg.c_str(), "S") != 0) {
ITKCALL(EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, returnMsg.c_str())); ITKCALL(EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, returnMsg.c_str()));
} }
} }

@ -3,6 +3,10 @@
#include <sstream> #include <sstream>
#include <iostream> #include <iostream>
#include"tinyxml2.h" #include"tinyxml2.h"
#include "cJSON.h"
#include "common_itk_util.h"
//#include "string_utils.h"
using namespace tinyxml2; using namespace tinyxml2;
size_t write_data(void* ptr, size_t size, size_t nmemb, void* stream) { size_t write_data(void* ptr, size_t size, size_t nmemb, void* stream) {
string data((const char*)ptr, (size_t)size * nmemb); string data((const char*)ptr, (size_t)size * nmemb);
@ -12,6 +16,18 @@ size_t write_data(void* ptr, size_t size, size_t nmemb, void* stream) {
const char* trim(const string& str) {
if (str.size() == 0) {
return "";
}
size_t first = str.find_first_not_of(" \t\n\r");
size_t last = str.find_last_not_of(" \t\n\r");
if (first == string::npos) {
//return "";
}
return str.substr(first, (last - first + 1)).c_str();
}
string callHttpserver(string signinfoJsonString, string url){ string callHttpserver(string signinfoJsonString, string url){
CURL *curl; CURL *curl;
CURLcode res; CURLcode res;
@ -253,9 +269,9 @@ string getUserIdOA(string email, string url) {
printf("res=%d\n", res); printf("res=%d\n", res);
curl_slist_free_all(headers); curl_slist_free_all(headers);
} }
string str_json = out.str(); string str_json = U2G(out.str().c_str());
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
printf("return Msg===>%s\n", str_json.c_str()); printf("getUserIdOA Msg===>%s\n", str_json.c_str());
return str_json; return str_json;
} }
/*通过UUID获取用户ID /*通过UUID获取用户ID
@ -296,9 +312,12 @@ string getUserIdOAUUID(string uuid, string url) {
} }
//解析OA的返回信息 //解析OA的返回信息
string readXmlMSG(string xmlMsg) { string readXmlMSG(string xmlMsg) {
printf("xmlMsg %s \n", xmlMsg.c_str()); printf("readXmlMSG %s \n", xmlMsg.c_str());
tinyxml2::XMLDocument doc; tinyxml2::XMLDocument doc;
doc.Parse(xmlMsg.c_str()); XMLError res = doc.Parse(xmlMsg.c_str());
if (res != XML_SUCCESS) {
return xmlMsg;
}
tinyxml2::XMLElement* root = doc.RootElement(); tinyxml2::XMLElement* root = doc.RootElement();
tinyxml2::XMLElement* succEle = root->FirstChildElement("Success");//传递状态 tinyxml2::XMLElement* succEle = root->FirstChildElement("Success");//传递状态
tinyxml2::XMLElement* messageEle = root->FirstChildElement("Message");//错误原因 tinyxml2::XMLElement* messageEle = root->FirstChildElement("Message");//错误原因
@ -394,7 +413,7 @@ void updatePiProject(string json,string url) {
} }
/*PLM推送变更通知单数据流信息 /*PLM推送变更通知单数据流信息
*/ */
string ecnSendOA(string entityParamValues, string url) { string ecnSendSRM(string entityParamValues, string url) {
CURL* curl; CURL* curl;
CURLcode res; CURLcode res;
std::stringstream out; std::stringstream out;
@ -407,7 +426,7 @@ string ecnSendOA(string entityParamValues, string url) {
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &out); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &out);
struct curl_slist *headers = NULL; struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/xml"); headers = curl_slist_append(headers, "Content-Type: text/xml;charset=utf-8");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, G2U(entityParamValues.c_str())); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, G2U(entityParamValues.c_str()));
@ -415,10 +434,33 @@ string ecnSendOA(string entityParamValues, string url) {
//curl_easy_strerror //curl_easy_strerror
printf("res=%d\n", res); printf("res=%d\n", res);
} }
string str_json = out.str(); string str_json = U2G(out.str().c_str());
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
printf("return Msg===>%s\n", str_json.c_str()); printf("ecnSendOA return Msg===>%s\n", str_json.c_str());
string returnMsg = readXmlMSG(str_json); WriteLog("»Ø´«ÐÅÏ¢£º\n %s\n", str_json.c_str());
//string returnMsg = readXmlMSG(str_json);
tinyxml2::XMLDocument doc;
XMLError xml = doc.Parse(str_json.c_str());
if (xml != XML_SUCCESS) {
return str_json;
}
tinyxml2::XMLElement* root = doc.RootElement();
tinyxml2::XMLElement* ChangeNotificationSyncResult = root->FirstChildElement()->FirstChildElement()->FirstChildElement();//´«µÝ״̬
string returnMsg = ChangeNotificationSyncResult->GetText();
printf("ecnSendSRM return===>%s\n", returnMsg.c_str());
cJSON *json = cJSON_Parse(returnMsg.c_str());
if (json == NULL) {
return returnMsg;
}
cJSON *code = cJSON_GetObjectItem(json, "code");
string codeVal = code->valuestring;
if (strcmp(codeVal.c_str(), "S") == 0) {
return "S";
}
cJSON *msg = cJSON_GetObjectItem(json, "msg");
//string msgVal = trim(msg->valuestring);
string msgVal = msg->valuestring;
printf("ecnSendSRM Msg===>%s\n", msgVal.c_str());
return returnMsg; return msgVal;
} }

@ -12,4 +12,4 @@ string getUserIdOA(string email, string url);
string getUserIdOAUUID(string uuid, string url); string getUserIdOAUUID(string uuid, string url);
string getAssignFromYP(string url); string getAssignFromYP(string url);
void updatePiProject(string json, string url); void updatePiProject(string json, string url);
string ecnSendOA(string entityParamValues, string url); string ecnSendSRM(string entityParamValues, string url);

@ -184,6 +184,7 @@
<ClCompile Include="CHINT_CHANGEBOM_TO_SRM.cxx" /> <ClCompile Include="CHINT_CHANGEBOM_TO_SRM.cxx" />
<ClCompile Include="chint_changenotice.cpp" /> <ClCompile Include="chint_changenotice.cpp" />
<ClCompile Include="chint_changenoticebm.cpp" /> <ClCompile Include="chint_changenoticebm.cpp" />
<ClCompile Include="CHINT_CHANGETZCG_TO_SRM.cpp" />
<ClCompile Include="chint_check_exist_ebom.cpp" /> <ClCompile Include="chint_check_exist_ebom.cpp" />
<ClCompile Include="chint_check_materialstatus.cpp" /> <ClCompile Include="chint_check_materialstatus.cpp" />
<ClCompile Include="CHINT_cossheet_upgrade.cpp" /> <ClCompile Include="CHINT_cossheet_upgrade.cpp" />

@ -245,5 +245,8 @@
<ClCompile Include="CHINT_CSH_CHECK.cxx"> <ClCompile Include="CHINT_CSH_CHECK.cxx">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="CHINT_CHANGETZCG_TO_SRM.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -330,12 +330,16 @@ void getTmpProcessUp(string cpxh, string th, string& errBuff, boolean isXq, stri
void updateAllProcess(tag_t bom_line, string& errorBuff) { void updateAllProcess(tag_t bom_line, string& errorBuff) {
int c_line_count; int c_line_count = 0;
tag_t mantr, *c_line_tags; char* objName = NULL;
tag_t mantr = NULLTAG, *c_line_tags = NULLTAG;
ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &mantr)); ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &mantr));
ITKCALL(AOM_ask_value_string(mantr, "object_name", &objName));
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));
if (c_line_count > 0 && isXnj(mantr)) { if (c_line_count > 0 && (strstr(objName, "±äѹÆ÷") != NULL || isXnj(mantr))) {
printf("ʵÌå\n"); char* os = NULL;
ITKCALL(AOM_ask_value_string(mantr, "object_string", &os));
printf("ʵÌ壺%s\n", os);
//检查是否有工艺路线 //检查是否有工艺路线
int n_references = 0; int n_references = 0;
int* levels = 0; int* levels = 0;
@ -344,15 +348,14 @@ void updateAllProcess(tag_t bom_line, string& errorBuff) {
//通过引用关系查找到变更单 //通过引用关系查找到变更单
ITKCALL(WSOM_where_referenced(mantr, 1, &n_references, &levels, &references_tag, &relation_type_name)); ITKCALL(WSOM_where_referenced(mantr, 1, &n_references, &levels, &references_tag, &relation_type_name));
boolean hasProcess = false; boolean hasProcess = false;
char* bl_desc, *objName, *itemID; char* bl_desc, *itemID;
AOM_ask_value_string(mantr, "object_name", &objName); ITKCALL(AOM_ask_value_string(mantr, "item_id", &itemID));
AOM_ask_value_string(mantr, "item_id", &itemID);
tag_t processTag; tag_t processTag;
for (int i = 0; i < n_references; i++) for (int i = 0; i < n_references; i++)
{ {
char* refType; char* refType;
tag_t refTag = references_tag[i]; tag_t refTag = references_tag[i];
AOM_ask_value_string(refTag, "object_type", &refType); ITKCALL(AOM_ask_value_string(refTag, "object_type", &refType));
if (strcmp(refType, "MEProcessRevision") == 0) { if (strcmp(refType, "MEProcessRevision") == 0) {
hasProcess = true; hasProcess = true;
processTag = refTag; processTag = refTag;
@ -363,11 +366,12 @@ void updateAllProcess(tag_t bom_line, string& errorBuff) {
errorBuff.append("实体未指派工艺路线,请检查:").append(itemID).append("/").append(objName); errorBuff.append("实体未指派工艺路线,请检查:").append(itemID).append("/").append(objName);
} }
else { else {
printf("objName£º%s\n", objName);
if (strstr(objName, "变压器") != NULL) { if (strstr(objName, "变压器") != NULL) {
tag_t *byqRev; tag_t *byqRev;
char *uid; char *uid;
int cnt3 = 0; int cnt3 = 0;
AOM_ask_value_tags(mantr, "TC_Is_Represented_By", &cnt3, &byqRev); ITKCALL(AOM_ask_value_tags(mantr, "TC_Is_Represented_By", &cnt3, &byqRev));
ByqBean2 bean; ByqBean2 bean;
ITK__convert_tag_to_uid(byqRev[0], &uid); ITK__convert_tag_to_uid(byqRev[0], &uid);
printf("objName%s %s\n", objName, uid); printf("objName%s %s\n", objName, uid);
@ -379,7 +383,8 @@ void updateAllProcess(tag_t bom_line, string& errorBuff) {
} }
} }
else { else {
AOM_ask_value_string(bom_line, "bl_rev_object_desc", &bl_desc); ITKCALL(AOM_ask_value_string(bom_line, "bl_rev_object_desc", &bl_desc));
printf("bl_rev_object_desc£º%s\n", bl_desc);
vector<string> descVec1; vector<string> descVec1;
Split(bl_desc, " ", descVec1); Split(bl_desc, " ", descVec1);
if (descVec1.size() > 1) { if (descVec1.size() > 1) {
@ -393,6 +398,7 @@ void updateAllProcess(tag_t bom_line, string& errorBuff) {
drawNo = drawNoVec1[0].append("-").append(drawNoVec1[1]); drawNo = drawNoVec1[0].append("-").append(drawNoVec1[1]);
wordNo = drawNoVec1[2]; wordNo = drawNoVec1[2];
} }
printf("drawNo£º%s£¬%s\n", drawNo, wordNo);
string byqId = "1ZDB300000P-", tmpGyId; string byqId = "1ZDB300000P-", tmpGyId;
tag_t byqTag, byqRev; tag_t byqTag, byqRev;
byqId.append(wordNo); byqId.append(wordNo);

@ -146,8 +146,8 @@ int chint_changenotice(EPM_action_message_t msg) {
WriteLog4(true, "chint_changenotice start"); WriteLog4(true, "chint_changenotice start");
WriteLog4(true, "========================="); WriteLog4(true, "=========================");
EPM_ask_root_task(task_tag, &root_task_tag); ITKCALL(EPM_ask_root_task(task_tag, &root_task_tag));
EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments); ITKCALL(EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments));
WriteLog4(true, "流程目标下的对象数量:%d", att_cnt); WriteLog4(true, "流程目标下的对象数量:%d", att_cnt);
//分割首选项 //分割首选项
@ -189,15 +189,15 @@ int chint_changenotice(EPM_action_message_t msg) {
tag_t group; tag_t group;
char* group_name; char* group_name;
AOM_ask_value_tag(tagt, "owning_group", &group); ITKCALL(AOM_ask_value_tag(tagt, "owning_group", &group));
AOM_ask_value_string(group, "name", &group_name); ITKCALL(AOM_ask_value_string(group, "name", &group_name));
char* name; char* name;
char* id; char* id;
tag_t user; tag_t user;
POM_get_user(&name, &user); ITKCALL(POM_get_user(&name, &user));
POM_get_user_id(&id); ITKCALL(POM_get_user_id(&id));
printf("name================%s\n", name); printf("name================%s\n", name);
printf("id================%s\n", id); printf("id================%s\n", id);
string users = ""; string users = "";
@ -250,9 +250,9 @@ int chint_changenotice(EPM_action_message_t msg) {
tag_t user; tag_t user;
char* duser, *itemId; char* duser, *itemId;
char* zt2_WBSNo, *zt2_ContractName; char* zt2_WBSNo, *zt2_ContractName;
AOM_ask_value_string(tagt, "item_id", &itemId); ITKCALL(AOM_ask_value_string(tagt, "item_id", &itemId));
AOM_ask_value_string(tagt, "zt2_WBSNo", &zt2_WBSNo); ITKCALL(AOM_ask_value_string(tagt, "zt2_WBSNo", &zt2_WBSNo));
AOM_ask_value_string(tagt, "zt2_ContractName", &zt2_ContractName); ITKCALL(AOM_ask_value_string(tagt, "zt2_ContractName", &zt2_ContractName));
string th = ""; string th = "";
int wlNum; tag_t* wlTags; int wlNum; tag_t* wlTags;
@ -260,18 +260,18 @@ int chint_changenotice(EPM_action_message_t msg) {
printf("wlNum======%d\n", wlNum); printf("wlNum======%d\n", wlNum);
for (int j = 0; j < wlNum; j++) { for (int j = 0; j < wlNum; j++) {
char* thType; char* thType;
AOM_ask_value_string(wlTags[j], "object_type", &thType); ITKCALL(AOM_ask_value_string(wlTags[j], "object_type", &thType));
if (strcmp(thType, "ZT2_Design3DRevision") == 0) { if (strcmp(thType, "ZT2_Design3DRevision") == 0) {
char* thid; char* thid;
AOM_ask_value_string(wlTags[j], "item_id", &thid); ITKCALL(AOM_ask_value_string(wlTags[j], "item_id", &thid));
th.append(thid).append(";"); th.append(thid).append(";");
} }
} }
printf("th======%s\n", th); printf("th======%s\n", th);
AOM_ask_value_tag(tagt, "owning_user", &user); ITKCALL(AOM_ask_value_tag(tagt, "owning_user", &user));
AOM_ask_value_string(user, "user_name", &duser); ITKCALL(AOM_ask_value_string(user, "user_name", &duser));
//获取当前时间 //获取当前时间

@ -377,7 +377,9 @@ int chint_ecn_assign(EPM_action_message_t msg) {
id = names2[1]; id = names2[1];
} }
else { else {
//使用分号后的内容调用OA接口获取用户id //不管是;还是:都用冒号的逻辑
id = names[1];
/*使用分号后的内容调用OA接口获取用户id
char *url = NULL; char *url = NULL;
ITKCALL(PREF_ask_char_value("CHINT_OA_GetUserItems", 0, &url)); ITKCALL(PREF_ask_char_value("CHINT_OA_GetUserItems", 0, &url));
if (url == NULL) { if (url == NULL) {
@ -403,7 +405,7 @@ int chint_ecn_assign(EPM_action_message_t msg) {
vector<string> emailId; vector<string> emailId;
Split(id, "@", emailId); Split(id, "@", emailId);
id = emailId[0]; id = emailId[0];
} }*/
} }
printf("id ===>%s\n", id.c_str()); printf("id ===>%s\n", id.c_str());
if (id.size() == 0) { if (id.size() == 0) {

@ -70,6 +70,7 @@ int chint_changenoticebm(EPM_action_message_t msg);
int getBomDetails(void *returnValue); int getBomDetails(void *returnValue);
int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg); int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg);
int CHINT_CHANGEBOM_TO_SRM(EPM_action_message_t msg); int CHINT_CHANGEBOM_TO_SRM(EPM_action_message_t msg);
int CHINT_CHANGETZCG_TO_SRM(EPM_action_message_t msg);
EPM_decision_t chint_csh_check(EPM_rule_message_t msg); EPM_decision_t chint_csh_check(EPM_rule_message_t msg);
//user service end //user service end
#ifdef __cplusplus #ifdef __cplusplus

@ -347,7 +347,16 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar
printf("Registering action handler CHINT_CHANGEBOM_TO_SRM failed %d\n", ifail); printf("Registering action handler CHINT_CHANGEBOM_TO_SRM failed %d\n", ifail);
} }
//检查目标下版本指定关系的数据集是否为空 //SRM-修改图纸
ITKCALL(ifail = EPM_register_action_handler("CHINT_CHANGETZCG_TO_SRM", "CHINT_CHANGETZCG_TO_SRM", (EPM_action_handler_t)CHINT_CHANGETZCG_TO_SRM));
if (ifail == 0) {
printf("Registering action handler CHINT_CHANGETZCG_TO_SRM successful\n");
}
else {
printf("Registering action handler CHINT_CHANGETZCG_TO_SRM failed %d\n", ifail);
}
//参数化数据校验
ITKCALL(ifail = EPM_register_rule_handler("chint_csh_check", "", chint_csh_check)); ITKCALL(ifail = EPM_register_rule_handler("chint_csh_check", "", chint_csh_check));
if (ifail == 0) { if (ifail == 0) {
printf("Registering rule handler chint_csh_check successful\n"); printf("Registering rule handler chint_csh_check successful\n");

@ -165,6 +165,9 @@ int getBomDetails(void *returnValue) {
//产成品物料编码 WBS号 //产成品物料编码 WBS号
char* wbsNo = cJSON_GetObjectItem(jsonObject1, "wbsno")->valuestring; char* wbsNo = cJSON_GetObjectItem(jsonObject1, "wbsno")->valuestring;
char* materialNo = cJSON_GetObjectItem(jsonObject1, "ccpmaterialno")->valuestring; char* materialNo = cJSON_GetObjectItem(jsonObject1, "ccpmaterialno")->valuestring;
//从左到右从第一个非0的数字开始
while (*materialNo == '0')
materialNo++;
//返回信息 //返回信息
cJSON* result = cJSON_CreateObject(); cJSON* result = cJSON_CreateObject();
cJSON_AddStringToObject(result, "wbsno", wbsNo); cJSON_AddStringToObject(result, "wbsno", wbsNo);

@ -91,6 +91,15 @@ void Split(string strArg, string spliter, vector<string>& ans)
} }
} }
const char* trim(const string& str) {
size_t first = str.find_first_not_of(" \t\n\r");
if (first == string::npos) {
return "";
}
size_t last = str.find_last_not_of(" \t\n\r");
return str.substr(first, (last - first + 1)).c_str();
}
char* GSTR_clone( char **dst, const char *src ) char* GSTR_clone( char **dst, const char *src )
{ {
char *retVal = NULL; char *retVal = NULL;
@ -290,4 +299,3 @@ void GSTR_trim_float( char *floatValue )
floatValue[ len - 1 ] = '\0'; floatValue[ len - 1 ] = '\0';
} }
} }

@ -28,7 +28,10 @@ using namespace std;
#define IS_NULL(S) ((S)==NULL) #define IS_NULL(S) ((S)==NULL)
#define IS_EMPTY(S) (((S)==NULL) || !(*(S))) #define IS_EMPTY(S) (((S)==NULL) || !(*(S)))
// @}} // @}}
void Split( string strArg, string spliter, vector<string> &ans ); void Split( string strArg, string spliter, vector<string> &ans );
const char* trim(const string& str);
/** /**
* Clones the string. * Clones the string.
* @param dst - <OF> the output string. * @param dst - <OF> the output string.

Loading…
Cancel
Save