20240712代码上传

master
李冬阳 11 months ago
parent 252607536c
commit bdcac11b43

@ -131,10 +131,12 @@ struct StBomBean {
vector<StBomBean> childs; vector<StBomBean> childs;
}; };
/*
boolean isSt(tag_t matnr) { 012
*/
int isSt(tag_t matnr) {
int cnt2, numFac, cnt3; int cnt2, numFac, cnt3;
boolean flag = false; int flag = 1;
char** procureType, ** factorys, ** specialProcureType,*objName; char** procureType, ** factorys, ** specialProcureType,*objName;
ITKCALL(AOM_ask_value_strings(matnr, "zt2_SZSpecialProcuretype", &cnt3, &specialProcureType)); //为/ ITKCALL(AOM_ask_value_strings(matnr, "zt2_SZSpecialProcuretype", &cnt3, &specialProcureType)); //为/
ITKCALL(AOM_ask_value_strings(matnr, "zt2_SZProcuretype", &cnt2, &procureType)); //包含自制 ITKCALL(AOM_ask_value_strings(matnr, "zt2_SZProcuretype", &cnt2, &procureType)); //包含自制
@ -142,8 +144,14 @@ boolean isSt(tag_t matnr) {
//AOM_ask_value_string(matnr, "object_name",&objName); //AOM_ask_value_string(matnr, "object_name",&objName);
for (int i = 0; i < numFac; i++) { for (int i = 0; i < numFac; i++) {
if (tc_strcmp(factorys[i], "M060") == 0 && cnt2 > i && cnt3 > i) { if (tc_strcmp(factorys[i], "M060") == 0 && cnt2 > i && cnt3 > i) {
if (tc_strstr(procureType[i], "自制") != NULL && tc_strcmp(specialProcureType[i], "/") == 0) { if (tc_strstr(procureType[i], "外购") != NULL) {//自制
flag = true; flag = 0;
}
else if (tc_strcmp(specialProcureType[i], "/") == 0) {
flag = 1;
}
else {
flag = 2;
} }
} }
} }
@ -162,28 +170,26 @@ void getBomMessage(vector<StBomBean>& stBomlines, tag_t cBomLine, StBomBean &pBe
char* cName = NULL, * zt2_SZProcuretype = NULL; char* cName = NULL, * zt2_SZProcuretype = NULL;
ITKCALL(AOM_ask_value_tag(cBomLine, "bl_line_object", &cmantr)); ITKCALL(AOM_ask_value_tag(cBomLine, "bl_line_object", &cmantr));
ITKCALL(AOM_ask_value_string(cmantr, "object_name", &cName)); ITKCALL(AOM_ask_value_string(cmantr, "object_name", &cName));
ITKCALL(AOM_UIF_ask_value(cmantr, "zt2_SZProcuretype", &zt2_SZProcuretype)); //外购不再展开投料 //ITKCALL(AOM_UIF_ask_value(cmantr, "zt2_SZProcuretype", &zt2_SZProcuretype)); //外购不再展开投料
printf("虚拟件===>%s\n", cName); printf("虚拟件===>%s\n", cName);
StBomBean bean; StBomBean bean;
bean.bomline = cBomLine; bean.bomline = cBomLine;
bean.currentName = cName; bean.currentName = cName;
bean.flag = false; bean.flag = false;
if (c_line_count > 0 && isSt(cmantr)) { int f = isSt(cmantr);
bean.st = true; //1、程序判断物料版本采购类型是什么如果是外购那么这个物料进行投料有没有子件都一样处理
//stBomlines.push_back(bean); //2、如果是自制那么判断特殊采购类型如果是虚拟那么此物料不投料继续展开BOM子件判断如果没有子那么此物料也算不需要投料的。如果是/,那么将此物料进行投料。
pBean.childs.push_back(bean); if (f == 0 || f == 1) {
} //外购和自制实体不看子级直接投本体
else if (c_line_count == 0) {
bean.st = true; bean.st = true;
// stBomlines.push_back(bean);
pBean.childs.push_back(bean); pBean.childs.push_back(bean);
} }
else if (tc_strcmp(zt2_SZProcuretype, "外购") != 0) { else if (c_line_count > 0) {
//自制虚拟有子级就投子级
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
tag_t c_line_tag = c_line_tags[i]; tag_t c_line_tag = c_line_tags[i];
getBomMessage(stBomlines, c_line_tag, bean); getBomMessage(stBomlines, c_line_tag, bean);
} }
// stBomlines.push_back(bean);
pBean.childs.push_back(bean); pBean.childs.push_back(bean);
} }
} }
@ -200,29 +206,26 @@ void getBomMessage(vector<StBomBean> &stBomlines, tag_t cBomLine) {
ITKCALL(AOM_ask_value_string(cBomLine, "object_string", &os)); ITKCALL(AOM_ask_value_string(cBomLine, "object_string", &os));
ITKCALL(AOM_ask_value_tag(cBomLine, "bl_line_object", &cmantr)); ITKCALL(AOM_ask_value_tag(cBomLine, "bl_line_object", &cmantr));
ITKCALL(AOM_ask_value_string(cmantr, "object_name", &cName)); ITKCALL(AOM_ask_value_string(cmantr, "object_name", &cName));
ITKCALL(AOM_UIF_ask_value(cmantr, "zt2_SZProcuretype", &zt2_SZProcuretype)); //外购不再展开投料 //ITKCALL(AOM_UIF_ask_value(cmantr, "zt2_SZProcuretype", &zt2_SZProcuretype)); //外购不再展开投料
printf("getBomMessage==>%s\n", os); printf("getBomMessage==>%s\n", os);
StBomBean bean; StBomBean bean;
bean.bomline = cBomLine; bean.bomline = cBomLine;
bean.currentName = cName; bean.currentName = cName;
if (c_line_count > 0 && isSt(cmantr)) { int f = isSt(cmantr);
bean.st = true; //1、程序判断物料版本采购类型是什么如果是外购那么这个物料进行投料有没有子件都一样处理
stBomlines.push_back(bean); //2、如果是自制那么判断特殊采购类型如果是虚拟那么此物料不投料继续展开BOM子件判断如果没有子那么此物料也算不需要投料的。如果是/,那么将此物料进行投料。
} if (f == 0 || f == 1) {
else if (c_line_count == 0) { //外购和自制实体不看子级直接投本体
bean.st = true; bean.st = true;
stBomlines.push_back(bean); stBomlines.push_back(bean);
//printf("st = true===>%s\n", cName);
} }
else if (tc_strcmp(zt2_SZProcuretype, "外购") != 0) { else if (c_line_count > 0) {
//虚拟件向下展开 //实体件直接投料 //自制虚拟有子级就投子级
printf("虚拟件============>%s\n", cName);
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
tag_t c_line_tag = c_line_tags[i]; tag_t c_line_tag = c_line_tags[i];
getBomMessage(stBomlines, c_line_tag, bean); getBomMessage(stBomlines, c_line_tag, bean);
} }
stBomlines.push_back(bean); stBomlines.push_back(bean);
printf("虚拟件===========>%zd\n", bean.childs.size());
} }
} }
//虚拟向下展开,实体投料 //虚拟向下展开,实体投料
@ -688,7 +691,7 @@ void readPbomMsg(tag_t bom_line, string &errBuffer, map<string, vector<FeedRule>
ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &rev)); ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &rev));
ITKCALL(AOM_ask_value_string(rev, "item_id", &id)); ITKCALL(AOM_ask_value_string(rev, "item_id", &id));
ITKCALL(AOM_ask_value_string(rev, "object_name", &objName)); ITKCALL(AOM_ask_value_string(rev, "object_name", &objName));
if (c_line_count > 0 && (isSt(rev) || tc_strstr(objName, "变压器") != NULL || isback)) { if (c_line_count > 0 && (isSt(rev) == 1 || tc_strstr(objName, "变压器") != NULL || isback)) {
auto start = std::chrono::high_resolution_clock::now(); auto start = std::chrono::high_resolution_clock::now();
int n_references = 0; int n_references = 0;

@ -261,11 +261,16 @@ int CHINT_CHANGEBOM_TO_SRM(EPM_action_message_t msg) {
string userCode = readXmlId(userXML); string userCode = readXmlId(userXML);
char *json_to_char = cJSON_Print(datas); char *json_to_char = cJSON_Print(datas);
WriteLog("\nworkflowCode=EH_TE_ChangeNotice\nuserCode=%s\nfinishStart=true\n", userCode.c_str()); //lidy20240710
WriteLog("组织之后的JSON\n %s\n", json_to_char); string xml = "<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:ChangeDifferenceSync xmlns:m=\"http://tempuri.org/\"><m:data>");
xml.append(json_to_char);
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("×éÖ¯Ö®ºóµÄ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(userCode.c_str(), json_to_char, urls[i])); returnMsg.append(ecnSendOA(xml, urls[i]));
} }
WriteLog("回传信息\n %s\n", returnMsg.c_str()); WriteLog("回传信息\n %s\n", returnMsg.c_str());
if (!returnMsg.empty()) { if (!returnMsg.empty()) {

@ -0,0 +1,126 @@
#include "epm/epm.h"
#include <tc/preferences.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <ics/ics.h>
#include "ocilib.h"
#include "string_utils.h"
#include "epm_handler_common.h"
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;
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");
}
}
}
break;
}
}
}
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;
}

