From 2891a6fbf24014cf014c2581cd107b126067ea20 Mon Sep 17 00:00:00 2001 From: "lidy@connor.net.cn" Date: Tue, 6 Aug 2024 17:20:05 +0800 Subject: [PATCH] =?UTF-8?q?20240806=E4=BB=A3=E7=A0=81=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- General/General/AutoFeeding.cpp | 3 + General/General/CHINT_CHANGEBOM_TO_SRM.cxx | 31 ++- General/General/CHINT_CHANGETZCG_TO_SRM.cpp | 225 ++++++++++++++++++ General/General/CHINT_CSH_CHECK - 鍓湰.cxx | 220 +++++++++++++++++ General/General/CHINT_CSH_CHECK.cxx | 65 ++--- General/General/CHINT_DRAWING_TO_SRM.cpp | 8 +- General/General/CHINT_Ecn_SendOA.cxx | 102 +++++--- .../General/CRUL_server_call_httpserver.cpp | 62 ++++- General/General/CRUL_server_call_httpserver.h | 2 +- General/General/General.vcxproj | 1 + General/General/General.vcxproj.filters | 3 + General/General/UpdateWorkTime.cpp | 26 +- General/General/chint_changenotice.cpp | 26 +- General/General/chint_ecn_signoff.cxx | 6 +- General/General/epm_handler_common.h | 1 + General/General/epm_register_handler.cpp | 11 +- General/General/getBomDetails.cxx | 3 + General/General/string_utils.cxx | 12 +- General/General/string_utils.h | 5 +- 19 files changed, 699 insertions(+), 113 deletions(-) create mode 100644 General/General/CHINT_CHANGETZCG_TO_SRM.cpp create mode 100644 General/General/CHINT_CSH_CHECK - 鍓湰.cxx diff --git a/General/General/AutoFeeding.cpp b/General/General/AutoFeeding.cpp index a57f363..9a41857 100644 --- a/General/General/AutoFeeding.cpp +++ b/General/General/AutoFeeding.cpp @@ -272,6 +272,7 @@ void autoFeedLike(tag_t towGxLine, StBomBean& pBean, vector& stBomlin //std::chrono::duration elapsed2 = time2 - time1; //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)); char *uid = NULL, *os = NULL, *os2 = NULL; ITKCALL(AOM_ask_value_string(newChild, "object_string", &uid)); @@ -757,6 +758,7 @@ int AutoFeeding(void *returnValue) { char*** outputValue2 = NULL; printf("search1"); QuerySQLNoInputParam((char*)sql22.c_str(), &colmun2, &count2, &outputValue2);*/ + POM_AM__set_application_bypass(true); char *loginId; ITKCALL(POM_get_user_id(&loginId)); int ifail = ITK_ok; @@ -866,6 +868,7 @@ int AutoFeeding(void *returnValue) { readPbomMsg(bom_line, errBuffer, drawMap, nameMap, loginId, isback); ITKCALL(BOM_close_window(ebom_window)); + POM_AM__set_application_bypass(false); auto end = std::chrono::high_resolution_clock::now(); // 计算时间间隔 diff --git a/General/General/CHINT_CHANGEBOM_TO_SRM.cxx b/General/General/CHINT_CHANGEBOM_TO_SRM.cxx index 92515f6..08362b2 100644 --- a/General/General/CHINT_CHANGEBOM_TO_SRM.cxx +++ b/General/General/CHINT_CHANGEBOM_TO_SRM.cxx @@ -47,16 +47,25 @@ int CHINT_CHANGEBOM_TO_SRM(EPM_action_message_t msg) { ECHO("CHINT_CHANGEBOM_TO_SRM 开始执行\n"); ECHO("=========================================================\n"); 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 cur_task = NULLTAG; - char* jobName = NULL, **url_vals = NULL; + char* jobName = NULL; current_task = msg.task; ITKCALL(AOM_ask_value_string(current_task, "job_name", &jobName)); ITKCALL(EPM_ask_root_task(msg.task, &root_task)); 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)); + 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地址 int url_cnt = 0; char** url = NULL, *urlId = NULL;// @@ -66,12 +75,12 @@ int CHINT_CHANGEBOM_TO_SRM(EPM_action_message_t msg) { vector vec1, vec2; Split(url[i], "=", vec1); 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]); } } if (urls.size() == 0) { - printf("CHINT_ChangeURL首选项中未找到可用地址\n"); + printf("CHINT_ChangeBOMURL首选项中未找到可用地址\n"); return ifail; } 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); } - string email = userId; - email.append("@chint.com"); - string userXML = getUserIdOA(email, urlId); - string userCode = readXmlId(userXML); - char *json_to_char = cJSON_Print(datas); //lidy20240710 string xml = ""); //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); 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()); - if (!returnMsg.empty()) { + WriteLog("解析结果:\n%s", returnMsg.c_str()); + //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())); } } diff --git a/General/General/CHINT_CHANGETZCG_TO_SRM.cpp b/General/General/CHINT_CHANGETZCG_TO_SRM.cpp new file mode 100644 index 0000000..bbeb4cd --- /dev/null +++ b/General/General/CHINT_CHANGETZCG_TO_SRM.cpp @@ -0,0 +1,225 @@ +#include "cJSON.h" + +#include +#include "epm_handler_common.h" +#include +#include +#include +#include +#include +#include +#include +#include "ps/ps.h"; +#include "ps/vrule.h" +#include "sstream" +#include +#include "epm/epm.h" +#include "sa/sa.h" +#include "libxl.h" +#include +#include "epm/signoff.h" +#include +#include +#include +#include +#include "ae/dataset.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "chint_Handler.h" +#include +#include +#include "ado.h" +#include "ocilib.h" +#include +#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; +} \ No newline at end of file diff --git a/General/General/CHINT_CSH_CHECK - 鍓湰.cxx b/General/General/CHINT_CSH_CHECK - 鍓湰.cxx new file mode 100644 index 0000000..685f45e --- /dev/null +++ b/General/General/CHINT_CSH_CHECK - 鍓湰.cxx @@ -0,0 +1,220 @@ + +#include "epm/epm.h" +#include +#include +#include +#include +#include +#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 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; +} \ No newline at end of file diff --git a/General/General/CHINT_CSH_CHECK.cxx b/General/General/CHINT_CSH_CHECK.cxx index 9ca7119..1c9a4b5 100644 --- a/General/General/CHINT_CSH_CHECK.cxx +++ b/General/General/CHINT_CSH_CHECK.cxx @@ -4,9 +4,12 @@ #include #include #include +#include #include "ocilib.h" #include "string_utils.h" #include "epm_handler_common.h" +#include "tc_util.h" + string getCshVal2(string name, string code) { @@ -32,7 +35,7 @@ string getCshVal2(string name, string code) { while (fgets(buf, sizeof buf, pf)) { strResult += buf; } - printf("接口返回:%s", strResult.c_str()); + printf("接口返回:%s\n", strResult.c_str()); _pclose(pf); return strResult; @@ -55,6 +58,11 @@ EPM_decision_t chint_csh_check(EPM_rule_message_t msg) { customError = EPM_nogo; 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; ITKCALL(EPM_ask_root_task(msg.task, &pRoot)); @@ -83,36 +91,35 @@ EPM_decision_t chint_csh_check(EPM_rule_message_t msg) { continue; } //找到总装图的分类属性:是否参数化设计,如果值为是,则进行下述的判断逻辑,如果为否,则跳过,无法检查 - int n_attrs; - char** attr_names = NULL, ** attr_vals = NULL; - ITKCALL(ICS_ask_attributes_of_classification_obj(top_classificationObject, &n_attrs, &attr_names, &attr_vals)); - for (int ii = 0; ii < n_attrs; ii++) { - if (strcmp(attr_names[ii], "是否参数化设计") == 0) { - 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"); - } + char* value = NULL; + ITKCALL(ICS_ask_attribute_value(top_classificationObject, "是否参数化设计", &value)); + printf("是否参数化设计==>%s\n", value); + if (!value || tc_strlen(value) == 0) { + //没维护的话,提示让维护总装图分类属性:是否参数化设计 + msgs.append("请维护总装图分类属性:是否参数化设计;\n"); + } + else if (strcmp(value, "是") == 0) { + char selectRxfs[200]; + sprintf(selectRxfs, "select \"param_code\" from CHINT_CSH_CHECK_RULE where \"factory\"='%s' and \"drawingno\"='%s'", groupName, 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(";"); } } - break; + if (errs.size() > 0) { + msgs.append(id).append("图纸所需的参数化数据:").append(errs).append("缺少数据,请先去参数化软件提交后,再执行流程提交;\n"); + } } } } diff --git a/General/General/CHINT_DRAWING_TO_SRM.cpp b/General/General/CHINT_DRAWING_TO_SRM.cpp index ac807cf..28eb24a 100644 --- a/General/General/CHINT_DRAWING_TO_SRM.cpp +++ b/General/General/CHINT_DRAWING_TO_SRM.cpp @@ -67,7 +67,7 @@ int CHINT_DRAWING_TO_SRM(EPM_action_message_t msg) { tag_t task_tag = NULL_TAG, root_task_tag = NULLTAG, - * attachments;; + *attachments;; task_tag = msg.task; int att_cnt = 0, ifail = 0; int c_sql_value_count = 0; @@ -124,7 +124,7 @@ int CHINT_DRAWING_TO_SRM(EPM_action_message_t msg) { ITKCALL(AOM_ask_value_tags(tagt, "IMAN_specification", &dataset_num, &dataset_tags)); - + for (int k = 0; k < dataset_num; k++) { @@ -147,7 +147,7 @@ int CHINT_DRAWING_TO_SRM(EPM_action_message_t msg) { 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); @@ -167,7 +167,7 @@ int CHINT_DRAWING_TO_SRM(EPM_action_message_t msg) { break;//如果发起多个对象,只写一条数据 } else if (strcmp("ZT2_Design3DRevision", type1) == 0) { - + //判断是否存在物料 int material_num = 0; tag_t* material_tags = NULL; diff --git a/General/General/CHINT_Ecn_SendOA.cxx b/General/General/CHINT_Ecn_SendOA.cxx index b44ce36..0c84fed 100644 --- a/General/General/CHINT_Ecn_SendOA.cxx +++ b/General/General/CHINT_Ecn_SendOA.cxx @@ -98,10 +98,11 @@ cJSON* getDrawingInform(tag_t changeTag) { } 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\""; - char selectRecord2[400]; + char selectRecord2[2048]; sprintf(selectRecord2, searchSql.c_str(), ecnCode.c_str(), section); int outputColumn1 = 0, outputValueCount1 = 0; char*** outputValue1 = NULL; @@ -113,6 +114,7 @@ cJSON* getEHDepart(string ecnCode,string section,string &uuid) { if (i == 0) { vector 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) { uuid = uuidVec[1]; } @@ -219,7 +221,7 @@ int CHINT_ECN_SendOA(EPM_action_message_t msg) { char* log_file = NULL; CreateLogFile("CHINT_ECN_SendOA", &log_file); // //获取当前流程目标 - connectSql(); + //connectSql(); //获取登陆组 tag_t group; char *groupName, *taskUid; @@ -273,9 +275,9 @@ int CHINT_ECN_SendOA(EPM_action_message_t msg) { /*S_ProductFeature 产品特性 字符串 A; B; C S_GCFeeature 过程特性 字符串 A; B; C*/ 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_ChangeNotificationCode", changeRequestNo); + cJSON_AddStringToObject(paramValue, "S_ChangeNotificationCode", itemId); string productFeature, changeTypeStr; if (processCnt > 0) { char *type = processTypes[0]; @@ -359,7 +361,7 @@ int CHINT_ECN_SendOA(EPM_action_message_t msg) { } DisConnServer(); - closeConn(); + //closeConn(); CloseLog(); //string str = uploadMinio("uploadMinio.jar", log_file); 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("=========================================================\n"); 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 cur_task = NULLTAG; - char* jobName = NULL, **url_vals = NULL; + char* jobName = NULL; current_task = msg.task; ITKCALL(AOM_ask_value_string(current_task, "job_name", &jobName)); ITKCALL(EPM_ask_root_task(msg.task, &root_task)); 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)); + 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地址 int url_cnt = 0; char** url = NULL, *urlId = NULL;// @@ -403,7 +415,7 @@ int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg) { vector vec1, vec2; Split(url[i], "=", vec1); 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]); } } @@ -420,6 +432,29 @@ int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg) { char *groupName, *taskUid; ITKCALL(POM_ask_group(&groupName, &group)); 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 bms; + for (int i = 0; i < pref_cnt; i++) { + vector v1; + Split(prefs[i], "|", v1); + if (tc_strcmp(v1[0].c_str(), groupName) != 0) { + continue; + } + vector v2; + Split(v1[1], ";", v2); + for (int j = 0; j < v2.size(); j++) { + vector 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 for (int count = 0; count < occur_of_counts; count++) { char *type; @@ -475,8 +510,19 @@ int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg) { 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, "iffilechange", ecnuid.size() > 0 ? "Y" : "N"); + cJSON_AddStringToObject(paramValue, "iffilechange", iffilechange ? "Y" : "N"); cJSON_AddStringToObject(paramValue, "ecnuid", ecnuid.c_str()); 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_FFBMOther", ""); - cJSON_AddStringToObject(paramValue, "S_ChangeCode", itemId);//更改申请单号 + cJSON_AddStringToObject(paramValue, "S_ChangeCode", changeRequestNo);//更改申请单号 cJSON_AddStringToObject(paramValue, "S_PLMCode", taskUid); - cJSON_AddStringToObject(paramValue, "S_ChangeNotificationCode", changeRequestNo); + cJSON_AddStringToObject(paramValue, "S_ChangeNotificationCode", itemId); //EH_DrawingInformation图样信息 cJSON* infomations = getDrawingInform(taskTag); 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_ZLBZRR", zlbUUid.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_XSZXZRR", xszxUUid.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); //lidy20240710 - string xml = ""); xml.append(json_to_char); xml.append(""); //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); 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()); - if (!returnMsg.empty()) { + WriteLog("解析结果:\n%s", returnMsg.c_str()); + //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())); } } diff --git a/General/General/CRUL_server_call_httpserver.cpp b/General/General/CRUL_server_call_httpserver.cpp index fe35310..2a5ae77 100644 --- a/General/General/CRUL_server_call_httpserver.cpp +++ b/General/General/CRUL_server_call_httpserver.cpp @@ -3,6 +3,10 @@ #include #include #include"tinyxml2.h" +#include "cJSON.h" +#include "common_itk_util.h" +//#include "string_utils.h" + using namespace tinyxml2; size_t write_data(void* ptr, size_t size, size_t nmemb, void* stream) { 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){ CURL *curl; CURLcode res; @@ -253,9 +269,9 @@ string getUserIdOA(string email, string url) { printf("res=%d\n", res); curl_slist_free_all(headers); } - string str_json = out.str(); + string str_json = U2G(out.str().c_str()); 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; } /*通过UUID获取用户ID @@ -296,9 +312,12 @@ string getUserIdOAUUID(string uuid, string url) { } //解析OA的返回信息 string readXmlMSG(string xmlMsg) { - printf("xmlMsg %s \n", xmlMsg.c_str()); + printf("readXmlMSG %s \n", xmlMsg.c_str()); 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* succEle = root->FirstChildElement("Success");//传递状态 tinyxml2::XMLElement* messageEle = root->FirstChildElement("Message");//错误原因 @@ -394,7 +413,7 @@ void updatePiProject(string json,string url) { } /*PLM推送变更通知单数据流信息 */ -string ecnSendOA(string entityParamValues, string url) { +string ecnSendSRM(string entityParamValues, string url) { CURL* curl; CURLcode res; 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_WRITEDATA, &out); 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_SSL_VERIFYPEER, false); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, G2U(entityParamValues.c_str())); @@ -415,10 +434,33 @@ string ecnSendOA(string entityParamValues, string url) { //curl_easy_strerror printf("res=%d\n", res); } - string str_json = out.str(); + string str_json = U2G(out.str().c_str()); curl_easy_cleanup(curl); - printf("return Msg===>%s\n", str_json.c_str()); - string returnMsg = readXmlMSG(str_json); + printf("ecnSendOA return Msg===>%s\n", str_json.c_str()); + 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; } \ No newline at end of file diff --git a/General/General/CRUL_server_call_httpserver.h b/General/General/CRUL_server_call_httpserver.h index 9244134..722acee 100644 --- a/General/General/CRUL_server_call_httpserver.h +++ b/General/General/CRUL_server_call_httpserver.h @@ -12,4 +12,4 @@ string getUserIdOA(string email, string url); string getUserIdOAUUID(string uuid, string url); string getAssignFromYP(string url); void updatePiProject(string json, string url); -string ecnSendOA(string entityParamValues, string url); \ No newline at end of file +string ecnSendSRM(string entityParamValues, string url); \ No newline at end of file diff --git a/General/General/General.vcxproj b/General/General/General.vcxproj index a55bd74..ac5b782 100644 --- a/General/General/General.vcxproj +++ b/General/General/General.vcxproj @@ -184,6 +184,7 @@ + diff --git a/General/General/General.vcxproj.filters b/General/General/General.vcxproj.filters index 86a211d..f95f57f 100644 --- a/General/General/General.vcxproj.filters +++ b/General/General/General.vcxproj.filters @@ -245,5 +245,8 @@ 婧愭枃浠 + + 婧愭枃浠 + \ No newline at end of file diff --git a/General/General/UpdateWorkTime.cpp b/General/General/UpdateWorkTime.cpp index a7e1039..b00e3d9 100644 --- a/General/General/UpdateWorkTime.cpp +++ b/General/General/UpdateWorkTime.cpp @@ -330,12 +330,16 @@ void getTmpProcessUp(string cpxh, string th, string& errBuff, boolean isXq, stri void updateAllProcess(tag_t bom_line, string& errorBuff) { - int c_line_count; - tag_t mantr, *c_line_tags; + int c_line_count = 0; + 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_string(mantr, "object_name", &objName)); ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); - if (c_line_count > 0 && isXnj(mantr)) { - printf("实体\n"); + if (c_line_count > 0 && (strstr(objName, "变压器") != NULL || isXnj(mantr))) { + char* os = NULL; + ITKCALL(AOM_ask_value_string(mantr, "object_string", &os)); + printf("实体:%s\n", os); //检查是否有工艺路线 int n_references = 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)); boolean hasProcess = false; - char* bl_desc, *objName, *itemID; - AOM_ask_value_string(mantr, "object_name", &objName); - AOM_ask_value_string(mantr, "item_id", &itemID); + char* bl_desc, *itemID; + ITKCALL(AOM_ask_value_string(mantr, "item_id", &itemID)); tag_t processTag; for (int i = 0; i < n_references; i++) { char* refType; 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) { hasProcess = true; processTag = refTag; @@ -363,11 +366,12 @@ void updateAllProcess(tag_t bom_line, string& errorBuff) { errorBuff.append("实体未指派工艺路线,请检查:").append(itemID).append("/").append(objName); } else { + printf("objName:%s\n", objName); if (strstr(objName, "变压器") != NULL) { tag_t *byqRev; char *uid; 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; ITK__convert_tag_to_uid(byqRev[0], &uid); printf("objName%s %s\n", objName, uid); @@ -379,7 +383,8 @@ void updateAllProcess(tag_t bom_line, string& errorBuff) { } } 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 descVec1; Split(bl_desc, " ", descVec1); if (descVec1.size() > 1) { @@ -393,6 +398,7 @@ void updateAllProcess(tag_t bom_line, string& errorBuff) { drawNo = drawNoVec1[0].append("-").append(drawNoVec1[1]); wordNo = drawNoVec1[2]; } + printf("drawNo:%s,%s\n", drawNo, wordNo); string byqId = "1ZDB300000P-", tmpGyId; tag_t byqTag, byqRev; byqId.append(wordNo); diff --git a/General/General/chint_changenotice.cpp b/General/General/chint_changenotice.cpp index bd1aa74..c26442f 100644 --- a/General/General/chint_changenotice.cpp +++ b/General/General/chint_changenotice.cpp @@ -146,8 +146,8 @@ int chint_changenotice(EPM_action_message_t msg) { 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); + ITKCALL(EPM_ask_root_task(task_tag, &root_task_tag)); + ITKCALL(EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments)); WriteLog4(true, "流程目标下的对象数量:%d", att_cnt); //分割首选项 @@ -189,15 +189,15 @@ int chint_changenotice(EPM_action_message_t msg) { tag_t group; char* group_name; - AOM_ask_value_tag(tagt, "owning_group", &group); - AOM_ask_value_string(group, "name", &group_name); + ITKCALL(AOM_ask_value_tag(tagt, "owning_group", &group)); + ITKCALL(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); + ITKCALL(POM_get_user(&name, &user)); + ITKCALL(POM_get_user_id(&id)); printf("name================%s\n", name); printf("id================%s\n", id); string users = ""; @@ -250,9 +250,9 @@ int chint_changenotice(EPM_action_message_t msg) { tag_t user; char* duser, *itemId; char* zt2_WBSNo, *zt2_ContractName; - AOM_ask_value_string(tagt, "item_id", &itemId); - AOM_ask_value_string(tagt, "zt2_WBSNo", &zt2_WBSNo); - AOM_ask_value_string(tagt, "zt2_ContractName", &zt2_ContractName); + ITKCALL(AOM_ask_value_string(tagt, "item_id", &itemId)); + ITKCALL(AOM_ask_value_string(tagt, "zt2_WBSNo", &zt2_WBSNo)); + ITKCALL(AOM_ask_value_string(tagt, "zt2_ContractName", &zt2_ContractName)); string th = ""; int wlNum; tag_t* wlTags; @@ -260,18 +260,18 @@ int chint_changenotice(EPM_action_message_t msg) { printf("wlNum======%d\n", wlNum); for (int j = 0; j < wlNum; j++) { 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) { 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(";"); } } printf("th======%s\n", th); - AOM_ask_value_tag(tagt, "owning_user", &user); - AOM_ask_value_string(user, "user_name", &duser); + ITKCALL(AOM_ask_value_tag(tagt, "owning_user", &user)); + ITKCALL(AOM_ask_value_string(user, "user_name", &duser)); //获取当前时间 diff --git a/General/General/chint_ecn_signoff.cxx b/General/General/chint_ecn_signoff.cxx index 7c1fe00..c508332 100644 --- a/General/General/chint_ecn_signoff.cxx +++ b/General/General/chint_ecn_signoff.cxx @@ -377,7 +377,9 @@ int chint_ecn_assign(EPM_action_message_t msg) { id = names2[1]; } else { - //使用分号后的内容调用OA接口,获取用户id + //不管是;还是:都用冒号的逻辑 + id = names[1]; + /*使用分号后的内容调用OA接口,获取用户id char *url = NULL; ITKCALL(PREF_ask_char_value("CHINT_OA_GetUserItems", 0, &url)); if (url == NULL) { @@ -403,7 +405,7 @@ int chint_ecn_assign(EPM_action_message_t msg) { vector emailId; Split(id, "@", emailId); id = emailId[0]; - } + }*/ } printf("id ===>%s\n", id.c_str()); if (id.size() == 0) { diff --git a/General/General/epm_handler_common.h b/General/General/epm_handler_common.h index 68027db..cae6f1d 100644 --- a/General/General/epm_handler_common.h +++ b/General/General/epm_handler_common.h @@ -70,6 +70,7 @@ int chint_changenoticebm(EPM_action_message_t msg); int getBomDetails(void *returnValue); int CHINT_CHANGEITEM_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); //user service end #ifdef __cplusplus diff --git a/General/General/epm_register_handler.cpp b/General/General/epm_register_handler.cpp index 26b2c94..d3b0c9a 100644 --- a/General/General/epm_register_handler.cpp +++ b/General/General/epm_register_handler.cpp @@ -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); } - //检查目标下版本指定关系的数据集是否为空 + //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)); if (ifail == 0) { printf("Registering rule handler chint_csh_check successful\n"); diff --git a/General/General/getBomDetails.cxx b/General/General/getBomDetails.cxx index aa3d4da..1ad1b3f 100644 --- a/General/General/getBomDetails.cxx +++ b/General/General/getBomDetails.cxx @@ -165,6 +165,9 @@ int getBomDetails(void *returnValue) { //产成品物料编码 WBS号 char* wbsNo = cJSON_GetObjectItem(jsonObject1, "wbsno")->valuestring; char* materialNo = cJSON_GetObjectItem(jsonObject1, "ccpmaterialno")->valuestring; + //从左到右,从第一个非0的数字开始 + while (*materialNo == '0') + materialNo++; //返回信息 cJSON* result = cJSON_CreateObject(); cJSON_AddStringToObject(result, "wbsno", wbsNo); diff --git a/General/General/string_utils.cxx b/General/General/string_utils.cxx index 0bdf0ba..5e33b0b 100644 --- a/General/General/string_utils.cxx +++ b/General/General/string_utils.cxx @@ -91,6 +91,15 @@ void Split(string strArg, string spliter, vector& 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 *retVal = NULL; @@ -289,5 +298,4 @@ void GSTR_trim_float( char *floatValue ) if (floatValue[ len - 1 ] == '.') floatValue[ len - 1 ] = '\0'; } -} - +} \ No newline at end of file diff --git a/General/General/string_utils.h b/General/General/string_utils.h index 4b379cc..43cbc74 100644 --- a/General/General/string_utils.h +++ b/General/General/string_utils.h @@ -28,7 +28,10 @@ using namespace std; #define IS_NULL(S) ((S)==NULL) #define IS_EMPTY(S) (((S)==NULL) || !(*(S))) // @}} - void Split( string strArg, string spliter, vector &ans ); + void Split( string strArg, string spliter, vector &ans ); + + const char* trim(const string& str); + /** * Clones the string. * @param dst - the output string.