@ -556,11 +556,17 @@ int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg) {
string userCode = readXmlId(userXML); string userCode = readXmlId(userXML);
char *json_to_char = cJSON_Print(paramValue); char *json_to_char = cJSON_Print(paramValue);
WriteLog("\nworkflowCode=EH_TE_ChangeNotice\nuserCode=%s\nfinishStart=true\n", userCode.c_str()); //lidy20240710
WriteLog("组织之后的JSON\n %s\n", json_to_char); string xml = "<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(json_to_char);
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("×éÖ¯Ö®ºóµÄ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(userCode.c_str(), json_to_char, urls[i])).append("\n"); returnMsg.append(ecnSendOA(xml, urls[i])).append("\n");
} }
WriteLog("回传信息\n %s\n", returnMsg.c_str()); WriteLog("回传信息\n %s\n", returnMsg.c_str());
if (!returnMsg.empty()) { if (!returnMsg.empty()) {

@ -392,3 +392,33 @@ void updatePiProject(string json,string url) {
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
printf("str_json===>%s\n", str_json.c_str()); printf("str_json===>%s\n", str_json.c_str());
} }
/*PLM推送变更通知单数据流信息
*/
string ecnSendOA(string entityParamValues, string url) {
CURL* curl;
CURLcode res;
std::stringstream out;
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
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");
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()));
res = curl_easy_perform(curl);
//curl_easy_strerror
printf("res=%d\n", res);
}
string str_json = out.str();
curl_easy_cleanup(curl);
printf("return Msg===>%s\n", str_json.c_str());
string returnMsg = readXmlMSG(str_json);
return returnMsg;
}

@ -12,3 +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);

@ -116,7 +116,7 @@ void updateTemGxCode(tag_t processTag, map<string, TemGxBean> temGxMap) {
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
tag_t oneGxLine = c_line_tags[i], *towGxLines, oneGx, gxItem; tag_t oneGxLine = c_line_tags[i], *towGxLines, oneGx, gxItem;
char* gxbm1; char* gxbm1;
AOM_ask_value_string(oneGxLine, "bl_ZT2_FirstOPRevision_zt2_ClassificationCode", &gxbm1); ITKCALL(AOM_ask_value_string(oneGxLine, "bl_ZT2_FirstOPRevision_zt2_ClassificationCode", &gxbm1));
printf("gxbm1===>%s\n", gxbm1); printf("gxbm1===>%s\n", gxbm1);
if (temGxMap.count(gxbm1) > 0) { if (temGxMap.count(gxbm1) > 0) {
@ -143,7 +143,7 @@ void updateTemGxCode(tag_t processTag, map<string, TemGxBean> temGxMap) {
} }
int c_cnt = 0; int c_cnt = 0;
BOM_line_ask_all_child_lines(oneGxLine, &c_cnt, &towGxLines); ITKCALL(BOM_line_ask_all_child_lines(oneGxLine, &c_cnt, &towGxLines));
for (int j = 0; j < c_cnt; j++) { for (int j = 0; j < c_cnt; j++) {
tag_t towGxLine = towGxLines[j]; tag_t towGxLine = towGxLines[j];
tag_t towGx, gxItem2; tag_t towGx, gxItem2;

@ -187,6 +187,7 @@
<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" />
<ClCompile Include="CHINT_CSH_CHECK.cxx" />
<ClCompile Include="CHINT_DRAWING_TO_SRM.cpp" /> <ClCompile Include="CHINT_DRAWING_TO_SRM.cpp" />
<ClCompile Include="CHINT_Ecn_SendOA.cxx" /> <ClCompile Include="CHINT_Ecn_SendOA.cxx" />
<ClCompile Include="chint_ecn_signoff.cxx" /> <ClCompile Include="chint_ecn_signoff.cxx" />

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

@ -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);
EPM_decision_t chint_csh_check(EPM_rule_message_t msg);
//user service end //user service end
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -347,6 +347,15 @@ 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);
} }
//检查目标下版本指定关系的数据集是否为空
ITKCALL(ifail = EPM_register_rule_handler("chint_csh_check", "", chint_csh_check));
if (ifail == 0) {
printf("Registering rule handler chint_csh_check successful\n");
}
else {
printf("Registering rule handler chint_csh_check failed %d\n", ifail);
}
return ifail; return ifail;
} }
// //

Loading…
Cancel
Save