20240708代码上传

master
李冬阳 11 months ago
parent 161e19925c
commit 252607536c

@ -38,13 +38,16 @@
#include "tc_util.h" #include "tc_util.h"
#include <regex> #include <regex>
#include <ics/ics.h> #include <ics/ics.h>
#include <chrono>
#include "ado.h" #include "ado.h"
#include "ocilib.h" #include "ocilib.h"
using namespace std; using namespace std;
vector<string> cutVec;
tag_t getPBomTag(tag_t designRev) { tag_t getPBomTag(tag_t designRev) {
char* object_type; char* object_type;
AOM_ask_value_string(designRev, "object_type", &object_type); ITKCALL(AOM_ask_value_string(designRev, "object_type", &object_type));
if (strcmp(object_type, "ZT2_Design3DRevision") == 0) { if (strcmp(object_type, "ZT2_Design3DRevision") == 0) {
int num; int num;
tag_t* mantrs; tag_t* mantrs;
@ -80,10 +83,10 @@ void SplitTest(string strArg, string spliter, vector<string> &ans)
} }
void getDrawNo(tag_t bom_line, string &drawNo) { void getDrawNo(tag_t bom_line, string &drawNo) {
char* bl_desc; char* bl_desc;
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));
regex qq_reg2("^1ZDB5.*\\d{1,}1000X.*"); regex qq_reg2("^1ZDB5.*\\d{1,}1000X.*");
//string item_id = id; //string item_id = id;
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));
vector<string> descVec1; vector<string> descVec1;
SplitTest(bl_desc, " ", descVec1); SplitTest(bl_desc, " ", descVec1);
printf("bl_desc===>%s\n", bl_desc); printf("bl_desc===>%s\n", bl_desc);
@ -133,13 +136,13 @@ boolean isSt(tag_t matnr) {
int cnt2, numFac, cnt3; int cnt2, numFac, cnt3;
boolean flag = false; boolean flag = false;
char** procureType, ** factorys, ** specialProcureType,*objName; char** procureType, ** factorys, ** specialProcureType,*objName;
AOM_ask_value_strings(matnr, "zt2_SZSpecialProcuretype", &cnt3, &specialProcureType); //为/ ITKCALL(AOM_ask_value_strings(matnr, "zt2_SZSpecialProcuretype", &cnt3, &specialProcureType)); //为/
AOM_ask_value_strings(matnr, "zt2_SZProcuretype", &cnt2, &procureType); //包含自制 ITKCALL(AOM_ask_value_strings(matnr, "zt2_SZProcuretype", &cnt2, &procureType)); //包含自制
AOM_ask_value_strings(matnr, "zt2_SZFactory", &numFac, &factorys); ITKCALL(AOM_ask_value_strings(matnr, "zt2_SZFactory", &numFac, &factorys));
//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 (strcmp(factorys[i], "M060") == 0 && cnt2 > i && cnt3 > i) { if (tc_strcmp(factorys[i], "M060") == 0 && cnt2 > i && cnt3 > i) {
if (strstr(procureType[i], "自制") != NULL && strcmp(specialProcureType[i], "/") == 0) { if (tc_strstr(procureType[i], "自制") != NULL && tc_strcmp(specialProcureType[i], "/") == 0) {
flag = true; flag = true;
} }
} }
@ -159,7 +162,7 @@ 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_ask_value_string(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;
@ -193,10 +196,12 @@ void getBomMessage(vector<StBomBean> &stBomlines, tag_t cBomLine) {
//ITKCALL(AOM_ask_value_string(mantr, "object_name", &parentName)); //ITKCALL(AOM_ask_value_string(mantr, "object_name", &parentName));
ITKCALL(BOM_line_ask_all_child_lines(cBomLine, &c_line_count, &c_line_tags)); ITKCALL(BOM_line_ask_all_child_lines(cBomLine, &c_line_count, &c_line_tags));
tag_t cmantr = NULLTAG; tag_t cmantr = NULLTAG;
char* cName = NULL, * zt2_SZProcuretype = NULL; char* cName = NULL, * zt2_SZProcuretype = NULL, *os = NULL;
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_ask_value_string(cmantr, "zt2_SZProcuretype", &zt2_SZProcuretype)); //外购不再展开投料 ITKCALL(AOM_UIF_ask_value(cmantr, "zt2_SZProcuretype", &zt2_SZProcuretype)); //外购不再展开投料
printf("getBomMessage==>%s\n", os);
StBomBean bean; StBomBean bean;
bean.bomline = cBomLine; bean.bomline = cBomLine;
bean.currentName = cName; bean.currentName = cName;
@ -221,11 +226,11 @@ void getBomMessage(vector<StBomBean> &stBomlines, tag_t cBomLine) {
} }
} }
//虚拟向下展开,实体投料 //虚拟向下展开,实体投料
void autoFeedLike(tag_t towGxLine, StBomBean& pBean, vector<StBomBean>& stBomlines,double xnQty) { void autoFeedLike(tag_t towGxLine, StBomBean& pBean, vector<StBomBean>& stBomlines, double xnQty) {
if (!pBean.st) { if (!pBean.st) {
char* qty; char* qty;
tag_t line = pBean.bomline; tag_t line = pBean.bomline;
AOM_ask_value_string(line,"bl_quantity",&qty); ITKCALL(AOM_ask_value_string(line,"bl_quantity",&qty));
if (strcmp(qty,"") == 0) { if (strcmp(qty,"") == 0) {
qty = "1"; qty = "1";
} }
@ -237,16 +242,20 @@ void autoFeedLike(tag_t towGxLine, StBomBean& pBean, vector<StBomBean>& stBomlin
} }
} }
else if (!pBean.istl) { else if (!pBean.istl) {
auto start = std::chrono::high_resolution_clock::now();
pBean.istl = true; pBean.istl = true;
tag_t newChild; tag_t newChild = NULLTAG;
tag_t *c_line_tags; tag_t *c_line_tags = NULLTAG;
int c_line_count; int c_line_count = 0;
ITKCALL(BOM_line_ask_all_child_lines(towGxLine, &c_line_count, &c_line_tags)); // 一级工序 ITKCALL(BOM_line_ask_all_child_lines(towGxLine, &c_line_count, &c_line_tags)); // 一级工序
string bl_seq = to_string((c_line_count+1) * 10); string bl_seq = to_string((c_line_count + 1) * 10);
char *bl_qty; //auto time1 = std::chrono::high_resolution_clock::now();
//std::chrono::duration<double> elapsed1 = time1 - start;
//printf("time1%f\n", elapsed1.count());
AOM_ask_value_string(pBean.bomline,"bl_quantity",&bl_qty); char *bl_qty = NULL;
ITKCALL(AOM_ask_value_string(pBean.bomline,"bl_quantity",&bl_qty));
double x = atof(bl_qty); double x = atof(bl_qty);
double xx = xnQty * x; double xx = xnQty * x;
string bl_quantity = bl_qty; string bl_quantity = bl_qty;
@ -256,16 +265,35 @@ void autoFeedLike(tag_t towGxLine, StBomBean& pBean, vector<StBomBean>& stBomlin
else { else {
bl_quantity = to_string(xx); bl_quantity = to_string(xx);
} }
//auto time2 = std::chrono::high_resolution_clock::now();
//std::chrono::duration<double> elapsed2 = time2 - time1;
//printf("%s,time2%f\n", bl_quantity.c_str(), elapsed2.count());
ITKCALL(BOM_line_copy(towGxLine, pBean.bomline, NULLTAG, &newChild)); ITKCALL(BOM_line_copy(towGxLine, pBean.bomline, NULLTAG, &newChild));
printf("bl_quantity==>%s\n", bl_quantity.c_str()); char *uid = NULL, *os = NULL, *os2 = NULL;
ITKCALL(AOM_lock(newChild)); // bl_occ_type ITKCALL(AOM_ask_value_string(newChild, "object_string", &uid));
ITKCALL(AOM_ask_value_string(pBean.bomline, "object_string", &os));
ITKCALL(AOM_ask_value_string(towGxLine, "object_string", &os2));
//ITKCALL(POM_tag_to_uid(towGxLine, &os2));
//ITKCALL(POM_tag_to_uid(pBean.bomline, &os));
//ITKCALL(POM_tag_to_uid(newChild, &uid));
printf("%s:%s:%s:bl_quantity==>%s\n", os2, os, uid, bl_quantity.c_str());
(AOM_lock(newChild)); // bl_occ_type
//设置事例类型 //设置事例类型
ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", bl_seq.c_str())); ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", bl_seq.c_str()));
ITKCALL(AOM_set_value_string(newChild, "bl_quantity", bl_quantity.c_str())); ITKCALL(AOM_set_value_string(newChild, "bl_quantity", bl_quantity.c_str()));
ITKCALL(AOM_set_value_string(newChild,"bl_occ_type","MEConsumed")); ITKCALL(AOM_set_value_string(newChild,"bl_occ_type","MEConsumed"));
ITKCALL(AOM_save(newChild)); (AOM_save(newChild));
ITKCALL(AOM_unlock(newChild)); (AOM_unlock(newChild));
DOFREE(c_line_tags);
DOFREE(bl_qty);
DOFREE(uid);
DOFREE(os);
DOFREE(os2);
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = end - start;
printf("autoFeedLike time%f\n", elapsed.count());
} }
} }
void autoFeedLike(tag_t towGxLine, StBomBean& pBean, string name2, vector<StBomBean>& stBomlines) { void autoFeedLike(tag_t towGxLine, StBomBean& pBean, string name2, vector<StBomBean>& stBomlines) {
@ -285,25 +313,31 @@ void autoFeedLike(tag_t towGxLine, StBomBean& pBean, string name2, vector<StBomB
break; break;
} }
} }
if (strstr(child.currentName.c_str(), nameLike.c_str()) != NULL) { if (tc_strstr(child.currentName.c_str(), nameLike.c_str()) != NULL) {
autoFeedLike(towGxLine, child, stBomlines,1); autoFeedLike(towGxLine, child, stBomlines, 1);
} }
}else if (name2.compare(child.currentName) == 0) { }else if (name2.compare(child.currentName) == 0) {
printf("===================\n"); printf("===================\n");
autoFeedLike(towGxLine, child, stBomlines,1); autoFeedLike(towGxLine, child, stBomlines, 1);
} }
} }
} }
//去掉现有的工序 //去掉现有的工序
void cutGxLine(tag_t bom_line) { void cutGxLine(tag_t bom_line) {
char* os = NULL;
ITKCALL(AOM_ask_value_string(bom_line, "object_string", &os));
if (find(cutVec.begin(), cutVec.end(), os) != cutVec.end()) {
return;
}
cutVec.push_back(os);
tag_t *c_line_tags; tag_t *c_line_tags;
int c_line_count; int c_line_count;
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)); // 一级工序
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
char *bl_occ_type; char *bl_occ_type;
AOM_ask_value_string(c_line_tags[i],"bl_occ_type",&bl_occ_type); ITKCALL(AOM_ask_value_string(c_line_tags[i],"bl_occ_type",&bl_occ_type));
if (strcmp(bl_occ_type,"MEConsumed")==0) { if (strcmp(bl_occ_type,"MEConsumed")==0) {
BOM_line_cut(c_line_tags[i]); ITKCALL(BOM_line_cut(c_line_tags[i]));
} }
} }
@ -314,14 +348,14 @@ void startFeed(tag_t meprocess, vector<StBomBean>& stBomlines, FeedRule bean, st
tag_t ebom_window = NULLTAG; tag_t ebom_window = NULLTAG;
tag_t bom_line = NULLTAG; tag_t bom_line = NULLTAG;
tag_t item_tag = NULLTAG, *c_line_tags; tag_t item_tag = NULLTAG, *c_line_tags;
(BOM_create_window(&ebom_window)); ITKCALL(BOM_create_window(&ebom_window));
tag_t* bvr_list = NULL; tag_t* bvr_list = NULL;
(ITEM_rev_list_bom_view_revs(meprocess, &bvr_count, &bvr_list)); ITKCALL(ITEM_rev_list_bom_view_revs(meprocess, &bvr_count, &bvr_list));
printf("bvr_count=%d", bvr_count); printf("bvr_count=%d", bvr_count);
(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取
//bom_line工艺 //bom_line工艺
int c_line_count; int c_line_count = 0;
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)); // 一级工序
//一级工序 //一级工序
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
@ -330,17 +364,17 @@ void startFeed(tag_t meprocess, vector<StBomBean>& stBomlines, FeedRule bean, st
char* yjName; char* yjName;
tag_t yjGx; tag_t yjGx;
ITKCALL(AOM_ask_value_tag(oneGx, "bl_line_object", &yjGx)); ITKCALL(AOM_ask_value_tag(oneGx, "bl_line_object", &yjGx));
AOM_ask_value_string(yjGx, "object_name", &yjName); ITKCALL(AOM_ask_value_string(yjGx, "object_name", &yjName));
printf("yjName%s %s \n", yjName, bean.yjgx.c_str()); printf("yjName%s %s \n", yjName, bean.yjgx.c_str());
if (bean.yjgx.compare(yjName) == 0) { if (bean.yjgx.compare(yjName) == 0) {
BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines); ITKCALL(BOM_line_ask_all_child_lines(oneGx, &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];
char* ejName; char* ejName;
tag_t ejGx; tag_t ejGx;
ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &ejGx)); ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &ejGx));
AOM_ask_value_string(ejGx, "object_name", &ejName); ITKCALL(AOM_ask_value_string(ejGx, "object_name", &ejName));
printf("ejName%s %s\n", ejName, bean.ejgx.c_str()); printf("ejName%s %s\n", ejName, bean.ejgx.c_str());
if (bean.ejgx.compare(ejName) == 0) { if (bean.ejgx.compare(ejName) == 0) {
printf("stBomlines %zd\n", stBomlines.size()); printf("stBomlines %zd\n", stBomlines.size());
@ -359,8 +393,10 @@ void startFeed(tag_t meprocess, vector<StBomBean>& stBomlines, FeedRule bean, st
} }
} }
} }
BOM_save_window(ebom_window); ITKCALL(BOM_save_window(ebom_window));
BOM_close_window(ebom_window); ITKCALL(BOM_close_window(ebom_window));
DOFREE(bvr_list);
DOFREE(c_line_tags);
} }
//匹配一级工序和二级工序,名称 //匹配一级工序和二级工序,名称
void startFeed(tag_t meprocess, vector<StBomBean>& stBomlines, FeedRule bean, vector<string> names) { void startFeed(tag_t meprocess, vector<StBomBean>& stBomlines, FeedRule bean, vector<string> names) {
@ -368,12 +404,12 @@ void startFeed(tag_t meprocess, vector<StBomBean>& stBomlines, FeedRule bean, ve
tag_t ebom_window = NULLTAG; tag_t ebom_window = NULLTAG;
tag_t bom_line = NULLTAG; tag_t bom_line = NULLTAG;
tag_t item_tag = NULLTAG, *c_line_tags; tag_t item_tag = NULLTAG, *c_line_tags;
(BOM_create_window(&ebom_window)); ITKCALL(BOM_create_window(&ebom_window));
tag_t* bvr_list = NULL; tag_t* bvr_list = NULL;
(ITEM_rev_list_bom_view_revs(meprocess, &bvr_count, &bvr_list)); ITKCALL(ITEM_rev_list_bom_view_revs(meprocess, &bvr_count, &bvr_list));
printf("bvr_count=%d", bvr_count); printf("bvr_count=%d", bvr_count);
(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取
//bom_line工艺 //bom_line工艺
int c_line_count; int c_line_count;
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)); // 一级工序
@ -384,16 +420,16 @@ void startFeed(tag_t meprocess, vector<StBomBean>& stBomlines, FeedRule bean, ve
char* yjName; char* yjName;
tag_t yjGx; tag_t yjGx;
ITKCALL(AOM_ask_value_tag(oneGx, "bl_line_object", &yjGx)); ITKCALL(AOM_ask_value_tag(oneGx, "bl_line_object", &yjGx));
AOM_ask_value_string(yjGx, "object_name", &yjName); ITKCALL(AOM_ask_value_string(yjGx, "object_name", &yjName));
if (bean.yjgx.compare(yjName) == 0) { if (bean.yjgx.compare(yjName) == 0) {
BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines); ITKCALL(BOM_line_ask_all_child_lines(oneGx, &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];
char* ejName; char* ejName;
tag_t ejGx; tag_t ejGx;
ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &ejGx)); ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &ejGx));
AOM_ask_value_string(ejGx, "object_name", &ejName); ITKCALL(AOM_ask_value_string(ejGx, "object_name", &ejName));
if (bean.ejgx.compare(ejName) == 0) { if (bean.ejgx.compare(ejName) == 0) {
cutGxLine(towGxLine); cutGxLine(towGxLine);
for (int t = 0; t < stBomlines.size(); t++) { for (int t = 0; t < stBomlines.size(); t++) {
@ -403,7 +439,7 @@ void startFeed(tag_t meprocess, vector<StBomBean>& stBomlines, FeedRule bean, ve
printf("stBom.currentName2%s %d\n", stBom.currentName.c_str(), !stBom.istl); printf("stBom.currentName2%s %d\n", stBom.currentName.c_str(), !stBom.istl);
if (!stBom.istl) { if (!stBom.istl) {
//投料 未投料的 //投料 未投料的
autoFeedLike(towGxLine, stBom, stBomlines,1); autoFeedLike(towGxLine, stBom, stBomlines, 1);
stBom.istl = true; stBom.istl = true;
} }
} }
@ -412,31 +448,33 @@ void startFeed(tag_t meprocess, vector<StBomBean>& stBomlines, FeedRule bean, ve
} }
} }
} }
BOM_save_window(ebom_window); ITKCALL(BOM_save_window(ebom_window));
BOM_close_window(ebom_window); ITKCALL(BOM_close_window(ebom_window));
DOFREE(bvr_list);
DOFREE(c_line_tags);
} }
void startFeed(tag_t meprocess, vector<StBomBean>& stBomlines, FeedRule bean, string nameLike) { void startFeed(tag_t meprocess, vector<StBomBean>& stBomlines, FeedRule bean, string nameLike) {//89
int bvr_count = 0; int bvr_count = 0;
tag_t ebom_window = NULLTAG; tag_t ebom_window = NULLTAG;
tag_t bom_line = NULLTAG; tag_t bom_line = NULLTAG;
tag_t item_tag = NULLTAG, *c_line_tags; tag_t item_tag = NULLTAG, *c_line_tags;
(BOM_create_window(&ebom_window)); ITKCALL(BOM_create_window(&ebom_window));
tag_t* bvr_list = NULL; tag_t* bvr_list = NULL;
(ITEM_rev_list_bom_view_revs(meprocess, &bvr_count, &bvr_list)); ITKCALL(ITEM_rev_list_bom_view_revs(meprocess, &bvr_count, &bvr_list));
printf("bvr_count=%d", bvr_count); printf("bvr_count=%d", bvr_count);
(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取
//bom_line工艺 //bom_line工艺
int c_line_count; int c_line_count;
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)); // 一级工序
//一级工序 //一级工序
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
tag_t oneGx = c_line_tags[i], *towGxLines; tag_t oneGx = c_line_tags[i], *towGxLines = NULL;
int c_cnt = 0; int c_cnt = 0;
char* yjName; char* yjName = NULL;
tag_t yjGx; tag_t yjGx = NULLTAG;
ITKCALL(AOM_ask_value_tag(oneGx, "bl_line_object", &yjGx)); ITKCALL(AOM_ask_value_tag(oneGx, "bl_line_object", &yjGx));
AOM_ask_value_string(yjGx, "object_name", &yjName); ITKCALL(AOM_ask_value_string(yjGx, "object_name", &yjName));
printf("yjName===>%s %s \n", yjName, bean.yjgx.c_str()); printf("yjName===>%s %s \n", yjName, bean.yjgx.c_str());
boolean falg = false; boolean falg = false;
if (strstr(bean.yjgx.c_str(), "*") != NULL) { if (strstr(bean.yjgx.c_str(), "*") != NULL) {
@ -453,14 +491,14 @@ void startFeed(tag_t meprocess, vector<StBomBean>& stBomlines, FeedRule bean, st
} }
} }
if (bean.yjgx.compare(yjName) == 0 || falg) { if (bean.yjgx.compare(yjName) == 0 || falg) {
BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines); ITKCALL(BOM_line_ask_all_child_lines(oneGx, &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];
char* ejName; char* ejName = NULL;
tag_t ejGx; tag_t ejGx = NULLTAG;
ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &ejGx)); ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &ejGx));
AOM_ask_value_string(ejGx, "object_name", &ejName); ITKCALL(AOM_ask_value_string(ejGx, "object_name", &ejName));
printf("ejName===>%s \n", ejName); printf("ejName===>%s \n", ejName);
if (bean.ejgx.compare(ejName) == 0) { if (bean.ejgx.compare(ejName) == 0) {
cutGxLine(towGxLine); cutGxLine(towGxLine);
@ -474,13 +512,13 @@ void startFeed(tag_t meprocess, vector<StBomBean>& stBomlines, FeedRule bean, st
if (strstr(stBom.currentName.c_str(), nameLike.c_str()) != NULL) { if (strstr(stBom.currentName.c_str(), nameLike.c_str()) != NULL) {
printf("stBom.currentName2==>%s %d\n", stBom.currentName.c_str(), !stBom.st); printf("stBom.currentName2==>%s %d\n", stBom.currentName.c_str(), !stBom.st);
if (!stBom.istl && stBom.flag) { if (!stBom.istl && stBom.flag) {
autoFeedLike(towGxLine, stBom, stBomlines,1); autoFeedLike(towGxLine, stBom, stBomlines, 1);
stBom.istl = true; stBom.istl = true;
} }
} }
} }
else if (!stBom.istl) { else if (!stBom.istl) {
autoFeedLike(towGxLine, stBom, stBomlines,1); autoFeedLike(towGxLine, stBom, stBomlines, 1);
stBom.istl = true; stBom.istl = true;
//ITKCALL(BOM_line_copy(towGxLine, stBom.bomline, NULLTAG, &newChild)); //ITKCALL(BOM_line_copy(towGxLine, stBom.bomline, NULLTAG, &newChild));
} }
@ -491,8 +529,14 @@ void startFeed(tag_t meprocess, vector<StBomBean>& stBomlines, FeedRule bean, st
} }
} }
} }
BOM_save_window(ebom_window); auto start = std::chrono::high_resolution_clock::now();
BOM_close_window(ebom_window); ITKCALL(BOM_save_window(ebom_window));
ITKCALL(BOM_close_window(ebom_window));
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed1 = end - start;
printf("BOM_save_window time%f\n", elapsed1.count());
DOFREE(bvr_list);
DOFREE(c_line_tags);
} }
//map<string, vector<FeedRule>> drawMap; //map<string, vector<FeedRule>> drawMap;
//map<string, vector<FeedRule>> nameMap; //map<string, vector<FeedRule>> nameMap;
@ -520,17 +564,17 @@ void AutoFeedBom(tag_t mantr,tag_t meprocess,
if (drawMap.count(drawNo) > 0) { if (drawMap.count(drawNo) > 0) {
//图号匹配 //图号匹配
vector<FeedRule> beans = drawMap[drawNo]; vector<FeedRule> beans = drawMap[drawNo];
printf("beans===>%zd\n", beans.size()); printf("beans1===>%zd\n", beans.size());
for (int t = 0; t < beans.size(); t++) { for (int t = 0; t < beans.size(); t++) {
FeedRule bean = beans[t]; FeedRule bean = beans[t];
if (bean.tlth.empty()) { if (bean.tlth.empty()) {
//全投 //全投
printf("beans===>%s %s\n", bean.yjgx.c_str(), bean.ejgx.c_str()); printf("beans2===>%s %s\n", bean.yjgx.c_str(), bean.ejgx.c_str());
startFeed(meprocess, stBomlines, bean, ""); startFeed(meprocess, stBomlines, bean, "");
} }
else { else {
//剩下全投 //剩下全投
printf("beans===>%s\n", bean.tlth.c_str()); printf("beans3===>%s\n", bean.tlth.c_str());
if (bean.tlth.compare("else") == 0) { if (bean.tlth.compare("else") == 0) {
startFeed(meprocess, stBomlines, bean, ""); startFeed(meprocess, stBomlines, bean, "");
} }
@ -538,6 +582,7 @@ void AutoFeedBom(tag_t mantr,tag_t meprocess,
string nameMatnr = bean.tlth; string nameMatnr = bean.tlth;
//按名称模糊匹配投 //按名称模糊匹配投
if (strstr(nameMatnr.c_str(), "*") != NULL) { if (strstr(nameMatnr.c_str(), "*") != NULL) {
printf("beans4\n");
vector<string> liVec; vector<string> liVec;
string nameLike; string nameLike;
SplitTest(nameMatnr, "*", liVec); SplitTest(nameMatnr, "*", liVec);
@ -551,11 +596,13 @@ void AutoFeedBom(tag_t mantr,tag_t meprocess,
else { else {
//按名称精准匹配投料 //按名称精准匹配投料
if (strstr(nameMatnr.c_str(), "\\") != NULL) { if (strstr(nameMatnr.c_str(), "\\") != NULL) {
printf("beans5\n");
vector<string> names; vector<string> names;
SplitTest(nameMatnr, "\\", names); SplitTest(nameMatnr, "\\", names);
startFeed(meprocess, stBomlines, bean, names[0], names[1]); startFeed(meprocess, stBomlines, bean, names[0], names[1]);
} }
else { else {
printf("beans6\n");
vector<string> names; vector<string> names;
SplitTest(nameMatnr, ";", names); SplitTest(nameMatnr, ";", names);
startFeed(meprocess, stBomlines, bean, names); startFeed(meprocess, stBomlines, bean, names);
@ -575,10 +622,10 @@ void AutoFeedBom(tag_t mantr,tag_t meprocess,
AOM_ask_value_string(mantr, "object_name", &nowName); AOM_ask_value_string(mantr, "object_name", &nowName);
if (strstr(nowName, s.c_str()) != NULL) { if (strstr(nowName, s.c_str()) != NULL) {
vector<FeedRule> beans = nameMap[s]; vector<FeedRule> beans = nameMap[s];
printf("beans===>%zd\n", beans.size()); printf("beans7===>%zd\n", beans.size());
for (int t = 0; t < beans.size(); t++) { for (int t = 0; t < beans.size(); t++) {
FeedRule bean = beans[t]; FeedRule bean = beans[t];
printf("beans===>%s %s\n", bean.yjgx.c_str(), bean.ejgx.c_str()); printf("beans8===>%s %s\n", bean.yjgx.c_str(), bean.ejgx.c_str());
if (bean.tlth.empty()) { if (bean.tlth.empty()) {
//全投 //全投
startFeed(meprocess, stBomlines, bean, ""); startFeed(meprocess, stBomlines, bean, "");
@ -586,12 +633,14 @@ void AutoFeedBom(tag_t mantr,tag_t meprocess,
else { else {
//剩下全投 //剩下全投
if (bean.tlth.compare("else") == 0) { if (bean.tlth.compare("else") == 0) {
printf("beans9\n");
startFeed(meprocess, stBomlines, bean, ""); startFeed(meprocess, stBomlines, bean, "");
} }
else { else {
string nameMatnr = bean.tlth; string nameMatnr = bean.tlth;
//按名称模糊匹配投 //按名称模糊匹配投
if (strstr(nameMatnr.c_str(), "*") != NULL) { if (strstr(nameMatnr.c_str(), "*") != NULL) {
printf("beans10\n");
vector<string> liVec; vector<string> liVec;
string nameLike; string nameLike;
SplitTest(nameMatnr, "*", liVec); SplitTest(nameMatnr, "*", liVec);
@ -605,12 +654,14 @@ void AutoFeedBom(tag_t mantr,tag_t meprocess,
else { else {
//按名称精准匹配投料 //按名称精准匹配投料
if (strstr(nameMatnr.c_str(), "\\") != NULL) { if (strstr(nameMatnr.c_str(), "\\") != NULL) {
printf("beans11\n");
vector<string> names; vector<string> names;
SplitTest(nameMatnr, "\\", names); SplitTest(nameMatnr, "\\", names);
printf("beans===>%s %s\n", names[0].c_str(), names[1].c_str()); printf("beans===>%s %s\n", names[0].c_str(), names[1].c_str());
startFeed(meprocess, stBomlines, bean, names[0], names[1]); startFeed(meprocess, stBomlines, bean, names[0], names[1]);
} }
else { else {
printf("beans12\n");
vector<string> names; vector<string> names;
SplitTest(nameMatnr, ";", names); SplitTest(nameMatnr, ";", names);
startFeed(meprocess, stBomlines, bean, names); startFeed(meprocess, stBomlines, bean, names);
@ -637,7 +688,8 @@ 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) || strstr(objName, "变压器") != NULL || isback)) { if (c_line_count > 0 && (isSt(rev) || tc_strstr(objName, "变压器") != NULL || isback)) {
auto start = std::chrono::high_resolution_clock::now();
int n_references = 0; int n_references = 0;
int* levels = 0; int* levels = 0;
@ -676,6 +728,14 @@ void readPbomMsg(tag_t bom_line, string &errBuffer, map<string, vector<FeedRule>
AutoFeedBom(rev, meprocess, drawMap, nameMap); AutoFeedBom(rev, meprocess, drawMap, nameMap);
} }
//} //}
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed1 = end - start;
printf("readPbomMsg time%f\n", elapsed1.count());
}
else {
char *os = NULL;
ITKCALL(AOM_ask_value_string(bom_line, "object_string", &os));
printf("readPbomMsg else===>%s\n", os);
} }
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
readPbomMsg(c_line_tags[i], errBuffer, drawMap, nameMap, loginId, false); readPbomMsg(c_line_tags[i], errBuffer, drawMap, nameMap, loginId, false);
@ -684,19 +744,22 @@ void readPbomMsg(tag_t bom_line, string &errBuffer, map<string, vector<FeedRule>
//int EbomToPMethod(void *returnValue); //int EbomToPMethod(void *returnValue);
int AutoFeeding(void *returnValue) { int AutoFeeding(void *returnValue) {
printf("******************* AutoFeeding start *******************\n");
auto start = std::chrono::high_resolution_clock::now();
string sql = "select MC,ZZMB,XH,TLTH,LX,TL,YJGX,EJGX from CHINT_GYGL_001 WHERE LX is not NULL ORDER BY XH "; string sql = "select MC,ZZMB,XH,TLTH,LX,TL,YJGX,EJGX from CHINT_GYGL_001 WHERE LX is not NULL ORDER BY XH ";
cutVec.clear();
/*string sql22 = "select CHINT_MATERIAL_SEQ.nextval as sid from dual"; /*string sql22 = "select CHINT_MATERIAL_SEQ.nextval as sid from dual";
int colmun2 = 0, count2 = 0; int colmun2 = 0, count2 = 0;
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);*/
char *loginId; char *loginId;
POM_get_user_id(&loginId); ITKCALL(POM_get_user_id(&loginId));
int ifail = ITK_ok; int ifail = ITK_ok;
tag_t matnrRev; tag_t matnrRev;
char *revUid; char *revUid;
ITKCALL(ifail = USERARG_get_string_argument(&revUid)); ITKCALL(USERARG_get_string_argument(&revUid));
ITK__convert_uid_to_tag(revUid, &matnrRev); ITK__convert_uid_to_tag(revUid, &matnrRev);
string errBuffer; string errBuffer;
@ -704,7 +767,7 @@ int AutoFeeding(void *returnValue) {
int url_num = 0; int url_num = 0;
char** url_vals = NULL; char** url_vals = NULL;
PREF_ask_char_values("database_tc", &url_num, &url_vals); ITKCALL(PREF_ask_char_values("database_tc", &url_num, &url_vals));
string url = url_vals[0]; string url = url_vals[0];
url.append("/").append(url_vals[2]); url.append("/").append(url_vals[2]);
string errorBuff; string errorBuff;
@ -801,6 +864,10 @@ int AutoFeeding(void *returnValue) {
ITKCALL(BOM_close_window(ebom_window)); ITKCALL(BOM_close_window(ebom_window));
auto end = std::chrono::high_resolution_clock::now();
// 计算时间间隔
std::chrono::duration<double> elapsed = end - start;
printf("用时:%f\n", elapsed.count());
//readProcessBom(bom_line, errorBuff); //readProcessBom(bom_line, errorBuff);
string buff = errBuffer; string buff = errBuffer;

@ -0,0 +1,291 @@
#include <epm/epm.h>
#include <string>
#include <map>
#include "epm_handler_common.h"
#include <tccore/aom.h>
#include <tccore/aom_prop.h>
#include "common_itk_util.h"
#include "tc_util.h"
#include <tc/preferences.h>
#include <fclasses\tc_date.h>
#include "CRUL_server_call_httpserver.h"
#include "ocilib.h"
#include "cJSON.h"
using namespace std;
string getTime()
{
stringstream ss;
time_t t = time(0);
tm* local = localtime(&t);
ss << local->tm_year + 1900 << '-';
if (local->tm_mon < 9)
ss << "0";
ss << local->tm_mon + 1 << '-';
if (local->tm_mday < 10)
ss << "0";
ss << local->tm_mday << ' ';
if (local->tm_hour < 10)
ss << "0";
ss << local->tm_hour << ':';
if (local->tm_min < 10)
ss << "0";
ss << local->tm_min << ':';
if (local->tm_sec<10)
ss << "0";
ss << local->tm_sec;
return ss.str();
}
//变更对象发送到OA
int CHINT_CHANGEBOM_TO_SRM(EPM_action_message_t msg) {
int ifail = ITK_ok;
ECHO("=========================================================\n");
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;
tag_t* taskAttches = NULLTAG;
tag_t cur_task = NULLTAG;
char* jobName = NULL, **url_vals = 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));
//获取url地址
int url_cnt = 0;
char** url = NULL, *urlId = NULL;//
ITKCALL(PREF_ask_char_values("CHINT_ChangeBOMURL", &url_cnt, &url));
vector<string> urls;
for (int i = 0; i < url_cnt; i++) {
vector<string> vec1, vec2;
Split(url[i], "=", vec1);
Split(vec1[0], ":", vec2);
if (tc_strcmp(vec2[0].c_str(), "1") == 0) {
urls.push_back(vec1[1]);
}
}
if (urls.size() == 0) {
printf("CHINT_ChangeURL首选项中未找到可用地址\n");
return ifail;
}
ITKCALL(PREF_ask_char_value("CHINT_OAUserID_RUL", 0, &urlId));
char* log_file = NULL;
CreateLogFile("CHINT_CHANGEBOM_TO_SRM", &log_file); //
//获取当前流程目标
//获取登陆组
tag_t group;
char *groupName, *taskUid;
ITKCALL(POM_ask_group(&groupName, &group));
ITKCALL(AOM_ask_value_string(group, PROP_GROUP_NAME, &groupName));
ITK__convert_tag_to_uid(msg.task, &taskUid); //流程uid
for (int count = 0; count < occur_of_counts; count++) {
char *type;
tag_t taskTag = taskAttches[count];
ITKCALL(AOM_ask_value_string(taskTag, "object_type", &type));
if (strcmp(type, "ZT2_Change") == 0) {
int ref_cnt = 0;
tag_t *refs = NULLTAG;
ITKCALL(AOM_ask_value_tags(taskTag, "IMAN_reference", &ref_cnt, &refs));
string ecnuid = "";
tag_t bomec = NULLTAG;
for (int i = 0; i < ref_cnt; i++) {
char *type = NULL;
ITKCALL(WSOM_ask_object_type2(refs[i], &type));
if (tc_strcmp(type, "ZT2_BOMEC") == 0) {
bomec = refs[i];
break;
}
}
if (bomec == NULLTAG) {
continue;
}
//如果当前流程目标下的变更单对应的影响分析如果仅包含技术工艺无其他部门则不需要触发此handler
char *item_id = NULL;
ITKCALL(AOM_ask_value_string(taskTag, "item_id", &item_id));
//获取属性 查询数据库填写JSON
int property1Cnt = 0, property2Cnt = 0, property3Cnt = 0, property4Cnt = 0, property5Cnt = 0,
property6Cnt = 0, property7Cnt = 0, property8Cnt = 0, property9Cnt = 0, property10Cnt = 0,
property11Cnt = 0, property12Cnt = 0, property13Cnt = 0, property14Cnt = 0, index = 0;
char* zt2_ContractName = NULL, *zt2_WBSNo = NULL,
**zt2_property1 = NULL, **zt2_property2 = NULL, **zt2_property3 = NULL, **zt2_property4 = NULL, **zt2_property5 = NULL,
**zt2_property6 = NULL, **zt2_property7 = NULL, **zt2_property8 = NULL, **zt2_property9 = NULL, **zt2_property10 = NULL,
**zt2_property11 = NULL, **zt2_property12 = NULL, **zt2_property13 = NULL, **zt2_property14 = NULL;
date_t changeDate;
ITKCALL(AOM_ask_value_string(taskTag, "zt2_WBSNo", &zt2_WBSNo));//wbs号
ITKCALL(AOM_ask_value_string(taskTag, "zt2_ContractName", &zt2_ContractName)); // 合同名称
ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property1", &property1Cnt, &zt2_property1));//
ITKCALL(AOM_ask_value_strings(bomec, "zt2_property2", &property2Cnt, &zt2_property2));//
ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property3", &property3Cnt, &zt2_property3));//
ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property4", &property4Cnt, &zt2_property4));//
ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property5", &property5Cnt, &zt2_property5));//
ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property6", &property6Cnt, &zt2_property6));//
ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property7", &property7Cnt, &zt2_property7));//
ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property8", &property8Cnt, &zt2_property8));//
ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property9", &property9Cnt, &zt2_property9));//
ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property10", &property10Cnt, &zt2_property10));//
ITKCALL(AOM_ask_value_strings(bomec, "zt2_property11", &property11Cnt, &zt2_property11));//
ITKCALL(AOM_ask_value_strings(bomec, "zt2_property12", &property12Cnt, &zt2_property12));//
ITKCALL(AOM_ask_value_strings(bomec, "zt2_property13", &property13Cnt, &zt2_property13));//
ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property13", &property14Cnt, &zt2_property14));//
if (property1Cnt > index) index = property1Cnt;
if (property2Cnt > index) index = property2Cnt;
if (property3Cnt > index) index = property3Cnt;
if (property4Cnt > index) index = property4Cnt;
if (property5Cnt > index) index = property5Cnt;
if (property6Cnt > index) index = property6Cnt;
if (property7Cnt > index) index = property7Cnt;
if (property8Cnt > index) index = property8Cnt;
if (property9Cnt > index) index = property9Cnt;
if (property10Cnt > index) index = property10Cnt;
if (property11Cnt > index) index = property11Cnt;
if (property12Cnt > index) index = property12Cnt;
if (property13Cnt > index) index = property13Cnt;
if (property14Cnt > index) index = property14Cnt;
//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 date = getTime();
//json添加字段
/*S_ProductFeature 产品特性 字符串 A; B; C
S_GCFeeature A; B; C*/
//cJSON_AddStringToObject(paramValue, S_GCDM, groupName);//工厂
cJSON* datas = cJSON_CreateArray();
for (int i = 0; i < index; i++) {
cJSON* data = cJSON_CreateObject();
if (i < property1Cnt) {
cJSON_AddStringToObject(data, "ZCITEM", zt2_property1[i]);
}
else {
cJSON_AddStringToObject(data, "ZCITEM", "");
}
cJSON_AddStringToObject(data, "ZCORDER", item_id);
cJSON_AddStringToObject(data, "POSID", zt2_WBSNo);
cJSON_AddStringToObject(data, "WERKS", groupName);
cJSON_AddStringToObject(data, "POST1", zt2_ContractName);
if (i < property2Cnt) {
cJSON_AddStringToObject(data, "ZCFLAG", zt2_property2[i]);
}
else {
cJSON_AddStringToObject(data, "ZCFLAG", "");
}
if (i < property3Cnt) {
cJSON_AddStringToObject(data, "MATNR", zt2_property3[i]);
}
else {
cJSON_AddStringToObject(data, "MATNR", "");
}
if (i < property4Cnt) {
cJSON_AddStringToObject(data, "MAKTX", zt2_property4[i]);
}
else {
cJSON_AddStringToObject(data, "MAKTX", "");
}
if (i < property5Cnt) {
cJSON_AddStringToObject(data, "ZOLD_IDNRK", zt2_property5[i]);
}
else {
cJSON_AddStringToObject(data, "ZOLD_IDNRK", "");
}
if (i < property6Cnt) {
cJSON_AddStringToObject(data, "ZOLD_MAKTX", zt2_property6[i]);
}
else {
cJSON_AddStringToObject(data, "ZOLD_MAKTX", "");
}
if (i < property7Cnt) {
cJSON_AddStringToObject(data, "ZOLD_UNIT", zt2_property7[i]);
}
else {
cJSON_AddStringToObject(data, "ZOLD_UNIT", "");
}
if (i < property8Cnt) {
cJSON_AddStringToObject(data, "ZNEW_IDNRK", zt2_property8[i]);
}
else {
cJSON_AddStringToObject(data, "ZNEW_IDNRK", "");
}
if (i < property9Cnt) {
cJSON_AddStringToObject(data, "ZNEW_MAKTX", zt2_property9[i]);
}
else {
cJSON_AddStringToObject(data, "ZNEW_MAKTX", "");
}
if (i < property10Cnt) {
cJSON_AddStringToObject(data, "ZNEW_UNIT", zt2_property10[i]);
}
else {
cJSON_AddStringToObject(data, "ZNEW_UNIT", "");
}
if (i < property11Cnt) {
cJSON_AddStringToObject(data, "ZZYYDL", zt2_property11[i]);
}
else {
cJSON_AddStringToObject(data, "ZZYYDL", "");
}
if (i < property12Cnt) {
cJSON_AddStringToObject(data, "ZZYYXL", zt2_property12[i]);
}
else {
cJSON_AddStringToObject(data, "ZZYYXL", "");
}
if (i < property13Cnt) {
cJSON_AddStringToObject(data, "ZPRO_TYPE", zt2_property13[i]);
}
else {
cJSON_AddStringToObject(data, "ZPRO_TYPE", "");
}
if (i < property14Cnt) {
cJSON_AddStringToObject(data, "ZPRO_DES", zt2_property14[i]);
}
else {
cJSON_AddStringToObject(data, "ZPRO_DES", "");
}
cJSON_AddStringToObject(data, "ZNAME", userId);
cJSON_AddStringToObject(data, "ZDATE", date.c_str());
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);
WriteLog("\nworkflowCode=EH_TE_ChangeNotice\nuserCode=%s\nfinishStart=true\n", userCode.c_str());
WriteLog("组织之后的JSON\n %s\n", json_to_char);
string returnMsg = "";// ecnSendOA(userCode.c_str(), json_to_char, url);
for (int i = 0; i < urls.size(); i++) {
returnMsg.append(ecnSendOA(userCode.c_str(), json_to_char, urls[i]));
}
WriteLog("回传信息\n %s\n", returnMsg.c_str());
if (!returnMsg.empty()) {
ITKCALL(EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, returnMsg.c_str()));
}
}
}
CloseLog();
//string str = uploadMinio("uploadMinio.jar", log_file);
char date_string[MAX_PATH_LENGTHE], logFileName[MAX_PATH_LENGTHE];;
time_t now;
struct tm *p;
time(&now);
//current_time(&status_now);
p = localtime(&now);
memset(date_string, 0, sizeof(date_string));
sprintf(date_string, "%4d%02d%02d%02d%02d%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
sprintf(logFileName, "%s\\%s_%s.log", LOG_PATH, taskUid, date_string);
//file_xcopy_stod(log_file, logFileName);
//printf("str %s \n", str.c_str());
return ifail;
}

@ -213,23 +213,18 @@ int CHINT_ECN_SendOA(EPM_action_message_t msg) {
return ifail; return ifail;
} }
//获取url地址 //获取url地址
char* url, *userId, *urlId;// char* url = NULL, *urlId = NULL;//
ITKCALL(PREF_ask_char_value("CHINT_ECNSendOAUrl", 0, &url)); ITKCALL(PREF_ask_char_value("CHINT_ECNSendOAUrl", 0, &url));
ITKCALL(PREF_ask_char_value("CHINT_OAUserID_RUL", 0, &urlId)); ITKCALL(PREF_ask_char_value("CHINT_OAUserID_RUL", 0, &urlId));
char* log_file = NULL; char* log_file = NULL;
CreateLogFile("CHINT_ECN_SendOA", &log_file); // CreateLogFile("CHINT_ECN_SendOA", &log_file); //
//获取当前流程目标 //获取当前流程目标
connectSql(); connectSql();
ITKCALL(POM_get_user_id(&userId));
string email = userId;
email.append("@chint.com");
string userXML = getUserIdOA(email, urlId);
//获取登陆组 //获取登陆组
tag_t group; tag_t group;
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));
string userCode = readXmlId(userXML);
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;
@ -306,7 +301,15 @@ int CHINT_ECN_SendOA(EPM_action_message_t msg) {
cJSON_AddStringToObject(paramValue, "S_ContractName", contractName); cJSON_AddStringToObject(paramValue, "S_ContractName", contractName);
ITKCALL(DATE_date_to_string(changeDate, "%Y-%m-%d", &changeDateStr)); ITKCALL(DATE_date_to_string(changeDate, "%Y-%m-%d", &changeDateStr));
cJSON_AddStringToObject(paramValue, "T_MaterialDate", changeDateStr); cJSON_AddStringToObject(paramValue, "T_MaterialDate", changeDateStr);
cJSON_AddStringToObject(paramValue, "S_FFBM", changeUnits[0]); vector<string> split;
Split(changeUnits[0], " ", split);
string ffbm = "";
for (int i = 0; i < split.size(); i++) {
if (i > 0)
ffbm.append(";");
ffbm.append(split[i]);
}
cJSON_AddStringToObject(paramValue, "S_FFBM", ffbm.c_str());//changeUnits[0]
//EH_DrawingInformation图样信息 //EH_DrawingInformation图样信息
cJSON* infomations = getDrawingInform(taskTag); cJSON* infomations = getDrawingInform(taskTag);
cJSON_AddItemToObject(paramValue, "EH_DrawingInformation", infomations); cJSON_AddItemToObject(paramValue, "EH_DrawingInformation", infomations);
@ -334,9 +337,20 @@ int CHINT_ECN_SendOA(EPM_action_message_t msg) {
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);
string returnMsg = ecnSendOA(userCode.c_str(), json_to_char, url); WriteLog("\nworkflowCode=EH_TE_ChangeNotice\nuserCode=%s\nfinishStart=true\n", userCode.c_str());
WriteLog("组织之后的JSON\n %s\n", json_to_char); WriteLog("组织之后的JSON\n %s\n", json_to_char);
string returnMsg = ecnSendOA(userCode.c_str(), json_to_char, url);
WriteLog("回传信息\n %s\n", returnMsg.c_str()); WriteLog("回传信息\n %s\n", returnMsg.c_str());
if (!returnMsg.empty()) { if (!returnMsg.empty()) {
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()));
@ -361,3 +375,212 @@ int CHINT_ECN_SendOA(EPM_action_message_t msg) {
//printf("str %s \n", str.c_str()); //printf("str %s \n", str.c_str());
return ifail; return ifail;
} }
//PLM推送变更通知单数据流信息
int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg) {
int ifail = ITK_ok;
ECHO("=========================================================\n");
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;
tag_t* taskAttches = NULLTAG;
tag_t cur_task = NULLTAG;
char* jobName = NULL, **url_vals = 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));
//获取url地址
int url_cnt = 0;
char** url = NULL, *urlId = NULL;//
ITKCALL(PREF_ask_char_values("CHINT_ChangeURL", &url_cnt, &url));
vector<string> urls;
for (int i = 0; i < url_cnt; i++) {
vector<string> vec1, vec2;
Split(url[i], "=", vec1);
Split(vec1[0], ":", vec2);
if (tc_strcmp(vec2[0].c_str(), "1") == 0) {
urls.push_back(vec1[1]);
}
}
if (urls.size() == 0) {
printf("CHINT_ChangeURL首选项中未找到可用地址\n");
return ifail;
}
ITKCALL(PREF_ask_char_value("CHINT_OAUserID_RUL", 0, &urlId));
char* log_file = NULL;
CreateLogFile("CHINT_CHANGEITEM_TO_SRM", &log_file); //
//获取当前流程目标
//获取登陆组
tag_t group;
char *groupName, *taskUid;
ITKCALL(POM_ask_group(&groupName, &group));
ITKCALL(AOM_ask_value_string(group, PROP_GROUP_NAME, &groupName));
ITK__convert_tag_to_uid(msg.task, &taskUid); //流程uid
for (int count = 0; count < occur_of_counts; count++) {
char *type;
tag_t taskTag = taskAttches[count];
ITKCALL(AOM_ask_value_string(taskTag, "object_type", &type));
if (strcmp(type, "ZT2_Change") == 0) {
//如果当前流程目标下的变更单对应的影响分析如果仅包含技术工艺无其他部门则不需要触发此handler
char *itemId = NULL;
ITKCALL(AOM_ask_value_string(taskTag, "item_id", &itemId));
printf("id ===>%s\n", itemId);
//获取属性 查询数据库填写JSON
int unitCnt, processCnt = 0;
char* changeType, *productModel,
*productName, *fileName, *contractNo, *contractName,
*changeDateStr, **changeUnits, *changeRequestNo, **processTypes,
*wbsno = NULL, *owninguser = NULL, *releasedate = NULL;
date_t changeDate;
ITKCALL(AOM_ask_value_string(taskTag, "zt2_WBSNo", &wbsno));//wbs号
ITKCALL(AOM_UIF_ask_value(taskTag, "owning_user", &owninguser));//变更发起人
ITKCALL(AOM_UIF_ask_value(taskTag, "date_released", &releasedate));//发布时间
ITKCALL(AOM_ask_value_string(taskTag, "zt2_ChangeType", &changeType));//变更类型
ITKCALL(AOM_ask_value_string(taskTag, "zt2_ProductModel", &productModel));//产品型号
ITKCALL(AOM_ask_value_string(taskTag, "zt2_ProductName", &productName)); // 产品名称
ITKCALL(AOM_ask_value_string(taskTag, "zt2_FileName", &fileName)); // 文件代号及名称
ITKCALL(AOM_ask_value_string(taskTag, "zt2_ContractNo", &contractNo)); // 合同代号
ITKCALL(AOM_ask_value_string(taskTag, "zt2_ContractName", &contractName)); // 合同名称
ITKCALL(AOM_ask_value_date(taskTag, "zt2_ChangeDate", &changeDate)); // 变更实施日期
ITKCALL(AOM_ask_value_strings(taskTag, "zt2_ChangeUnit1", &unitCnt, &changeUnits)); // 合同名称
ITKCALL(AOM_ask_value_string(taskTag, "zt2_ChangRequestNo", &changeRequestNo)); // 更改通知单号
ITKCALL(AOM_ask_value_strings(taskTag, PROP_PROCESS, &processCnt, &processTypes));
cJSON* paramValue = cJSON_CreateObject();
//json添加字段
/*S_ProductFeature 产品特性 字符串 A; B; C
S_GCFeeature A; B; C*/
//cJSON_AddStringToObject(paramValue, S_GCDM, groupName);//工厂
cJSON_AddStringToObject(paramValue, "wbsno", wbsno);
cJSON_AddStringToObject(paramValue, "owninguser", owninguser);
cJSON_AddStringToObject(paramValue, "factory", groupName);
int ref_cnt = 0;
tag_t *refs = NULLTAG;
ITKCALL(AOM_ask_value_tags(taskTag, "IMAN_reference", &ref_cnt, &refs));
string ecnuid = "";
bool ifbomchange = false;
for (int i = 0; i < ref_cnt; i++) {
char *type = NULL;
ITKCALL(WSOM_ask_object_type2(refs[i], &type));
if (tc_strcmp(type, "ZT2_BOMEC") == 0) {
ifbomchange = true;
}
else if (tc_strcmp(type, "MSExcelX") == 0) {
char* uid = NULL;
ITK__convert_tag_to_uid(refs[i], &uid);
ecnuid = uid;
}
}
cJSON_AddStringToObject(paramValue, "ifbomchange", ifbomchange ? "Y" : "N");
cJSON_AddStringToObject(paramValue, "iffilechange", ecnuid.size() > 0 ? "Y" : "N");
cJSON_AddStringToObject(paramValue, "ecnuid", ecnuid.c_str());
cJSON_AddStringToObject(paramValue, "releasedate", releasedate);
string productFeature, changeTypeStr;
if (processCnt > 0) {
char *type = processTypes[0];
if (strcmp(type, "Y") == 0) {
productFeature = S_Product;
}
else {
productFeature = S_Process;
}
}
if (strstr(changeType, S_ZSChange) != NULL) {
changeTypeStr = S_ZSChange;
}
else {
changeTypeStr = S_LSChange;
}
cJSON_AddStringToObject(paramValue, "S_ChangeTypes", changeTypeStr.c_str());
cJSON_AddStringToObject(paramValue, "S_ProductFeature", productFeature.c_str());
cJSON_AddStringToObject(paramValue, "S_ProductNumber", productModel);
cJSON_AddStringToObject(paramValue, "S_ProductName", productName);
cJSON_AddStringToObject(paramValue, "S_Pcodename", fileName);
cJSON_AddStringToObject(paramValue, "S_Contractcode", contractNo);
cJSON_AddStringToObject(paramValue, "S_ContractName", contractName);
ITKCALL(DATE_date_to_string(changeDate, "%Y-%m-%d", &changeDateStr));
cJSON_AddStringToObject(paramValue, "T_MaterialDate", changeDateStr);
vector<string> split;
Split(changeUnits[0], " ", split);
string ffbm = "";
for (int i = 0; i < split.size(); i++) {
if (i > 0)
ffbm.append(";");
ffbm.append(split[i]);
}
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_PLMCode", taskUid);
cJSON_AddStringToObject(paramValue, "S_ChangeNotificationCode", changeRequestNo);
//EH_DrawingInformation图样信息
cJSON* infomations = getDrawingInform(taskTag);
cJSON_AddItemToObject(paramValue, "EH_DrawingInformation", infomations);
string jsbUUid = "", gybUUid = "", zlbUUid = "",
scbUUid = "", cgbUUid = "", xszxUUid = "", cwbUUid = "";
cJSON* jsbZx = getEHDepart(itemId, "技术部", jsbUUid);
cJSON_AddItemToObject(paramValue, "EH_JSBZX", jsbZx);
cJSON* gybZx = getEHDepart(itemId, "工艺部", gybUUid);
cJSON_AddItemToObject(paramValue, "EH_GYBZX", gybZx);
cJSON* zlbZx = getEHDepart(itemId, "质量部", zlbUUid);
cJSON_AddItemToObject(paramValue, "EH_ZLBZX", zlbZx);
cJSON* scbZx = getEHDepart(itemId, "生产部", scbUUid);
cJSON_AddItemToObject(paramValue, "EH_SCBZX", scbZx);
cJSON* cgbZx = getEHDepart(itemId, "采购部", cgbUUid);
cJSON_AddItemToObject(paramValue, "EH_CGBZX", cgbZx);
cJSON* saleCenter = getEHDepart(itemId, "销售中心", xszxUUid);
cJSON_AddItemToObject(paramValue, "EH_XSZXZX", saleCenter);
cJSON* cwbZx = getEHDepart(itemId, "财务部", cwbUUid);
cJSON_AddItemToObject(paramValue, "EH_CWBZX", cwbZx);
cJSON_AddStringToObject(paramValue, "S_JSBZRR", jsbUUid.c_str());
cJSON_AddStringToObject(paramValue, "S_GYBZRR", gybUUid.c_str());
cJSON_AddStringToObject(paramValue, "S_ZLBZRR", zlbUUid.c_str());
cJSON_AddStringToObject(paramValue, "S_SCBZRR", scbUUid.c_str());
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);
WriteLog("\nworkflowCode=EH_TE_ChangeNotice\nuserCode=%s\nfinishStart=true\n", userCode.c_str());
WriteLog("组织之后的JSON\n %s\n", json_to_char);
string returnMsg = "";// ecnSendOA(userCode.c_str(), json_to_char, url);
for (int i = 0; i < urls.size(); i++) {
returnMsg.append(ecnSendOA(userCode.c_str(), json_to_char, urls[i])).append("\n");
}
WriteLog("回传信息\n %s\n", returnMsg.c_str());
if (!returnMsg.empty()) {
ITKCALL(EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, returnMsg.c_str()));
}
}
}
CloseLog();
//string str = uploadMinio("uploadMinio.jar", log_file);
char date_string[MAX_PATH_LENGTHE], logFileName[MAX_PATH_LENGTHE];;
time_t now;
struct tm *p;
time(&now);
//current_time(&status_now);
p = localtime(&now);
memset(date_string, 0, sizeof(date_string));
sprintf(date_string, "%4d%02d%02d%02d%02d%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
sprintf(logFileName, "%s\\%s_%s.log", LOG_PATH, taskUid, date_string);
file_xcopy_stod(log_file, logFileName);
//printf("str %s \n", str.c_str());
return ifail;
}

@ -45,6 +45,8 @@
#include <tccore/aom.h> #include <tccore/aom.h>
#include <tccore/item.h> #include <tccore/item.h>
#include <tccore/workspaceobject.h> #include <tccore/workspaceobject.h>
#include <iostream>
#include <chrono>
using namespace std; using namespace std;
typedef struct { typedef struct {
@ -68,7 +70,7 @@ typedef struct {
}TemGxBean; }TemGxBean;
struct FlBean struct FlBean
{ {
tag_t flTag=NULLTAG; tag_t flTag = NULLTAG;
string blQty; string blQty;
}; };
string getCshVal(string name, string code); string getCshVal(string name, string code);
@ -92,8 +94,8 @@ void save_representation2(tag_t primaryTag, tag_t secondTag, char* relationType)
ITKCALL(GRM_create_relation(primaryTag, secondTag, typeTag, NULLTAG, &relationTag));//如果关系已经存在,那么就是增加对象 ITKCALL(GRM_create_relation(primaryTag, secondTag, typeTag, NULLTAG, &relationTag));//如果关系已经存在,那么就是增加对象
ITKCALL(GRM_save_relation(relationTag));//很必要 ITKCALL(GRM_save_relation(relationTag));//很必要
ITKCALL(AOM_save(primaryTag)); (AOM_save(primaryTag));
ITKCALL(AOM_save(secondTag)); (AOM_save(secondTag));
ITKCALL(AOM_refresh(primaryTag, FALSE)); ITKCALL(AOM_refresh(primaryTag, FALSE));
ITKCALL(AOM_refresh(secondTag, FALSE)); ITKCALL(AOM_refresh(secondTag, FALSE));
} }
@ -108,7 +110,7 @@ void updateTemGxCode(tag_t processTag, map<string, TemGxBean> temGxMap) {
printf("bvr_count=%d", bvr_count); printf("bvr_count=%d", bvr_count);
ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取
//bom_line工艺 //bom_line工艺
int c_line_count; int c_line_count;
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)); // 一级工序
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
@ -120,21 +122,21 @@ void updateTemGxCode(tag_t processTag, map<string, TemGxBean> temGxMap) {
if (temGxMap.count(gxbm1) > 0) { if (temGxMap.count(gxbm1) > 0) {
char* oldName; char* oldName;
TemGxBean temGxBean = temGxMap[gxbm1]; TemGxBean temGxBean = temGxMap[gxbm1];
ITKCALL(AOM_lock(oneGxLine)); (AOM_lock(oneGxLine));
ITKCALL(AOM_set_value_string(oneGxLine, "bl_ZT2_FirstOPRevision_zt2_ClassificationCode", temGxBean.temGxCode.c_str())); ITKCALL(AOM_set_value_string(oneGxLine, "bl_ZT2_FirstOPRevision_zt2_ClassificationCode", temGxBean.temGxCode.c_str()));
ITKCALL(AOM_save(oneGxLine)); (AOM_save(oneGxLine));
AOM_unlock(oneGxLine); AOM_unlock(oneGxLine);
ITKCALL(AOM_ask_value_tag(oneGxLine, "bl_line_object", &oneGx)); ITKCALL(AOM_ask_value_tag(oneGxLine, "bl_line_object", &oneGx));
ITKCALL(ITEM_ask_item_of_rev(oneGx, &gxItem)); ITKCALL(ITEM_ask_item_of_rev(oneGx, &gxItem));
ITKCALL(AOM_lock(gxItem)); (AOM_lock(gxItem));
ITKCALL(AOM_ask_value_string(gxItem, "object_name", &oldName)); ITKCALL(AOM_ask_value_string(gxItem, "object_name", &oldName));
ITKCALL(AOM_set_value_string(gxItem, "object_name", temGxBean.temGxName.c_str())); ITKCALL(AOM_set_value_string(gxItem, "object_name", temGxBean.temGxName.c_str()));
ITKCALL(AOM_save(gxItem)); (AOM_save(gxItem));
ITKCALL(AOM_unlock(gxItem)); (AOM_unlock(gxItem));
ITKCALL(AOM_lock(oneGx)); (AOM_lock(oneGx));
ITKCALL(AOM_set_value_string(oneGx, "object_name", temGxBean.temGxName.c_str())); ITKCALL(AOM_set_value_string(oneGx, "object_name", temGxBean.temGxName.c_str()));
ITKCALL(AOM_save(oneGx)); (AOM_save(oneGx));
ITKCALL(AOM_unlock(oneGx)); (AOM_unlock(oneGx));
printf("oldName===>%s\n", oldName); printf("oldName===>%s\n", oldName);
printf("temGxName===>%s\n", temGxBean.temGxName.c_str()); printf("temGxName===>%s\n", temGxBean.temGxName.c_str());
printf("temGxCode===>%s\n", temGxBean.temGxCode.c_str()); printf("temGxCode===>%s\n", temGxBean.temGxCode.c_str());
@ -158,20 +160,20 @@ void updateTemGxCode(tag_t processTag, map<string, TemGxBean> temGxMap) {
char* oldName, *oldName2; char* oldName, *oldName2;
ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &towGx)); ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &towGx));
ITKCALL(ITEM_ask_item_of_rev(towGx, &gxItem2)); ITKCALL(ITEM_ask_item_of_rev(towGx, &gxItem2));
ITKCALL(AOM_lock(gxItem2)); (AOM_lock(gxItem2));
ITKCALL(AOM_ask_value_string(gxItem2, "object_name", &oldName)); ITKCALL(AOM_ask_value_string(gxItem2, "object_name", &oldName));
ITKCALL(AOM_set_value_string(gxItem2, "object_name", temGxBean.temGxName.c_str())); ITKCALL(AOM_set_value_string(gxItem2, "object_name", temGxBean.temGxName.c_str()));
ITKCALL(AOM_save(gxItem2)); (AOM_save(gxItem2));
ITKCALL(AOM_unlock(gxItem2)); (AOM_unlock(gxItem2));
ITKCALL(AOM_ask_value_string(gxItem2, "object_name", &oldName2)); ITKCALL(AOM_ask_value_string(gxItem2, "object_name", &oldName2));
printf("oldName===>%s\n", oldName); printf("oldName===>%s\n", oldName);
printf("oldName2===>%s\n", oldName2); printf("oldName2===>%s\n", oldName2);
printf("temGxName===>%s\n", temGxBean.temGxName.c_str()); printf("temGxName===>%s\n", temGxBean.temGxName.c_str());
printf("temGxCode===>%s\n", temGxBean.temGxCode.c_str()); printf("temGxCode===>%s\n", temGxBean.temGxCode.c_str());
ITKCALL(AOM_lock(towGx)); (AOM_lock(towGx));
ITKCALL(AOM_set_value_string(towGx, "object_name", temGxBean.temGxName.c_str())); ITKCALL(AOM_set_value_string(towGx, "object_name", temGxBean.temGxName.c_str()));
ITKCALL(AOM_save(towGx)); (AOM_save(towGx));
ITKCALL(AOM_unlock(towGx)); (AOM_unlock(towGx));
} }
@ -179,13 +181,17 @@ void updateTemGxCode(tag_t processTag, map<string, TemGxBean> temGxMap) {
} }
BOM_close_window(ebom_window); BOM_close_window(ebom_window);
} }
string getCshVal(string name,string code) { map<string, string> cshMap;
string getCshVal(string name, string code) {
string strResult; string strResult = "", schVal = "";
string schVal = ""; schVal.append(name).append("@").append(code);
if (cshMap.count(schVal) > 0) {
return cshMap[schVal];
}
//cmd指令 //cmd指令
char cmd[256] = ""; char cmd[256] = "";
strcpy(cmd, "java -jar "); strcpy(cmd, "java -jar \"");
//strcat(cmd, jar_file); //strcat(cmd, jar_file);
strcat(cmd, getenv("TC_ROOT")); strcat(cmd, getenv("TC_ROOT"));
strcat(cmd, "\\bin\\findCshSql.jar"); strcat(cmd, "\\bin\\findCshSql.jar");
@ -193,6 +199,7 @@ string getCshVal(string name,string code) {
strcat(cmd, name.c_str()); strcat(cmd, name.c_str());
strcat(cmd, "\" \""); strcat(cmd, "\" \"");
strcat(cmd, code.c_str()); strcat(cmd, code.c_str());
strcat(cmd, "\"");
printf("路径:\n%s\n", cmd); printf("路径:\n%s\n", cmd);
char buf[8000] = { 0 }; char buf[8000] = { 0 };
FILE* pf = NULL; FILE* pf = NULL;
@ -203,17 +210,19 @@ string getCshVal(string name,string code) {
while (fgets(buf, sizeof buf, pf)) { while (fgets(buf, sizeof buf, pf)) {
strResult += buf; strResult += buf;
} }
printf("接口返回:\n%s", strResult.c_str());
_pclose(pf); _pclose(pf);
vector<string> vec; /*vector<string> vec;
Split(strResult,"CSHVAL:[",vec); Split(strResult, "CSHVAL:[", vec);
if (vec.size() > 0) { if (vec.size() > 0) {
Split(vec[1], "]", vec); Split(vec[1], "]", vec);
schVal = vec[0]; schVal = vec[0];
} }*/
cshMap[schVal] = strResult;
return schVal; return strResult;
} }
string getJdbVal(string name,string yqz,string checkcode,string draw,string modelVersion,string code,string checkCode) { string getJdbVal(string name, string yqz, string checkcode, string draw, string modelVersion, string code, string checkCode) {
string drawingno = draw.append("-").append(name); string drawingno = draw.append("-").append(name);
string getCode = "select checkno,NUMBEROFCHECKS from CHINT_CHECK_TITLE WHERE drawingno = '%s' and modelversion='%s' order by NUMBEROFCHECKS desc "; string getCode = "select checkno,NUMBEROFCHECKS from CHINT_CHECK_TITLE WHERE drawingno = '%s' and modelversion='%s' order by NUMBEROFCHECKS desc ";
string getNo = "select NO from CHINT_CHECK_DETAILS_TEMPLATE where code ='%s' and modelversion = '%s' and checkCode = '%s' "; string getNo = "select NO from CHINT_CHECK_DETAILS_TEMPLATE where code ='%s' and modelversion = '%s' and checkCode = '%s' ";
@ -257,11 +266,12 @@ typedef struct {
string mentDesc; string mentDesc;
string mentResult; string mentResult;
}JYXBean; }JYXBean;
void setZljyx(string gxbm2, string th,string lastId,string name,tag_t towGx) { void setZljyx(string gxbm2, string th, string lastId, string name, tag_t towGx) {
auto start = std::chrono::high_resolution_clock::now();
string code; string code;
printf("th == >%s \n", th.c_str()); printf("th == >%s \n", th.c_str());
if (strstr(th.c_str(),"-") != NULL) { if (strstr(th.c_str(), "-") != NULL) {
vector<string> vec; vector<string> vec;
Split(th, "-", vec); Split(th, "-", vec);
code.append(vec[0]).append("-").append("X"); code.append(vec[0]).append("-").append("X");
@ -281,6 +291,7 @@ void setZljyx(string gxbm2, string th,string lastId,string name,tag_t towGx) {
QuerySQLNoInputParam(selectRxfs, &outputColumn1, &outputValueCount1, &outputValue1); QuerySQLNoInputParam(selectRxfs, &outputColumn1, &outputValueCount1, &outputValue1);
printf("search result ===> %d\n", outputValueCount1); printf("search result ===> %d\n", outputValueCount1);
vector< JYXBean> beans; vector< JYXBean> beans;
cshMap.clear();
for (int num = 0; num < outputValueCount1; num++) { for (int num = 0; num < outputValueCount1; num++) {
//TarGXCODE\", \"TarGXNAME\", \"TemGXCODE\", \"TemGXNAME //TarGXCODE\", \"TarGXNAME\", \"TemGXCODE\", \"TemGXNAME
@ -299,12 +310,13 @@ void setZljyx(string gxbm2, string th,string lastId,string name,tag_t towGx) {
bean.mentDesc = cqmanagementdesc; bean.mentDesc = cqmanagementdesc;
bean.mentNo = cqmanagementno; bean.mentNo = cqmanagementno;
bean.no = cqmodelnno; bean.no = cqmodelnno;
bean.mentResult = "";
if (cqmanagementresult.empty()) { if (cqmanagementresult.empty()) {
if (datasource.compare("校对表") == 0) { if (datasource.compare("校对表") == 0) {
// string getCode = "select code,NUMBEROFCHECKS from CHINT_CHECK_TITLE WHERE drawingno = '?' order by NUMBEROFCHECKS desc "; // string getCode = "select code,NUMBEROFCHECKS from CHINT_CHECK_TITLE WHERE drawingno = '?' order by NUMBEROFCHECKS desc ";
if (checkline.compare("要求值") == 0 && !checkcode.empty()) { if (checkline.compare("要求值") == 0 && !checkcode.empty()) {
bean.mentResult = getJdbVal(lastId,"designresult", checkcode, drawingno, modelversion,code, checkcode); //designresult,PROOFREADRESULT bean.mentResult = getJdbVal(lastId, "designresult", checkcode, drawingno, modelversion, code, checkcode); //designresult,PROOFREADRESULT
} }
else if (checkline.compare("设计值") == 0 && !checkcode.empty()) { else if (checkline.compare("设计值") == 0 && !checkcode.empty()) {
bean.mentResult = getJdbVal(lastId, "PROOFREADRESULT", checkcode, drawingno, modelversion, code, checkcode); bean.mentResult = getJdbVal(lastId, "PROOFREADRESULT", checkcode, drawingno, modelversion, code, checkcode);
@ -328,32 +340,35 @@ void setZljyx(string gxbm2, string th,string lastId,string name,tag_t towGx) {
if (beans.size()>0) { if (beans.size()>0) {
tag_t *tableRow; tag_t *tableRow;
ITKCALL(ITEM_create_item(NULL, objName.c_str(), "ZT2_QCHECK", NULL, &item, &rev)); ITKCALL(ITEM_create_item(NULL, objName.c_str(), "ZT2_QCHECK", NULL, &item, &rev));
ITKCALL(AOM_save(item)); (AOM_save(item));
ITKCALL(AOM_save(rev)); (AOM_save(rev));
ITKCALL(AOM_lock(item)); (AOM_lock(item));
ITKCALL(AOM_lock(rev)); (AOM_lock(rev));
ITKCALL(AOM_insert_table_rows(rev, "zt2_QCHECKS", 0, beans.size(), &tableRow)); ITKCALL(AOM_insert_table_rows(rev, "zt2_QCHECKS", 0, beans.size(), &tableRow));
ITKCALL(AOM_save(rev)); (AOM_save(rev));
ITKCALL(AOM_unlock(rev)); (AOM_unlock(rev));
ITKCALL(AOM_save(item)); (AOM_save(item));
ITKCALL(AOM_unlock(item)); (AOM_unlock(item));
for (int i = 0; i < beans.size(); i++) { for (int i = 0; i < beans.size(); i++) {
tag_t table = tableRow[i]; tag_t table = tableRow[i];
ITKCALL(AOM_lock(table)); (AOM_lock(table));
ITKCALL(AOM_set_value_string(table,"zt2_code", beans[i].no.c_str())); ITKCALL(AOM_set_value_string(table, "zt2_code", beans[i].no.c_str()));
ITKCALL(AOM_set_value_string(table, "zt2_jjxbh", beans[i].mentNo.c_str())); ITKCALL(AOM_set_value_string(table, "zt2_jjxbh", beans[i].mentNo.c_str()));
ITKCALL(AOM_set_value_string(table, "zt2_jyxmc", beans[i].mentDesc.c_str())); ITKCALL(AOM_set_value_string(table, "zt2_jyxmc", beans[i].mentDesc.c_str()));
ITKCALL(AOM_set_value_string(table, "zt2_jyxsjjg", beans[i].mentResult.c_str())); ITKCALL(AOM_set_value_string(table, "zt2_jyxsjjg", beans[i].mentResult.c_str()));
ITKCALL(AOM_save(table)); (AOM_save(table));
ITKCALL(AOM_unlock(table)); (AOM_unlock(table));
} }
ITKCALL(AOM_save(towGx)); (AOM_save(towGx));
save_representation2(towGx, item, "ZT2_QualityCheckRelation"); save_representation2(towGx, item, "ZT2_QualityCheckRelation");
} }
auto setZljyx = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = setZljyx - start;
printf("setZljyx%f\n", elapsed.count());
} }
void getGxbmMap(tag_t processTag, map<string, tag_t>& gxDocMap, map<string, TimeBean > timebeans, void getGxbmMap(tag_t processTag, map<string, tag_t>& gxDocMap, map<string, TimeBean > timebeans,
map<string, vector<FlBean>> flBeanMap,string th,string lastId) { map<string, vector<FlBean>> flBeanMap, string th, string lastId) {
int bvr_count = 0; int bvr_count = 0;
tag_t ebom_window = NULLTAG; tag_t ebom_window = NULLTAG;
tag_t bom_line = NULLTAG; tag_t bom_line = NULLTAG;
@ -364,24 +379,24 @@ void getGxbmMap(tag_t processTag, map<string, tag_t>& gxDocMap, map<string, Time
printf("bvr_count=%d", bvr_count); printf("bvr_count=%d", bvr_count);
ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取
//bom_line工艺 //bom_line工艺
int c_line_count; int c_line_count;
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)); // 一级工序
//修改工时 //修改工时
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
tag_t oneGx = c_line_tags[i], *towGxLines; tag_t oneGx = c_line_tags[i], *towGxLines;
char* gxbm1; char* gxbm1;
ITKCALL(AOM_ask_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ClassificationCode", &gxbm1)); ITKCALL(AOM_ask_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ClassificationCode", &gxbm1));
if (timebeans.count(gxbm1) > 0) { if (timebeans.count(gxbm1) > 0) {
ITKCALL(AOM_lock(oneGx)); (AOM_lock(oneGx));
TimeBean tbean = timebeans[gxbm1]; TimeBean tbean = timebeans[gxbm1];
ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ArtificialTime", tbean.rgsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ArtificialTime", tbean.rgsj.c_str()));
ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_MachineTime", tbean.jqsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_MachineTime", tbean.jqsj.c_str()));
ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ReadinessTime", tbean.zbsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ReadinessTime", tbean.zbsj.c_str()));
ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ProCycle", tbean.zrsczq.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ProCycle", tbean.zrsczq.c_str()));
ITKCALL(AOM_save(oneGx)); (AOM_save(oneGx));
ITKCALL(AOM_unlock(oneGx)); (AOM_unlock(oneGx));
} }
int c_cnt = 0; int c_cnt = 0;
ITKCALL(BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines)); ITKCALL(BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines));
@ -391,20 +406,20 @@ void getGxbmMap(tag_t processTag, map<string, tag_t>& gxDocMap, map<string, Time
char* gxbm2; char* gxbm2;
ITKCALL(AOM_ask_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ClassificationCode", &gxbm2)); ITKCALL(AOM_ask_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ClassificationCode", &gxbm2));
if (timebeans.count(gxbm2) > 0) { if (timebeans.count(gxbm2) > 0) {
ITKCALL(AOM_lock(towGxLine)); (AOM_lock(towGxLine));
TimeBean tbean = timebeans[gxbm2]; TimeBean tbean = timebeans[gxbm2];
ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ArtificialTime", tbean.rgsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ArtificialTime", tbean.rgsj.c_str()));
ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_MachineTime", tbean.jqsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_MachineTime", tbean.jqsj.c_str()));
ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ReadinessTime", tbean.zbsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ReadinessTime", tbean.zbsj.c_str()));
ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ProCycle", tbean.zrsczq.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ProCycle", tbean.zrsczq.c_str()));
ITKCALL(AOM_save(towGxLine)); (AOM_save(towGxLine));
ITKCALL(AOM_unlock(towGxLine)); (AOM_unlock(towGxLine));
} }
char* name = NULL; char* name = NULL;
ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &towGx)); ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &towGx));
ITKCALL(AOM_ask_value_string(towGx, "object_name", &name)); ITKCALL(AOM_ask_value_string(towGx, "object_name", &name));
//设置质检项 //设置质检项
setZljyx(gxbm2,th, lastId, name, towGx); setZljyx(gxbm2, th, lastId, name, towGx);
if (flBeanMap.count(gxbm2) > 0) { if (flBeanMap.count(gxbm2) > 0) {
vector<FlBean> beansVec = flBeanMap[gxbm2]; vector<FlBean> beansVec = flBeanMap[gxbm2];
printf("beansVec===>%zd\n", beansVec.size()); printf("beansVec===>%zd\n", beansVec.size());
@ -417,10 +432,10 @@ void getGxbmMap(tag_t processTag, map<string, tag_t>& gxDocMap, map<string, Time
tag_t newView, newViewBvr, pitem; tag_t newView, newViewBvr, pitem;
ITKCALL(ITEM_ask_item_of_rev(axqPmatnr, &pitem)); ITKCALL(ITEM_ask_item_of_rev(axqPmatnr, &pitem));
ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView));
ITKCALL(AOM_save(newView)); (AOM_save(newView));
ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, axqPmatnr, &newViewBvr)); ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, axqPmatnr, &newViewBvr));
ITKCALL(AOM_save(newViewBvr)); (AOM_save(newViewBvr));
ITKCALL(AOM_save(axqPmatnr)); (AOM_save(axqPmatnr));
} }
} }
//投辅料 //投辅料
@ -431,15 +446,15 @@ void getGxbmMap(tag_t processTag, map<string, tag_t>& gxDocMap, map<string, Time
continue; continue;
} }
ITKCALL(BOM_line_add(towGxLine, NULL, cBean.flTag, NULL, &cLine)); ITKCALL(BOM_line_add(towGxLine, NULL, cBean.flTag, NULL, &cLine));
ITKCALL(AOM_lock(cLine)); (AOM_lock(cLine));
string num = cBean.blQty; string num = cBean.blQty;
ITKCALL(AOM_set_value_string(cLine, "bl_quantity", num.c_str())); ITKCALL(AOM_set_value_string(cLine, "bl_quantity", num.c_str()));
string seqNo = to_string((n + 1) * 10); string seqNo = to_string((n + 1) * 10);
ITKCALL(AOM_set_value_string(cLine, "bl_sequence_no", seqNo.c_str())); ITKCALL(AOM_set_value_string(cLine, "bl_sequence_no", seqNo.c_str()));
ITKCALL(AOM_set_value_string(cLine, "bl_occ_type", "ZT2_FuLiao")); ITKCALL(AOM_set_value_string(cLine, "bl_occ_type", "ZT2_FuLiao"));
ITKCALL(AOM_save(cLine)); (AOM_save(cLine));
//最后unlock //最后unlock
ITKCALL(AOM_unlock(cLine)); (AOM_unlock(cLine));
ITKCALL(AOM_refresh(cLine, FALSE)); ITKCALL(AOM_refresh(cLine, FALSE));
} }
@ -460,7 +475,7 @@ void getGxbmMap(tag_t processTag, map<string, tag_t>& gxDocMap, map<string, Time
printf("bvr_count=%d", bvr_count); printf("bvr_count=%d", bvr_count);
ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取
//bom_line工艺 //bom_line工艺
int c_line_count; int c_line_count;
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)); // 一级工序
@ -469,14 +484,14 @@ void getGxbmMap(tag_t processTag, map<string, tag_t>& gxDocMap, map<string, Time
char* gxbm1; char* gxbm1;
ITKCALL(AOM_ask_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ClassificationCode", &gxbm1)); ITKCALL(AOM_ask_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ClassificationCode", &gxbm1));
if (timebeans.count(gxbm1) > 0) { if (timebeans.count(gxbm1) > 0) {
ITKCALL(AOM_lock(oneGx)); (AOM_lock(oneGx));
TimeBean tbean = timebeans[gxbm1]; TimeBean tbean = timebeans[gxbm1];
ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ArtificialTime", tbean.rgsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ArtificialTime", tbean.rgsj.c_str()));
ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_MachineTime", tbean.jqsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_MachineTime", tbean.jqsj.c_str()));
ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ReadinessTime", tbean.zbsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ReadinessTime", tbean.zbsj.c_str()));
ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ProCycle", tbean.zrsczq.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ProCycle", tbean.zrsczq.c_str()));
ITKCALL(AOM_save(oneGx)); (AOM_save(oneGx));
ITKCALL(AOM_unlock(oneGx)); (AOM_unlock(oneGx));
} }
int c_cnt = 0; int c_cnt = 0;
ITKCALL(BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines)); ITKCALL(BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines));
@ -486,14 +501,14 @@ void getGxbmMap(tag_t processTag, map<string, tag_t>& gxDocMap, map<string, Time
char* gxbm2; char* gxbm2;
ITKCALL(AOM_ask_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ClassificationCode", &gxbm2)); ITKCALL(AOM_ask_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ClassificationCode", &gxbm2));
if (timebeans.count(gxbm2) > 0) { if (timebeans.count(gxbm2) > 0) {
ITKCALL(AOM_lock(towGxLine)); (AOM_lock(towGxLine));
TimeBean tbean = timebeans[gxbm2]; TimeBean tbean = timebeans[gxbm2];
ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ArtificialTime", tbean.rgsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ArtificialTime", tbean.rgsj.c_str()));
ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_MachineTime", tbean.jqsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_MachineTime", tbean.jqsj.c_str()));
ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ReadinessTime", tbean.zbsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ReadinessTime", tbean.zbsj.c_str()));
ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ProCycle", tbean.zrsczq.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ProCycle", tbean.zrsczq.c_str()));
ITKCALL(AOM_save(towGxLine)); (AOM_save(towGxLine));
ITKCALL(AOM_unlock(towGxLine)); (AOM_unlock(towGxLine));
} }
ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &towGx)); ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &towGx));
gxDocMap[gxbm2] = towGx; gxDocMap[gxbm2] = towGx;
@ -503,8 +518,8 @@ void getGxbmMap(tag_t processTag, map<string, tag_t>& gxDocMap, map<string, Time
} }
//查询ID //查询ID
tag_t * queryItem(char* itemId,tag_t newGx,char *relation) { tag_t * queryItem(char* itemId, tag_t newGx, char *relation) {
tag_t query_tag = NULLTAG,*tags=NULLTAG; tag_t query_tag = NULLTAG, *tags = NULLTAG;
ITKCALL(QRY_find("零组件...", &query_tag)); ITKCALL(QRY_find("零组件...", &query_tag));
char* qry_entries[1] = { "零组件 ID" }, *qry_values[1] = { itemId }; char* qry_entries[1] = { "零组件 ID" }, *qry_values[1] = { itemId };
int n_found; int n_found;
@ -542,11 +557,11 @@ void queryProcessRule(char *windWay, boolean isXq, char *processCode, tag_t &new
esopIds.append(esopId).append(";"); esopIds.append(esopId).append(";");
} }
} }
queryItem((char*)processIds.c_str(), newGx,"ZT2_ProcessRuleRelation"); queryItem((char*)processIds.c_str(), newGx, "ZT2_ProcessRuleRelation");
queryItem((char*)esopIds.c_str(), newGx, "ZT2_ProcGuidBookRelation"); queryItem((char*)esopIds.c_str(), newGx, "ZT2_ProcGuidBookRelation");
} }
tag_t clone_process_from_template(char* process_item_id, boolean isXq, string productZu, string xqfs,string th, string lastId) tag_t clone_process_from_template(char* process_item_id, boolean isXq, string productZu, string xqfs, string th, string lastId)
{ {
tag_t item_tag = NULLTAG; tag_t item_tag = NULLTAG;
ITKCALL(ITEM_find_item(process_item_id, &item_tag)); ITKCALL(ITEM_find_item(process_item_id, &item_tag));
@ -582,7 +597,7 @@ tag_t clone_process_from_template(char* process_item_id, boolean isXq, string pr
if (next_id) MEM_free(next_id); if (next_id) MEM_free(next_id);
ITKCALL(AOM_refresh(clone_tag, TRUE)); ITKCALL(AOM_refresh(clone_tag, TRUE));
ITKCALL(AOM_save(clone_tag)); (AOM_save(clone_tag));
ITKCALL(AOM_refresh(clone_tag, FALSE)); ITKCALL(AOM_refresh(clone_tag, FALSE));
char* item_id = NULL; char* item_id = NULL;
@ -620,8 +635,8 @@ tag_t clone_process_from_template(char* process_item_id, boolean isXq, string pr
} }
//if (!isXq) { //if (!isXq) {
map<string, tag_t> tmpProcessMap; //存放的是二级工序编码对应的二级工序版本 模板的 map<string, tag_t> tmpProcessMap; //存放的是二级工序编码对应的二级工序版本 模板的
//vector<string> timeVec; //vector<string> timeVec;
//工艺模板 //工艺模板
map<string, TimeBean > beanMap; map<string, TimeBean > beanMap;
//根据数据库配置修改工时 //根据数据库配置修改工时
getGxbmMap(revision_tag, tmpProcessMap, beanMap); getGxbmMap(revision_tag, tmpProcessMap, beanMap);
@ -693,9 +708,9 @@ tag_t clone_process_from_template(char* process_item_id, boolean isXq, string pr
string materialno = outputValue3[j][0]; string materialno = outputValue3[j][0];
string ejbm = outputValue3[j][1]; string ejbm = outputValue3[j][1];
string quantity = outputValue3[j][2]; string quantity = outputValue3[j][2];
tag_t fltag,flRev; tag_t fltag, flRev;
ITEM_find_item(materialno.c_str(),&fltag); ITEM_find_item(materialno.c_str(), &fltag);
ITEM_ask_latest_rev(fltag,&flRev); ITEM_ask_latest_rev(fltag, &flRev);
printf("materialno%s ejbm==%sEnd\n", materialno.c_str(), ejbm.c_str()); printf("materialno%s ejbm==%sEnd\n", materialno.c_str(), ejbm.c_str());
FlBean bean; FlBean bean;
bean.blQty = quantity; bean.blQty = quantity;
@ -711,28 +726,28 @@ tag_t clone_process_from_template(char* process_item_id, boolean isXq, string pr
} }
} }
getGxbmMap(clone_tag, newProcessMap, beanMap, flBeanMap,th, lastId); getGxbmMap(clone_tag, newProcessMap, beanMap, flBeanMap, th, lastId);
map<string, tag_t>::iterator it; map<string, tag_t>::iterator it;
//复制“工艺守则”、“工序作业指导书” 旧逻辑 //复制“工艺守则”、“工序作业指导书” 旧逻辑
/*for (it = tmpProcessMap.begin(); it != tmpProcessMap.end(); it++) { /*for (it = tmpProcessMap.begin(); it != tmpProcessMap.end(); it++) {
string gxbm = it->first; string gxbm = it->first;
tag_t tmpGx = it->second; tag_t tmpGx = it->second;
if (newProcessMap.count(gxbm) != 0) { if (newProcessMap.count(gxbm) != 0) {
tag_t* procGuidBooks, *processRules; tag_t* procGuidBooks, *processRules;
int cnt2 = 0, cnt3 = 0; int cnt2 = 0, cnt3 = 0;
tag_t newGx = newProcessMap[gxbm]; tag_t newGx = newProcessMap[gxbm];
ITKCALL(AOM_ask_value_tags(tmpGx, "ZT2_ProcGuidBookRelation", &cnt2, &procGuidBooks)); ITKCALL(AOM_ask_value_tags(tmpGx, "ZT2_ProcGuidBookRelation", &cnt2, &procGuidBooks));
ITKCALL(AOM_ask_value_tags(tmpGx, "ZT2_ProcessRuleRelation", &cnt3, &processRules)); ITKCALL(AOM_ask_value_tags(tmpGx, "ZT2_ProcessRuleRelation", &cnt3, &processRules));
AOM_lock(newGx); AOM_lock(newGx);
if (cnt2 > 0) { if (cnt2 > 0) {
ITKCALL(AOM_set_value_tags(newGx, "ZT2_ProcGuidBookRelation", cnt2, procGuidBooks)); ITKCALL(AOM_set_value_tags(newGx, "ZT2_ProcGuidBookRelation", cnt2, procGuidBooks));
} }
if (cnt3 > 0) { if (cnt3 > 0) {
ITKCALL(AOM_set_value_tags(newGx, "ZT2_ProcessRuleRelation", cnt3, processRules)); ITKCALL(AOM_set_value_tags(newGx, "ZT2_ProcessRuleRelation", cnt3, processRules));
} }
AOM_save(newGx); AOM_save(newGx);
AOM_unlock(newGx); AOM_unlock(newGx);
} }
}*/ }*/
//复制“工艺守则”、“工序作业指导书” 2023/12/19新增逻辑 CHINT_PROCESS_SOP_RULE 表中查询 //复制“工艺守则”、“工序作业指导书” 2023/12/19新增逻辑 CHINT_PROCESS_SOP_RULE 表中查询
for (it = newProcessMap.begin(); it != newProcessMap.end(); it++) { for (it = newProcessMap.begin(); it != newProcessMap.end(); it++) {
@ -740,23 +755,23 @@ tag_t clone_process_from_template(char* process_item_id, boolean isXq, string pr
tag_t newGx = it->second; tag_t newGx = it->second;
queryProcessRule((char*)xqfs.c_str(), isXq, (char*)gxbm.c_str(), newGx); queryProcessRule((char*)xqfs.c_str(), isXq, (char*)gxbm.c_str(), newGx);
/*if (newProcessMap.count(gxbm) != 0) { /*if (newProcessMap.count(gxbm) != 0) {
tag_t* procGuidBooks, *processRules; tag_t* procGuidBooks, *processRules;
int cnt2 = 0, cnt3 = 0; int cnt2 = 0, cnt3 = 0;
if (isXq) { if (isXq) {
sprintf(selectGyId, sqlGxTime2.c_str(), productZu.c_str(), process_item_id, xqfs.c_str()); sprintf(selectGyId, sqlGxTime2.c_str(), productZu.c_str(), process_item_id, xqfs.c_str());
} }
tag_t newGx = newProcessMap[gxbm]; tag_t newGx = newProcessMap[gxbm];
ITKCALL(AOM_ask_value_tags(tmpGx, "ZT2_ProcGuidBookRelation", &cnt2, &procGuidBooks)); ITKCALL(AOM_ask_value_tags(tmpGx, "ZT2_ProcGuidBookRelation", &cnt2, &procGuidBooks));
ITKCALL(AOM_ask_value_tags(tmpGx, "ZT2_ProcessRuleRelation", &cnt3, &processRules)); ITKCALL(AOM_ask_value_tags(tmpGx, "ZT2_ProcessRuleRelation", &cnt3, &processRules));
AOM_lock(newGx); AOM_lock(newGx);
if (cnt2 > 0) { if (cnt2 > 0) {
ITKCALL(AOM_set_value_tags(newGx, "ZT2_ProcGuidBookRelation", cnt2, procGuidBooks)); ITKCALL(AOM_set_value_tags(newGx, "ZT2_ProcGuidBookRelation", cnt2, procGuidBooks));
} }
if (cnt3 > 0) { if (cnt3 > 0) {
ITKCALL(AOM_set_value_tags(newGx, "ZT2_ProcessRuleRelation", cnt3, processRules)); ITKCALL(AOM_set_value_tags(newGx, "ZT2_ProcessRuleRelation", cnt3, processRules));
} }
AOM_save(newGx); AOM_save(newGx);
AOM_unlock(newGx); AOM_unlock(newGx);
}*/ }*/
} }
//} //}
@ -854,7 +869,7 @@ string getClassVal(tag_t top_rev_tag, string& errMessage, ByqBean &bean) {
} }
else if (strcmp(attr_names[ii], "稳压线圈绕线方式") == 0) { else if (strcmp(attr_names[ii], "稳压线圈绕线方式") == 0) {
if (strcmp(attr_vals[ii], "") == 0) { if (strcmp(attr_vals[ii], "") == 0) {
// errMessage.append("分类属性稳压线圈绕线方式为空,请检查。\n"); // errMessage.append("分类属性稳压线圈绕线方式为空,请检查。\n");
//return ""; //return "";
} }
else { else {
@ -894,7 +909,7 @@ void Split2(string strArg, string spliter, vector<string>& ans)
} }
} }
} }
tag_t getTmpProcess(string cpxh, string th, string& errBuff, string& oldGyId, boolean isXq, string xqfs,string lastId) { tag_t getTmpProcess(string cpxh, string th, string& errBuff, string& oldGyId, boolean isXq, string xqfs, string lastId) {
char selectCPZ[300], selectGyId[200]; char selectCPZ[300], selectGyId[200];
sprintf(selectCPZ, sqlCpxh.c_str(), cpxh.c_str()); sprintf(selectCPZ, sqlCpxh.c_str(), cpxh.c_str());
int outputColumn = 0, outputValueCount = 0; int outputColumn = 0, outputValueCount = 0;
@ -1004,7 +1019,7 @@ void readProcessBom(tag_t bom_line, string& errorBuff, boolean &flag, tag_t &top
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));
char *objName; char *objName;
AOM_ask_value_string(mantr, "object_name", &objName); AOM_ask_value_string(mantr, "object_name", &objName);
if (c_line_count > 0 && (isXn(mantr)|| strstr(objName, "变压器") != NULL)) { if (c_line_count > 0 && (isXn(mantr) || strstr(objName, "变压器") != NULL)) {
printf("实体\n"); printf("实体\n");
flag = true; flag = true;
//检查是否有工艺路线 //检查是否有工艺路线
@ -1027,7 +1042,7 @@ void readProcessBom(tag_t bom_line, string& errorBuff, boolean &flag, tag_t &top
} }
printf("hasProcess==%d\n", hasProcess); printf("hasProcess==%d\n", hasProcess);
if (!hasProcess) { if (!hasProcess) {
char* bl_desc = NULL, * itemID = NULL; char* bl_desc = NULL, *itemID = NULL;
ITKCALL(AOM_ask_value_string(mantr, "item_id", &itemID)); ITKCALL(AOM_ask_value_string(mantr, "item_id", &itemID));
printf("back==%zd\n", back.size()); printf("back==%zd\n", back.size());
if (back.size() > 0) { if (back.size() > 0) {
@ -1178,6 +1193,8 @@ tag_t getProcess(tag_t designRev) {
} }
int CloneTempProcess(void *returnValue) int CloneTempProcess(void *returnValue)
{ {
// 记录开始时间点
auto start = std::chrono::high_resolution_clock::now();
int ifail = ITK_ok; int ifail = ITK_ok;
char* sql = NULL, *revUid; char* sql = NULL, *revUid;
tag_t designRev; tag_t designRev;
@ -1187,7 +1204,7 @@ int CloneTempProcess(void *returnValue)
tag_t ebom_window = NULLTAG; tag_t ebom_window = NULLTAG;
tag_t bom_line = NULLTAG; tag_t bom_line = NULLTAG;
tag_t item_tag = NULLTAG, *c_line_tags = NULLTAG; tag_t item_tag = NULLTAG, *c_line_tags = NULLTAG;
(BOM_create_window(&ebom_window)); ITKCALL(BOM_create_window(&ebom_window));
tag_t* bvr_list = NULL; tag_t* bvr_list = NULL;
ITKCALL(ITEM_rev_list_bom_view_revs(designRev, &bvr_count, &bvr_list)); ITKCALL(ITEM_rev_list_bom_view_revs(designRev, &bvr_count, &bvr_list));
printf("bvr_count=%d", bvr_count); printf("bvr_count=%d", bvr_count);
@ -1232,7 +1249,7 @@ int CloneTempProcess(void *returnValue)
} }
boolean isback = false; boolean isback = false;
tag_t meProcess = NULLTAG; tag_t meProcess = NULLTAG;
char* objName = NULL, * topId = NULL; char* objName = NULL, *topId = NULL;
string backs = ""; string backs = "";
ITKCALL(AOM_ask_value_string(designRev, "object_name", &objName)); ITKCALL(AOM_ask_value_string(designRev, "object_name", &objName));
ITKCALL(AOM_ask_value_string(designRev, "item_id", &topId)); ITKCALL(AOM_ask_value_string(designRev, "item_id", &topId));
@ -1240,7 +1257,7 @@ int CloneTempProcess(void *returnValue)
//如果是产成品的话, 判断是否存在多个P物料 //如果是产成品的话, 判断是否存在多个P物料
//20240203备件包工艺路线指派 //20240203备件包工艺路线指派
int back_num = 0; int back_num = 0;
char** back_vals = NULL, * group_name = NULL; char** back_vals = NULL, *group_name = NULL;
tag_t group = NULLTAG; tag_t group = NULLTAG;
string tuhao; string tuhao;
vector<string> group_names; vector<string> group_names;
@ -1262,7 +1279,7 @@ int CloneTempProcess(void *returnValue)
break; break;
} }
} }
if(isback) if (isback)
break; break;
} }
} }
@ -1271,7 +1288,7 @@ int CloneTempProcess(void *returnValue)
int b_refs = 0; int b_refs = 0;
int* b_levels = 0; int* b_levels = 0;
tag_t* b_refs_tag = NULLTAG; tag_t* b_refs_tag = NULLTAG;
char** b_rel_name = NULL, * pcode = NULL; char** b_rel_name = NULL, *pcode = NULL;
string cpxh = ""; string cpxh = "";
//判断当前物料对象是否在“产成品”文件夹ZT2_ProjectFolder //判断当前物料对象是否在“产成品”文件夹ZT2_ProjectFolder
ITKCALL(ITEM_ask_item_of_rev(designRev, &item_tag)); ITKCALL(ITEM_ask_item_of_rev(designRev, &item_tag));
@ -1287,7 +1304,7 @@ int CloneTempProcess(void *returnValue)
ITKCALL(AOM_ask_value_tags(b_refs_tag[i], "contents", &n_projs, &projs)); ITKCALL(AOM_ask_value_tags(b_refs_tag[i], "contents", &n_projs, &projs));
for (int j = 0; j < n_projs; j++) { for (int j = 0; j < n_projs; j++) {
int n_drows = 0; int n_drows = 0;
tag_t proj_rev = NULLTAG, * drows = NULLTAG; tag_t proj_rev = NULLTAG, *drows = NULLTAG;
ITKCALL(ITEM_ask_latest_rev(projs[j], &proj_rev)); ITKCALL(ITEM_ask_latest_rev(projs[j], &proj_rev));
ITKCALL(AOM_ask_value_tags(proj_rev, "TC_Is_Represented_By", &n_drows, &drows)); ITKCALL(AOM_ask_value_tags(proj_rev, "TC_Is_Represented_By", &n_drows, &drows));
printf("n_drows:%d\n", n_drows); printf("n_drows:%d\n", n_drows);
@ -1304,35 +1321,35 @@ int CloneTempProcess(void *returnValue)
backs.append(cpxh).append("@").append(tuhao); backs.append(cpxh).append("@").append(tuhao);
/*string sql = "select a.GYID from CHINT_WORKHOUR_WhProductXH a,CHINT_WORKHOUR_WhGYRule b "; /*string sql = "select a.GYID from CHINT_WORKHOUR_WhProductXH a,CHINT_WORKHOUR_WhGYRule b ";
sql.append("where a.COMPANYCODE=b.COMPANYCODE and a.ProductZu=b.ProductZu ") sql.append("where a.COMPANYCODE=b.COMPANYCODE and a.ProductZu=b.ProductZu ")
.append("and a.COMPANYCODE='").append(group_name) .append("and a.COMPANYCODE='").append(group_name)
.append("' and a.ProductXH='").append(cpxh) .append("' and a.ProductXH='").append(cpxh)
.append("' and b.TuHao='").append(tuhao) .append("' and b.TuHao='").append(tuhao)
.append("'"); .append("'");
int outputColumn = 0, outputValueCount = 0; int outputColumn = 0, outputValueCount = 0;
char*** outputValue = NULL, sqlc[1024]; char*** outputValue = NULL, sqlc[1024];
tc_strcpy(sqlc, sql.c_str()); tc_strcpy(sqlc, sql.c_str());
QuerySQLNoInputParam(sqlc, &outputColumn, &outputValueCount, &outputValue); QuerySQLNoInputParam(sqlc, &outputColumn, &outputValueCount, &outputValue);
if (outputValueCount > 0) { if (outputValueCount > 0) {
gyid = outputValue[0][0]; gyid = outputValue[0][0];
} }
for (int i = 0; i < outputValueCount; i++) { for (int i = 0; i < outputValueCount; i++) {
}*/ }*/
} }
else if (strstr(objName, "变压器") != NULL) { else if (strstr(objName, "变压器") != NULL) {
tag_t *topMatnrs,*pMaterials; tag_t *topMatnrs, *pMaterials;
int num = 0, num2=0; int num = 0, num2 = 0;
ITKCALL(AOM_ask_value_tags(designRev, "TC_Is_Represented_By", &num, &topMatnrs)); ITKCALL(AOM_ask_value_tags(designRev, "TC_Is_Represented_By", &num, &topMatnrs));
printf("num===>%d\n", num); printf("num===>%d\n", num);
if (num >= 1) { if (num >= 1) {
tag_t tzRev = topMatnrs[0]; tag_t tzRev = topMatnrs[0];
ITKCALL(AOM_ask_value_tags(tzRev, "representation_for", &num2, &pMaterials)); ITKCALL(AOM_ask_value_tags(tzRev, "representation_for", &num2, &pMaterials));
for (int x = 0; x < num2; x++) { for (int x = 0; x < num2; x++) {
char *pId,*zt2_ifpbom; char *pId, *zt2_ifpbom;
tag_t pMatr = pMaterials[x]; tag_t pMatr = pMaterials[x];
ITKCALL(AOM_ask_value_string(pMatr, "item_id", &pId)); ITKCALL(AOM_ask_value_string(pMatr, "item_id", &pId));
ITKCALL(AOM_ask_value_string(pMatr, "zt2_ifpbom", &zt2_ifpbom)); ITKCALL(AOM_ask_value_string(pMatr, "zt2_ifpbom", &zt2_ifpbom));
if (strcmp(pId, topId) != 0 && strcmp(zt2_ifpbom,"P")==0) { if (strcmp(pId, topId) != 0 && strcmp(zt2_ifpbom, "P") == 0) {
tag_t process = getProcess(pMatr); tag_t process = getProcess(pMatr);
if (process != NULLTAG) { if (process != NULLTAG) {
meProcess = process; meProcess = process;
@ -1355,7 +1372,7 @@ int CloneTempProcess(void *returnValue)
save_representation2(meProcess, matnrPrev, "IMAN_METarget"); save_representation2(meProcess, matnrPrev, "IMAN_METarget");
} }
printf("=======\n"); printf("=======\n");
errorBuff = "当前选中的物料已经存在工艺路线.\n"; //errorBuff = "当前选中的物料已经存在工艺路线.\n";
} }
else if (processTagTop != NULLTAG) { else if (processTagTop != NULLTAG) {
map<string, tag_t>::iterator it; map<string, tag_t>::iterator it;
@ -1366,22 +1383,34 @@ int CloneTempProcess(void *returnValue)
tag_t matnrPrev = mapByq[s]; tag_t matnrPrev = mapByq[s];
save_representation2(processTagTop, matnrPrev, "IMAN_METarget"); save_representation2(processTagTop, matnrPrev, "IMAN_METarget");
} }
errorBuff = "当前选中的物料已经存在工艺路线.\n"; //errorBuff = "当前选中的物料已经存在工艺路线.\n";
} }
} }
printf("mapByq===>%zd\n", mapByq.size()); printf("mapByq===>%zd\n", mapByq.size());
if (hasProcess) { if ((strcmp(bl_desc, "") == 0 || strstr(bl_desc, "-") == NULL) && strstr(objName, "变压器") == NULL && !isback) {
errorBuff = "当前选中的物料已经存在工艺路线.\n";
}else if ((strcmp(bl_desc, "") == 0 || strstr(bl_desc,"-")==NULL) && strstr(objName, "变压器") == NULL && !isback) {
errorBuff = "当前选中的物料版本没有图号信息,请检查.\n"; errorBuff = "当前选中的物料版本没有图号信息,请检查.\n";
} }
else { else {
if (hasProcess) {
//errorBuff = "当前选中的物料已经存在工艺路线.\n";
}
POM_AM__set_application_bypass(true); POM_AM__set_application_bypass(true);
tag_t topProcess = NULLTAG; tag_t topProcess = NULLTAG;
boolean flag = false; boolean flag = false;
printf("errorBuff==>%s\n", errorBuff.c_str()); printf("errorBuff==>%s\n", errorBuff.c_str());
// 记录开始时间点
auto start1 = std::chrono::high_resolution_clock::now();
readProcessBom(bom_line, errorBuff, flag, topProcess, notTcmBuff, backs); readProcessBom(bom_line, errorBuff, flag, topProcess, notTcmBuff, backs);
// 记录结束时间点
auto end1 = std::chrono::high_resolution_clock::now();
// 计算时间差,转换为秒
auto duration1 = std::chrono::duration_cast<std::chrono::seconds>(end1 - start1);
double elapsed_seconds1 = duration1.count();
// 输出耗时(秒)
std::cout << "Function call took " << elapsed_seconds1 << " seconds." << std::endl;
if (topProcess != NULLTAG) { if (topProcess != NULLTAG) {
map<string, tag_t>::iterator it; map<string, tag_t>::iterator it;
for (it = mapByq.begin(); it != mapByq.end(); it++) { for (it = mapByq.begin(); it != mapByq.end(); it++) {
@ -1395,6 +1424,18 @@ int CloneTempProcess(void *returnValue)
} }
POM_AM__set_application_bypass(false); POM_AM__set_application_bypass(false);
} }
// 记录结束时间点
auto end = std::chrono::high_resolution_clock::now();
// 计算时间差,转换为秒
auto duration = std::chrono::duration_cast<std::chrono::seconds>(end - start);
double elapsed_seconds = duration.count();
// 输出耗时(秒)
std::cout << "Function call took " << elapsed_seconds << " seconds." << std::endl;
DisConnServer(); DisConnServer();
errorBuff.append(notTcmBuff); errorBuff.append(notTcmBuff);
if (errorBuff.empty()) { if (errorBuff.empty()) {

@ -33,6 +33,7 @@
#include <ss/ss_errors.h> #include <ss/ss_errors.h>
#include <ae/datasettype.h> #include <ae/datasettype.h>
// #include "hx_custom.h" // #include "hx_custom.h"
#include <chrono>
#include <regex> #include <regex>
#include "tc_log.h" #include "tc_log.h"
// #include "jk_custom.h" // #include "jk_custom.h"
@ -53,6 +54,7 @@ struct NodeBean
vector<tag_t> ccps;//产成品 vector<tag_t> ccps;//产成品
int xnNum = 1;//虚拟件数量累乘 int xnNum = 1;//虚拟件数量累乘
boolean isOutBuy = false;//记录是否外购、或者权限不是自己的 boolean isOutBuy = false;//记录是否外购、或者权限不是自己的
string remark; //备注
}; };
bool isTcm(tag_t mantr) { bool isTcm(tag_t mantr) {
int releaseCount = 0; int releaseCount = 0;
@ -116,8 +118,8 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean
int num = 0; int num = 0;
tag_t* mantrs; tag_t* mantrs;
char *type, *item_id; char *type, *item_id;
AOM_ask_value_string(designRev, "object_type", &type); ITKCALL(AOM_ask_value_string(designRev, "object_type", &type));
AOM_ask_value_string(designRev, "item_id", &item_id); ITKCALL(AOM_ask_value_string(designRev, "item_id", &item_id));
if (strcmp(type, "Part Revision") == 0) { if (strcmp(type, "Part Revision") == 0) {
return designRev; return designRev;
} }
@ -128,12 +130,12 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean
map<string, tag_t> partsCcp; map<string, tag_t> partsCcp;
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
char* type, *zt2_ifpbom, *itemId; char* type, *zt2_ifpbom, *itemId;
AOM_ask_value_string(mantrs[i], "object_type", &type); ITKCALL(AOM_ask_value_string(mantrs[i], "object_type", &type));
AOM_ask_value_string(mantrs[i], "zt2_ifpbom", &zt2_ifpbom); ITKCALL(AOM_ask_value_string(mantrs[i], "zt2_ifpbom", &zt2_ifpbom));
AOM_ask_value_string(mantrs[i], "item_id", &itemId); ITKCALL(AOM_ask_value_string(mantrs[i], "item_id", &itemId));
if (strstr(type, "Part") != NULL && strcmp(zt2_ifpbom, "P") != 0) { // if (strstr(type, "Part") != NULL && strcmp(zt2_ifpbom, "P") != 0) { //
tag_t matnrItem; tag_t matnrItem;
ITEM_ask_item_of_rev(mantrs[i], &matnrItem); ITKCALL(ITEM_ask_item_of_rev(mantrs[i], &matnrItem));
partsCcp[itemId] = matnrItem; partsCcp[itemId] = matnrItem;
//partsCcp.push_back(); //partsCcp.push_back();
/*if (parts.size()==0) { /*if (parts.size()==0) {
@ -149,7 +151,7 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean
for (it = partsCcp.begin(); it != partsCcp.end(); it++) { for (it = partsCcp.begin(); it != partsCcp.end(); it++) {
string s = it->first; string s = it->first;
tag_t partLast = partsCcp[s], partRevLast; tag_t partLast = partsCcp[s], partRevLast;
ITEM_ask_latest_rev(partLast, &partRevLast); ITKCALL(ITEM_ask_latest_rev(partLast, &partRevLast));
if (parts.size() == 0) { if (parts.size() == 0) {
parts.push_back(partRevLast); parts.push_back(partRevLast);
} }
@ -163,12 +165,12 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean
map<string, tag_t> partsCcp; map<string, tag_t> partsCcp;
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
char* type, *zt2_ifpbom, *itemId; char* type, *zt2_ifpbom, *itemId;
AOM_ask_value_string(mantrs[i], "object_type", &type); ITKCALL(AOM_ask_value_string(mantrs[i], "object_type", &type));
AOM_ask_value_string(mantrs[i], "zt2_ifpbom", &zt2_ifpbom); ITKCALL(AOM_ask_value_string(mantrs[i], "zt2_ifpbom", &zt2_ifpbom));
AOM_ask_value_string(mantrs[i], "item_id", &itemId); ITKCALL(AOM_ask_value_string(mantrs[i], "item_id", &itemId));
if (strstr(type, "Part") != NULL && strcmp(zt2_ifpbom, "P") != 0) { // if (strstr(type, "Part") != NULL && strcmp(zt2_ifpbom, "P") != 0) { //
tag_t matnrItem; tag_t matnrItem;
ITEM_ask_item_of_rev(mantrs[i], &matnrItem); ITKCALL(ITEM_ask_item_of_rev(mantrs[i], &matnrItem));
partsCcp[itemId] = matnrItem; partsCcp[itemId] = matnrItem;
} }
} }
@ -176,7 +178,7 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean
for (it = partsCcp.begin(); it != partsCcp.end(); it++) { for (it = partsCcp.begin(); it != partsCcp.end(); it++) {
string s = it->first; string s = it->first;
tag_t partLast = partsCcp[s], partRevLast; tag_t partLast = partsCcp[s], partRevLast;
ITEM_ask_latest_rev(partLast, &partRevLast); ITKCALL(ITEM_ask_latest_rev(partLast, &partRevLast));
//if (parts.size() == 0) { //if (parts.size() == 0) {
//} //}
parts.push_back(partRevLast); parts.push_back(partRevLast);
@ -259,7 +261,7 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean
for (int i = 0; i < parts.size(); i++) { for (int i = 0; i < parts.size(); i++) {
tag_t part = parts[i]; tag_t part = parts[i];
char* specPart; char* specPart;
AOM_ask_value_string(part, "zt2_Specifications", &specPart); ITKCALL(AOM_ask_value_string(part, "zt2_Specifications", &specPart));
if (strcmp(specPart, spec) == 0) { if (strcmp(specPart, spec) == 0) {
return part; return part;
} }
@ -285,6 +287,84 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean
}*/ }*/
} }
/**
* part
* @param bom_line partBOM
* @param errBuff
*/
void checkPart(tag_t bom_line, string& errBuff) {
tag_t part = NULLTAG;
ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &part));
char* name, *partId, **sealeds, **factorys, *matnr, **procureType;
ITKCALL(AOM_refresh(part, false));
ITKCALL(AOM_ask_value_string(part, "object_name", &name));
//printf("name%s\n", name);
int cnt2, numFac, cnt3;
//检查物料是否可用
ITKCALL(AOM_ask_value_string(part, "item_id", &partId));
ITKCALL(AOM_ask_value_string(part, "zt2_MaterialNo", &matnr));
if (strcmp(matnr, "") == 0) {
string buffErr = "";
buffErr.append("物料:").append(partId).append("/").append(name).append("没有物料编码.\n");
size_t found = errBuff.find(buffErr);
if (found == std::string::npos) {
errBuff.append(buffErr);
}
//errBuff.append("物料:").append(partId).append("/").append(name).append("没有物料编码.\n");
//return;
}
boolean numFlag = true;
ITKCALL(AOM_ask_value_strings(part, "zt2_SZSealedornot", &cnt2, &sealeds));
ITKCALL(AOM_ask_value_strings(part, "zt2_SZFactory", &numFac, &factorys));
ITKCALL(AOM_ask_value_strings(part, "zt2_SZProcuretype", &cnt3, &procureType)); //包含自制
for (int i = 0; i < numFac; i++) {
if (strcmp(factorys[i], "M060") == 0) {
numFlag = false;
}
if (strcmp(factorys[i], "M060") == 0 && cnt2 > i) {
if (strcmp(sealeds[i], "Y") == 0) {
//errBuff.append("物料:").append(partId).append("/").append(name).append("已封存无法转换EBOM.\n");
string buffErr = "";
buffErr.append("物料:").append(partId).append("/").append(name).append("已封存无法转换EBOM.\n");
size_t found = errBuff.find(buffErr);
if (found == std::string::npos) {
errBuff.append(buffErr);
}
}
//if (cnt3 > i && strstr(procureType[i], "自制") != NULL) {
// flagMat = true;
//}
}
}
char*objName;
ITKCALL(AOM_ask_value_string(part, OBJECT_NAME, &objName));
if (numFlag && strstr(objName, CCP_NAME) == NULL) {// || (strstr(partId,"2ZD")!=NULL|| strstr(partId, "4ZD") != NULL)
string buffErr = "";
buffErr.append("物料:").append(partId).append("/").append(name).append("物料视图没有维护,请检查.\n");
size_t found = errBuff.find(buffErr);
if (found == std::string::npos) {
errBuff.append(buffErr);
}
//errBuff.append("物料:").append(partId).append("/").append(name).append("物料视图没有维护,请检查.\n");
}
char *sffc = NULL;
ITKCALL(AOM_ask_value_string(part, "zt2_State", &sffc));
if (strcmp(sffc, "D1") == 0 || strcmp(sffc, "封存") == 0) {
string buffErr = "";
buffErr.append("物料:").append(partId).append("/").append(name).append("已封存无法转换EBOM.\n");
size_t found = errBuff.find(buffErr);
if (found == std::string::npos) {
errBuff.append(buffErr);
}
}
int c_line_count = 0;
tag_t *c_line_tags = NULL;
ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags));
for (int i = 0; i < c_line_count; i++) {
checkPart(c_line_tags[i], errBuff);
}
}
/** /**
* DBOM * DBOM
* @param bom_line DBOM * @param bom_line DBOM
@ -293,6 +373,7 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean
* @param designRev * @param designRev
* @param flagMat * @param flagMat
*/ */
void askLineVal(NodeBean& bean, tag_t bom_line, tag_t designRev, string& errBuff, boolean &flagMat) { void askLineVal(NodeBean& bean, tag_t bom_line, tag_t designRev, string& errBuff, boolean &flagMat) {
char* bl_quantity, *bl_plmxml_occ_xform, *bl_sequence_no, *sffc; char* bl_quantity, *bl_plmxml_occ_xform, *bl_sequence_no, *sffc;
ITKCALL(AOM_ask_value_string(bom_line, "bl_sequence_no", &bl_sequence_no)); ITKCALL(AOM_ask_value_string(bom_line, "bl_sequence_no", &bl_sequence_no));
@ -324,7 +405,7 @@ void askLineVal(NodeBean& bean, tag_t bom_line, tag_t designRev, string& errBuff
char* name, *partId, **sealeds, **factorys, *matnr, **procureType; char* name, *partId, **sealeds, **factorys, *matnr, **procureType;
ITKCALL(AOM_refresh(part, false)); ITKCALL(AOM_refresh(part, false));
ITKCALL(AOM_ask_value_string(part, "object_name", &name)); ITKCALL(AOM_ask_value_string(part, "object_name", &name));
printf("name%s\n", name); //printf("name%s\n", name);
int cnt2, numFac, cnt3; int cnt2, numFac, cnt3;
//检查物料是否可用 //检查物料是否可用
ITKCALL(AOM_ask_value_string(part, "item_id", &partId)); ITKCALL(AOM_ask_value_string(part, "item_id", &partId));
@ -363,7 +444,7 @@ void askLineVal(NodeBean& bean, tag_t bom_line, tag_t designRev, string& errBuff
} }
} }
char*objName; char*objName;
AOM_ask_value_string(part, OBJECT_NAME, &objName); ITKCALL(AOM_ask_value_string(part, OBJECT_NAME, &objName));
if (numFlag && strstr(objName, CCP_NAME) == NULL) {// || (strstr(partId,"2ZD")!=NULL|| strstr(partId, "4ZD") != NULL) if (numFlag && strstr(objName, CCP_NAME) == NULL) {// || (strstr(partId,"2ZD")!=NULL|| strstr(partId, "4ZD") != NULL)
string buffErr = ""; string buffErr = "";
buffErr.append("物料:").append(partId).append("/").append(name).append("物料视图没有维护,请检查.\n"); buffErr.append("物料:").append(partId).append("/").append(name).append("物料视图没有维护,请检查.\n");
@ -383,11 +464,21 @@ void askLineVal(NodeBean& bean, tag_t bom_line, tag_t designRev, string& errBuff
} }
} }
bean.mantr = part; bean.mantr = part;
/*
tag_t ebom_window = NULLTAG, line = NULLTAG;
ITKCALL(BOM_create_window(&ebom_window));
ITKCALL(BOM_set_window_top_line(ebom_window, NULL, part, NULLTAG, &line));
int c_line_count = 0;
tag_t *c_line_tags = NULL;
ITKCALL(BOM_line_ask_all_child_lines(line, &c_line_count, &c_line_tags));
for (int i = 0; i < c_line_count; i++) {
checkPart(c_line_tags[i], errBuff);
}*/
} }
else { else {
char *partId, *name; char *partId, *name;
AOM_ask_value_string(designRev, "item_id", &partId); ITKCALL(AOM_ask_value_string(designRev, "item_id", &partId));
AOM_ask_value_string(designRev, "object_name", &name); ITKCALL(AOM_ask_value_string(designRev, "object_name", &name));
string buffErr = ""; string buffErr = "";
buffErr.append("图纸:").append(partId).append("/").append(name).append("下未找到物料对象.\n"); buffErr.append("图纸:").append(partId).append("/").append(name).append("下未找到物料对象.\n");
@ -407,8 +498,8 @@ void askLineVal(NodeBean& bean, tag_t bom_line, tag_t designRev, string& errBuff
*/ */
string getTyjZl(tag_t bom_line, string materialutilization, tag_t desginRev, string &errMessage) { string getTyjZl(tag_t bom_line, string materialutilization, tag_t desginRev, string &errMessage) {
char *ZT2_TYSpecifications, *ZT2_TYWeight, *item_id; char *ZT2_TYSpecifications, *ZT2_TYWeight, *item_id;
AOM_ask_value_string(bom_line, "item_id", &item_id); ITKCALL(AOM_ask_value_string(bom_line, "bl_item_item_id", &item_id));
AOM_ask_value_string(bom_line, "ZT2_TYSpecifications", &ZT2_TYSpecifications); ITKCALL(AOM_ask_value_string(bom_line, "ZT2_TYSpecifications", &ZT2_TYSpecifications));
double lyl = 0.85; double lyl = 0.85;
char strff[21]; char strff[21];
if (!materialutilization.empty()) { if (!materialutilization.empty()) {
@ -416,7 +507,7 @@ string getTyjZl(tag_t bom_line, string materialutilization, tag_t desginRev, str
} }
if (strcmp(ZT2_TYSpecifications, "") == 0) { if (strcmp(ZT2_TYSpecifications, "") == 0) {
double weight = 0; double weight = 0;
AOM_ask_value_double(desginRev, "zt2_DesignWeight", &weight); ITKCALL(AOM_ask_value_double(desginRev, "zt2_DesignWeight", &weight));
if (weight == 0) { if (weight == 0) {
errMessage.append(item_id).append("未填写设计重量;\n"); errMessage.append(item_id).append("未填写设计重量;\n");
return "0"; return "0";
@ -425,7 +516,7 @@ string getTyjZl(tag_t bom_line, string materialutilization, tag_t desginRev, str
sprintf(strff, "%.3f", two); sprintf(strff, "%.3f", two);
} }
else { else {
AOM_ask_value_string(bom_line, "ZT2_TYWeight", &ZT2_TYWeight); ITKCALL(AOM_ask_value_string(bom_line, "ZT2_TYWeight", &ZT2_TYWeight));
if (strcmp(ZT2_TYWeight, "") == 0) { if (strcmp(ZT2_TYWeight, "") == 0) {
errMessage.append(item_id).append("未填写通用件重量;\n"); errMessage.append(item_id).append("未填写通用件重量;\n");
return "0"; return "0";
@ -541,16 +632,15 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName
return; return;
} }
} }
/*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));
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
logical flag; logical flag;
BOM_line_is_packed(c_line_tags[i], &flag); ITKCALL(BOM_line_is_packed(c_line_tags[i], &flag));
if (flag) { if (flag) {
BOM_line_unpack(c_line_tags[i]); ITKCALL(BOM_line_unpack(c_line_tags[i]));
} }
} }
AOM_refresh(bom_line, FALSE); AOM_refresh(bom_line, FALSE);*/
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 && !dbName.empty() && (strstr(itemId, "1ZD") != NULL || if (c_line_count == 0 && !dbName.empty() && (strstr(itemId, "1ZD") != NULL ||
@ -590,6 +680,7 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName
cBean.bl_sequence_no = "10"; cBean.bl_sequence_no = "10";
cBean.bl_plmxml_occ_xform = ""; cBean.bl_plmxml_occ_xform = "";
cBean.mantr = materialRev; cBean.mantr = materialRev;
cBean.remark = "";
pBean.childs.push_back(cBean); pBean.childs.push_back(cBean);
} }
} }
@ -600,45 +691,62 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName
//检查是否线圈 //检查是否线圈
regex qq_reg2("^1ZDB5.*\\d{1,}1000X.*"); regex qq_reg2("^1ZDB5.*\\d{1,}1000X.*");
bool ret = regex_match(item_id, result, qq_reg2); bool ret = regex_match(item_id, result, qq_reg2);
vector<string> uidVec;
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
logical suppressed; logical suppressed;
ITKCALL(AOM_ask_value_logical(c_line_tags[i], "bl_is_occ_suppressed", &suppressed)); ITKCALL(AOM_ask_value_logical(c_line_tags[i], "bl_is_occ_suppressed", &suppressed));
if (suppressed) { if (suppressed) {
continue; continue;
} }
char* os = NULL;
ITKCALL(AOM_ask_value_string(c_line_tags[i], "object_string", &os));
//修改过之后之前已经是解包的状态了 //修改过之后之前已经是解包的状态了
logical flag; logical flag;
char *remark;
ITKCALL(BOM_line_is_packed(c_line_tags[i], &flag)); ITKCALL(BOM_line_is_packed(c_line_tags[i], &flag));
//printf("flag===>%d\n", flag); printf("flag1=%d==>%s\n", flag, os);
ITKCALL(AOM_ask_value_string(c_line_tags[i], "ZT2_Remark", &remark));
//printf("recyReadBom:%s\n", remark);
if (flag) { if (flag) {
int count = 0; int count = 0;
char *topNum; char *topNum;
ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_quantity", &topNum)); ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_quantity", &topNum));
tag_t* packLines; tag_t* packLines;
ITKCALL(BOM_line_ask_packed_lines(c_line_tags[i], &count, &packLines)); ITKCALL(BOM_line_ask_packed_lines(c_line_tags[i], &count, &packLines));
for (int t = 0; t < count; t++) { printf("packLines:%d\n", count);
/*for (int t = 0; t < count; t++) {
tag_t c_Rev; tag_t c_Rev;
ITKCALL(AOM_ask_value_tag(packLines[t], "bl_line_object", &c_Rev)); ITKCALL(AOM_ask_value_tag(packLines[t], "bl_line_object", &c_Rev));
char* cUid; char* cUid;
ITK__convert_tag_to_uid(c_Rev, &cUid); ITK__convert_tag_to_uid(c_Rev, &cUid);
//if (find(uidVec.begin(), uidVec.end(), cUid) != uidVec.end()) {
// continue;
//}
//uidVec.push_back(cUid);
NodeBean cBean; NodeBean cBean;
cBean.revUid = cUid; cBean.revUid = cUid;
cBean.designRev = c_Rev; cBean.designRev = c_Rev;
cBean.packNum = count + 1; cBean.packNum = count + 1;
cBean.topNum = atoi(topNum); cBean.topNum = atoi(topNum);
cBean.remark = remark;
recyReadBom(c_line_tags[i], cBean, errBuff, dbName, loginUserId); recyReadBom(c_line_tags[i], cBean, errBuff, dbName, loginUserId);
pBean.childs.push_back(cBean); pBean.childs.push_back(cBean);
} }*/
AOM_refresh(c_line_tags[i], FALSE); AOM_refresh(c_line_tags[i], FALSE);
tag_t c_Rev; tag_t c_Rev;
ITKCALL(AOM_ask_value_tag(c_line_tags[i], "bl_line_object", &c_Rev)); ITKCALL(AOM_ask_value_tag(c_line_tags[i], "bl_line_object", &c_Rev));
char* cUid; char* cUid;
ITK__convert_tag_to_uid(c_Rev, &cUid); ITK__convert_tag_to_uid(c_Rev, &cUid);
/*if (find(uidVec.begin(), uidVec.end(), cUid) != uidVec.end()) {
continue;
}
uidVec.push_back(cUid);*/
NodeBean cBean; NodeBean cBean;
cBean.revUid = cUid; cBean.revUid = cUid;
cBean.designRev = c_Rev; cBean.designRev = c_Rev;
cBean.packNum = count + 1; cBean.packNum = count + 1;
cBean.topNum = atoi(topNum); cBean.topNum = atoi(topNum);
cBean.remark = remark;
recyReadBom(c_line_tags[i], cBean, errBuff, dbName, loginUserId); recyReadBom(c_line_tags[i], cBean, errBuff, dbName, loginUserId);
pBean.childs.push_back(cBean); pBean.childs.push_back(cBean);
@ -646,30 +754,34 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName
else { else {
//检查E转P时的拆分逻辑 //检查E转P时的拆分逻辑
tag_t c_Rev; tag_t c_Rev;
char *seqNo, *c_type, *remark, *bl_quantity, *bl_line_name; char *seqNo, *c_type, *bl_quantity, *bl_line_name;
ITKCALL(AOM_ask_value_tag(c_line_tags[i], "bl_line_object", &c_Rev)); ITKCALL(AOM_ask_value_tag(c_line_tags[i], "bl_line_object", &c_Rev));
char* id; char* id;
AOM_ask_value_string(c_Rev, "item_id", &id); ITKCALL(AOM_ask_value_string(c_Rev, "item_id", &id));
//获取BOM行的REMARK //获取BOM行的REMARK
if (ret) { if (ret) {
AOM_ask_value_string(c_line_tags[i], "ZT2_Remark", &remark); ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_quantity", &bl_quantity));
AOM_ask_value_string(c_line_tags[i], "bl_quantity", &bl_quantity); ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_line_name", &bl_line_name));
AOM_ask_value_string(c_line_tags[i], "bl_line_name", &bl_line_name);
getRemarkMsg(remark, xsLen, errBuff, bl_quantity, itemId, id, bl_line_name); getRemarkMsg(remark, xsLen, errBuff, bl_quantity, itemId, id, bl_line_name);
} }
//新增逻辑 当前对象类型为ZT2_XNZJB 虚拟组件包时 进行削层处理 数量*虚拟层数量 //新增逻辑 当前对象类型为ZT2_XNZJB 虚拟组件包时 进行削层处理 数量*虚拟层数量
AOM_ask_value_string(c_Rev, "object_type", &c_type); ITKCALL(AOM_ask_value_string(c_Rev, "object_type", &c_type));
if (strcmp(c_type, "ZT2_XNZJBRevision") == 0) { if (strcmp(c_type, "ZT2_XNZJBRevision") == 0) {
xnzjbVec.push_back(c_line_tags[i]); xnzjbVec.push_back(c_line_tags[i]);
continue; continue;
} }
AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &seqNo); ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &seqNo));
maxSeqNo = seqNo; maxSeqNo = seqNo;
char* cUid; char* cUid;
ITK__convert_tag_to_uid(c_Rev, &cUid); ITK__convert_tag_to_uid(c_Rev, &cUid);
/*if (find(uidVec.begin(), uidVec.end(), cUid) != uidVec.end()) {
continue;
}
uidVec.push_back(cUid);*/
NodeBean cBean; NodeBean cBean;
cBean.revUid = cUid; cBean.revUid = cUid;
cBean.designRev = c_Rev; cBean.designRev = c_Rev;
cBean.remark = remark;
recyReadBom(c_line_tags[i], cBean, errBuff, dbName, loginUserId); recyReadBom(c_line_tags[i], cBean, errBuff, dbName, loginUserId);
pBean.childs.push_back(cBean); pBean.childs.push_back(cBean);
} }
@ -705,7 +817,7 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName
ITKCALL(AOM_ask_value_string(designRev, "object_name", &object_name)); ITKCALL(AOM_ask_value_string(designRev, "object_name", &object_name));
//printf("type===>%s\n", type); //printf("type===>%s\n", type);
if (strcmp(type, "ZT2_Design3DRevision") == 0) { if (strcmp(type, "ZT2_Design3DRevision") == 0) {
AOM_ask_value_string(designRev, "zt2_Diagram", &zt2_Diagram); ITKCALL(AOM_ask_value_string(designRev, "zt2_Diagram", &zt2_Diagram));
if (strcmp(zt2_Diagram, "Y") == 0 || strcmp(zt2_Diagram, "") == 0) { if (strcmp(zt2_Diagram, "Y") == 0 || strcmp(zt2_Diagram, "") == 0) {
return; return;
} }
@ -740,28 +852,28 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName
} }
} }
if (strstr(itemId, "1ZD") != NULL) { if (strstr(itemId, "1ZD") != NULL) {
AOM_ask_value_string(designRev, "zt2_Source", &source); ITKCALL(AOM_ask_value_string(designRev, "zt2_Source", &source));
if (strcmp(source, "S2") == 0 || strcmp(source, "外购") == 0) { if (strcmp(source, "S2") == 0 || strcmp(source, "外购") == 0) {
return; return;
} }
} }
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));
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
logical flag; logical flag;
BOM_line_is_packed(c_line_tags[i], &flag); ITKCALL(BOM_line_is_packed(c_line_tags[i], &flag));
if (flag) { if (flag) {
BOM_line_unpack(c_line_tags[i]); ITKCALL(BOM_line_unpack(c_line_tags[i]));
} }
} }
AOM_refresh(bom_line, FALSE); (AOM_refresh(bom_line, FALSE));*/
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 && !dbName.empty() && (strstr(itemId, "1ZD") != NULL || if (c_line_count == 0 && !dbName.empty() && (strstr(itemId, "1ZD") != NULL ||
strstr(itemId, "2ZD") != NULL || strstr(itemId, "4ZD") != NULL)) { strstr(itemId, "2ZD") != NULL || strstr(itemId, "4ZD") != NULL)) {
//原材料展开 //原材料展开
char *zt2_MaterialMark; char *zt2_MaterialMark;
AOM_ask_value_string(designRev, "zt2_MaterialMark", &zt2_MaterialMark); ITKCALL(AOM_ask_value_string(designRev, "zt2_MaterialMark", &zt2_MaterialMark));
//String zt2_MaterialMark = rev.getProperty("zt2_MaterialMark") //String zt2_MaterialMark = rev.getProperty("zt2_MaterialMark")
string sql = "select materialno, materialutilization, materialunit FROM %s where materialmark = '%s'"; string sql = "select materialno, materialutilization, materialunit FROM %s where materialmark = '%s'";
char selectRxfs[500]; char selectRxfs[500];
@ -785,8 +897,8 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName
string materialutilization = outputValue1[t][1]; string materialutilization = outputValue1[t][1];
string materialunit = outputValue1[t][2]; string materialunit = outputValue1[t][2];
tag_t material, materialRev; tag_t material, materialRev;
ITEM_find_item(materialno.c_str(), &material); ITKCALL(ITEM_find_item(materialno.c_str(), &material));
ITEM_ask_latest_rev(material, &materialRev); ITKCALL(ITEM_ask_latest_rev(material, &materialRev));
string bl_qty = getTyjZl(bom_line, materialutilization, designRev, errBuff); string bl_qty = getTyjZl(bom_line, materialutilization, designRev, errBuff);
printf("bl_qty%s\n", bl_qty.c_str()); printf("bl_qty%s\n", bl_qty.c_str());
NodeBean cBean; NodeBean cBean;
@ -794,50 +906,67 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName
cBean.bl_sequence_no = "10"; cBean.bl_sequence_no = "10";
cBean.bl_plmxml_occ_xform = ""; cBean.bl_plmxml_occ_xform = "";
cBean.mantr = materialRev; cBean.mantr = materialRev;
cBean.remark = "";
pBean.childs.push_back(cBean); pBean.childs.push_back(cBean);
} }
} }
string maxSeqNo; string maxSeqNo;
vector<tag_t> xnzjbVec; vector<tag_t> xnzjbVec;
vector<string> uidVec;
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
logical suppressed; logical suppressed;
AOM_ask_value_logical(c_line_tags[i], "bl_is_occ_suppressed", &suppressed); char *remark;
ITKCALL(AOM_ask_value_string(c_line_tags[i], "ZT2_Remark", &remark));
//printf("recyReadBom2:%s\n", remark);
ITKCALL(AOM_ask_value_logical(c_line_tags[i], "bl_is_occ_suppressed", &suppressed));
if (suppressed) { if (suppressed) {
continue; continue;
} }
//修改过之后之前已经是解包的状态了 //修改过之后之前已经是解包的状态了
logical flag; logical flag;
BOM_line_is_packed(c_line_tags[i], &flag); ITKCALL(BOM_line_is_packed(c_line_tags[i], &flag));
//printf("flag===>%d\n", flag); printf("flag2===>%d\n", flag);
if (flag) { if (flag) {
int count = 0; int count = 0;
char *topNum; char *topNum;
AOM_ask_value_string(c_line_tags[i], "bl_quantity", &topNum); ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_quantity", &topNum));
tag_t* packLines; tag_t* packLines;
BOM_line_ask_packed_lines(c_line_tags[i], &count, &packLines); ITKCALL(BOM_line_ask_packed_lines(c_line_tags[i], &count, &packLines));
for (int t = 0; t < count; t++) { printf("packLines:%d\n", count);
/*for (int t = 0; t < count; t++) {
tag_t c_Rev; tag_t c_Rev;
ITKCALL(AOM_ask_value_tag(packLines[t], "bl_line_object", &c_Rev)); ITKCALL(AOM_ask_value_tag(packLines[t], "bl_line_object", &c_Rev));
char* cUid; char* cUid;
ITK__convert_tag_to_uid(c_Rev, &cUid); ITK__convert_tag_to_uid(c_Rev, &cUid);
//打包
//if (find(uidVec.begin(), uidVec.end(), cUid) != uidVec.end()) {
// continue;
//}
//uidVec.push_back(cUid);
NodeBean cBean; NodeBean cBean;
cBean.revUid = cUid; cBean.revUid = cUid;
cBean.designRev = c_Rev; cBean.designRev = c_Rev;
cBean.packNum = count + 1; cBean.packNum = count + 1;
cBean.topNum = atoi(topNum); cBean.topNum = atoi(topNum);
cBean.remark = remark;
recyReadBom(c_line_tags[i], cBean, errBuff, dbName, idVector); recyReadBom(c_line_tags[i], cBean, errBuff, dbName, idVector);
pBean.childs.push_back(cBean); pBean.childs.push_back(cBean);
} }*/
AOM_refresh(c_line_tags[i], FALSE); AOM_refresh(c_line_tags[i], FALSE);
tag_t c_Rev; tag_t c_Rev;
ITKCALL(AOM_ask_value_tag(c_line_tags[i], "bl_line_object", &c_Rev)); ITKCALL(AOM_ask_value_tag(c_line_tags[i], "bl_line_object", &c_Rev));
char* cUid; char* cUid;
ITK__convert_tag_to_uid(c_Rev, &cUid); ITK__convert_tag_to_uid(c_Rev, &cUid);
/*if (find(uidVec.begin(), uidVec.end(), cUid) != uidVec.end()) {
continue;
}
uidVec.push_back(cUid);*/
NodeBean cBean; NodeBean cBean;
cBean.revUid = cUid; cBean.revUid = cUid;
cBean.designRev = c_Rev; cBean.designRev = c_Rev;
cBean.packNum = count + 1; cBean.packNum = count + 1;
cBean.topNum = atoi(topNum); cBean.topNum = atoi(topNum);
cBean.remark = remark;
recyReadBom(c_line_tags[i], cBean, errBuff, dbName, idVector); recyReadBom(c_line_tags[i], cBean, errBuff, dbName, idVector);
pBean.childs.push_back(cBean); pBean.childs.push_back(cBean);
@ -847,18 +976,23 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName
char *seqNo, *c_type; char *seqNo, *c_type;
ITKCALL(AOM_ask_value_tag(c_line_tags[i], "bl_line_object", &c_Rev)); ITKCALL(AOM_ask_value_tag(c_line_tags[i], "bl_line_object", &c_Rev));
//新增逻辑 当前对象类型为ZT2_XNZJB 虚拟组件包时 进行削层处理 数量*虚拟层数量 //新增逻辑 当前对象类型为ZT2_XNZJB 虚拟组件包时 进行削层处理 数量*虚拟层数量
AOM_ask_value_string(c_Rev, "object_type", &c_type); ITKCALL(AOM_ask_value_string(c_Rev, "object_type", &c_type));
if (strcmp(c_type, "ZT2_XNZJBRevision") == 0) { if (strcmp(c_type, "ZT2_XNZJBRevision") == 0) {
xnzjbVec.push_back(c_line_tags[i]); xnzjbVec.push_back(c_line_tags[i]);
continue; continue;
} }
AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &seqNo); ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &seqNo));
maxSeqNo = seqNo; maxSeqNo = seqNo;
char* cUid; char* cUid;
ITK__convert_tag_to_uid(c_Rev, &cUid); ITK__convert_tag_to_uid(c_Rev, &cUid);
/*if (find(uidVec.begin(), uidVec.end(), cUid) != uidVec.end()) {
continue;
}
uidVec.push_back(cUid);*/
NodeBean cBean; NodeBean cBean;
cBean.revUid = cUid; cBean.revUid = cUid;
cBean.designRev = c_Rev; cBean.designRev = c_Rev;
cBean.remark = remark;
recyReadBom(c_line_tags[i], cBean, errBuff, dbName, idVector); recyReadBom(c_line_tags[i], cBean, errBuff, dbName, idVector);
pBean.childs.push_back(cBean); pBean.childs.push_back(cBean);
} }
@ -889,7 +1023,7 @@ void getAllXnj(vector<tag_t> xnzjbVec, int maxNum, int &xxt,
ITKCALL(BOM_line_ask_all_child_lines(c_line_tag, &cc_line_count, &cc_line_tags)); ITKCALL(BOM_line_ask_all_child_lines(c_line_tag, &cc_line_count, &cc_line_tags));
char *cnt, *c_type; char *cnt, *c_type;
int qtyPXn = 1; int qtyPXn = 1;
AOM_ask_value_string(c_line_tag, "bl_quantity", &cnt); ITKCALL(AOM_ask_value_string(c_line_tag, "bl_quantity", &cnt));
if (strcmp(cnt, "") != 0) { if (strcmp(cnt, "") != 0) {
qtyPXn = atoi(cnt); qtyPXn = atoi(cnt);
} }
@ -897,11 +1031,13 @@ void getAllXnj(vector<tag_t> xnzjbVec, int maxNum, int &xxt,
vector<tag_t> xnzjbVec2; vector<tag_t> xnzjbVec2;
for (int j = 0; j < cc_line_count; j++) { for (int j = 0; j < cc_line_count; j++) {
tag_t c_Rev; tag_t c_Rev;
char *itemId, *object_name; char *itemId, *object_name, *remark;
ITKCALL(AOM_ask_value_tag(cc_line_tags[j], "bl_line_object", &c_Rev)); ITKCALL(AOM_ask_value_tag(cc_line_tags[j], "bl_line_object", &c_Rev));
AOM_ask_value_string(c_Rev, "object_type", &c_type); ITKCALL(AOM_ask_value_string(c_Rev, "object_type", &c_type));
AOM_ask_value_string(c_Rev, "item_id", &itemId); ITKCALL(AOM_ask_value_string(c_Rev, "item_id", &itemId));
AOM_ask_value_string(c_Rev, "object_name", &object_name); ITKCALL(AOM_ask_value_string(c_Rev, "object_name", &object_name));
ITKCALL(AOM_ask_value_string(cc_line_tags[j], "ZT2_Remark", &remark));
//printf("getAllXnj:%s\n", remark);
if (strcmp(c_type, "ZT2_XNZJBRevision") == 0) { if (strcmp(c_type, "ZT2_XNZJBRevision") == 0) {
printf("itemId===>%s\n", itemId); printf("itemId===>%s\n", itemId);
xnzjbVec2.push_back(cc_line_tags[j]); xnzjbVec2.push_back(cc_line_tags[j]);
@ -927,6 +1063,7 @@ void getAllXnj(vector<tag_t> xnzjbVec, int maxNum, int &xxt,
string lastnum = to_string(srqNum); string lastnum = to_string(srqNum);
xxt = xxt + 1; xxt = xxt + 1;
cBean.bl_sequence_no = lastnum; cBean.bl_sequence_no = lastnum;
cBean.remark = remark;
recyReadBom(cc_line_tags[j], cBean, errBuff, dbName, idVector); recyReadBom(cc_line_tags[j], cBean, errBuff, dbName, idVector);
pBean.childs.push_back(cBean); pBean.childs.push_back(cBean);
} }
@ -955,7 +1092,7 @@ void getAllXnj(vector<tag_t> xnzjbVec, int maxNum, int &xxt,
ITKCALL(BOM_line_ask_all_child_lines(c_line_tag, &cc_line_count, &cc_line_tags)); ITKCALL(BOM_line_ask_all_child_lines(c_line_tag, &cc_line_count, &cc_line_tags));
char *cnt, *c_type; char *cnt, *c_type;
int qtyPXn = 1; int qtyPXn = 1;
AOM_ask_value_string(c_line_tag, "bl_quantity", &cnt); ITKCALL(AOM_ask_value_string(c_line_tag, "bl_quantity", &cnt));
if (strcmp(cnt, "") != 0) { if (strcmp(cnt, "") != 0) {
//虚拟件的BOM数量 //虚拟件的BOM数量
qtyPXn = atoi(cnt); qtyPXn = atoi(cnt);
@ -964,11 +1101,13 @@ void getAllXnj(vector<tag_t> xnzjbVec, int maxNum, int &xxt,
vector<tag_t> xnzjbVec2; vector<tag_t> xnzjbVec2;
for (int j = 0; j < cc_line_count; j++) { for (int j = 0; j < cc_line_count; j++) {
tag_t c_Rev; tag_t c_Rev;
char *itemId, *object_name; char *itemId, *object_name, *remark;
ITKCALL(AOM_ask_value_tag(cc_line_tags[j], "bl_line_object", &c_Rev)); ITKCALL(AOM_ask_value_tag(cc_line_tags[j], "bl_line_object", &c_Rev));
AOM_ask_value_string(c_Rev, "object_type", &c_type); ITKCALL(AOM_ask_value_string(c_Rev, "object_type", &c_type));
AOM_ask_value_string(c_Rev, "item_id", &itemId); ITKCALL(AOM_ask_value_string(c_Rev, "item_id", &itemId));
AOM_ask_value_string(c_Rev, "object_name", &object_name); ITKCALL(AOM_ask_value_string(c_Rev, "object_name", &object_name));
ITKCALL(AOM_ask_value_string(cc_line_tags[j], "ZT2_Remark", &remark));
//printf("getAllXnj2:%s\n", remark);
if (strcmp(c_type, "ZT2_XNZJBRevision") == 0) { if (strcmp(c_type, "ZT2_XNZJBRevision") == 0) {
printf("itemId===>%s\n", itemId); printf("itemId===>%s\n", itemId);
xnzjbVec2.push_back(cc_line_tags[j]); xnzjbVec2.push_back(cc_line_tags[j]);
@ -994,6 +1133,7 @@ void getAllXnj(vector<tag_t> xnzjbVec, int maxNum, int &xxt,
string lastnum = to_string(srqNum); string lastnum = to_string(srqNum);
xxt = xxt + 1; xxt = xxt + 1;
cBean.bl_sequence_no = lastnum; cBean.bl_sequence_no = lastnum;
cBean.remark = remark;
//非虚拟件的继续原逻辑展开 //非虚拟件的继续原逻辑展开
recyReadBom(cc_line_tags[j], cBean, errBuff, dbName, loginUserId); recyReadBom(cc_line_tags[j], cBean, errBuff, dbName, loginUserId);
pBean.childs.push_back(cBean); pBean.childs.push_back(cBean);
@ -1025,13 +1165,13 @@ string GBKToUTF8(const std::string& strGBK)
string proProcessCreate(tag_t rev, string process_name) string proProcessCreate(tag_t rev, string process_name)
{ {
tag_t template_tag = NULLTAG; tag_t template_tag = NULLTAG;
EPM_find_template2(process_name.c_str(), PROCESS_TEMPLATE, &template_tag); ITKCALL(EPM_find_template2(process_name.c_str(), PROCESS_TEMPLATE, &template_tag));
tag_t new_process = NULLTAG; tag_t new_process = NULLTAG;
int *tagType = (int *)MEM_alloc(1024 * sizeof(int));//EPM_reference_attachment int *tagType = (int *)MEM_alloc(1024 * sizeof(int));//EPM_reference_attachment
tag_t * itemTag = (tag_t *)MEM_alloc(1024 * sizeof(tag_t)); tag_t * itemTag = (tag_t *)MEM_alloc(1024 * sizeof(tag_t));
tagType[0] = EPM_target_attachment; tagType[0] = EPM_target_attachment;
itemTag[0] = rev; itemTag[0] = rev;
EPM_create_process("¿ìËÙ·¢²¼", "", template_tag, 1, itemTag, tagType, &new_process); ITKCALL(EPM_create_process("快速发布", "", template_tag, 1, itemTag, tagType, &new_process));
return "1"; return "1";
} }
@ -1039,11 +1179,11 @@ boolean firstRevision(tag_t designRev, tag_t mantr) {
char *revId; char *revId;
int revNum = 0, statusNum = 0; int revNum = 0, statusNum = 0;
tag_t *structure_revisions; tag_t *structure_revisions;
AOM_ask_value_string(designRev, "item_revision_id", &revId); ITKCALL(AOM_ask_value_string(designRev, "item_revision_id", &revId));
AOM_ask_value_tags(mantr, "structure_revisions", &revNum, &structure_revisions); ITKCALL(AOM_ask_value_tags(mantr, "structure_revisions", &revNum, &structure_revisions));
if (revNum > 0) { if (revNum > 0) {
tag_t struct_revision = structure_revisions[0], *release_status_list; tag_t struct_revision = structure_revisions[0], *release_status_list;
AOM_ask_value_tags(struct_revision, "release_status_list", &statusNum, &release_status_list); ITKCALL(AOM_ask_value_tags(struct_revision, "release_status_list", &statusNum, &release_status_list));
if (statusNum == 0) { if (statusNum == 0) {
return false; return false;
} }
@ -1112,6 +1252,7 @@ map<string, int> getBomMsg(tag_t mantrRev, bool& flag) {
ITKCALL(AOM_ask_value_tag(c_line_tags[t], "bl_line_object", &c_Rev)); ITKCALL(AOM_ask_value_tag(c_line_tags[t], "bl_line_object", &c_Rev));
ITKCALL(AOM_ask_value_string(c_Rev, "zt2_MaterialNo", &matnrNo)); ITKCALL(AOM_ask_value_string(c_Rev, "zt2_MaterialNo", &matnrNo));
printf("zt2_MaterialNo===>%s\n", matnrNo); printf("zt2_MaterialNo===>%s\n", matnrNo);
int qtyPXn = 1; int qtyPXn = 1;
ITKCALL(AOM_ask_value_string(c_line_tags[t], "bl_quantity", &cnt)); ITKCALL(AOM_ask_value_string(c_line_tags[t], "bl_quantity", &cnt));
if (strcmp(cnt, "") != 0) { if (strcmp(cnt, "") != 0) {
@ -1240,8 +1381,11 @@ string createEbom(NodeBean topBean, boolean isTop, string &hasChange, map<string
ITKCALL(ITEM_rev_list_bom_view_revs(mantr, &bvr_count, &bvr_list)); ITKCALL(ITEM_rev_list_bom_view_revs(mantr, &bvr_count, &bvr_list));
//没有BOM视图创建 //没有BOM视图创建
POM_AM__set_application_bypass(true); POM_AM__set_application_bypass(true);
tag_t defGroup = NULLTAG, dsuser = NULLTAG;
ITKCALL(AOM_ask_value_tag(desBean, "owning_user", &dsuser));
ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup));
if (bvr_count == 0) { if (bvr_count == 0) {
tag_t newView, newViewBvr, pitem, dsuser; tag_t newView = NULLTAG, newViewBvr = NULLTAG, pitem = NULLTAG;
ITKCALL(ITEM_ask_item_of_rev(mantr, &pitem)); ITKCALL(ITEM_ask_item_of_rev(mantr, &pitem));
POM_AM__set_application_bypass(true); POM_AM__set_application_bypass(true);
ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView));
@ -1249,9 +1393,6 @@ string createEbom(NodeBean topBean, boolean isTop, string &hasChange, map<string
ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, mantr, &newViewBvr)); ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, mantr, &newViewBvr));
ITKCALL(AOM_save(newViewBvr)); ITKCALL(AOM_save(newViewBvr));
ITKCALL(AOM_save(mantr)); ITKCALL(AOM_save(mantr));
ITKCALL(AOM_ask_value_tag(desBean, "owning_user", &dsuser));
tag_t defGroup;
ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup));
ITKCALL(AOM_set_ownership(newView, dsuser, defGroup)); ITKCALL(AOM_set_ownership(newView, dsuser, defGroup));
ITKCALL(AOM_set_ownership(newViewBvr, dsuser, defGroup)); ITKCALL(AOM_set_ownership(newViewBvr, dsuser, defGroup));
} }
@ -1272,6 +1413,9 @@ string createEbom(NodeBean topBean, boolean isTop, string &hasChange, map<string
return errMsg; return errMsg;
} }
} }
else {
ITKCALL(AOM_set_ownership(bvr_list[0], dsuser, defGroup));
}
} }
if (flagChange) { if (flagChange) {
tag_t ebom_window = NULLTAG; tag_t ebom_window = NULLTAG;
@ -1293,16 +1437,17 @@ string createEbom(NodeBean topBean, boolean isTop, string &hasChange, map<string
for (int i = 0; i < childs.size(); i++) { for (int i = 0; i < childs.size(); i++) {
NodeBean cBean = childs[i]; NodeBean cBean = childs[i];
if (cBean.mantr != NULLTAG) { if (cBean.mantr != NULLTAG) {
tag_t cLine; tag_t cLine = NULLTAG;
char* bom_string = NULL; char* bom_string = NULL;
ITKCALL(AOM_ask_value_string(bom_line, "object_string", &bom_string)); ITKCALL(AOM_ask_value_string(cBean.mantr, "object_string", &bom_string));
printf("bom_line%s\n", bom_string); printf("bom_line%s\n", bom_string);
ITKCALL(BOM_line_add(bom_line, NULL, cBean.mantr, NULL, &cLine)); ITKCALL(BOM_line_add(bom_line, NULL, cBean.mantr, NULL, &cLine));
if (cLine != NULLTAG) { if (cLine != NULLTAG) {
AOM_lock(cLine); AOM_lock(cLine);
if (cBean.packNum > 0) { if (cBean.packNum > 0) {
string num = cBean.bl_quantity; //string num = cBean.bl_quantity;
num = to_string(cBean.topNum / cBean.packNum); string num = to_string(cBean.topNum);//cBean.topNum / cBean.packNum
printf("cBean.Num%d==%d\n", cBean.topNum, cBean.packNum);
ITKCALL(AOM_set_value_string(cLine, "bl_quantity", num.c_str())); ITKCALL(AOM_set_value_string(cLine, "bl_quantity", num.c_str()));
} }
else { else {
@ -1314,6 +1459,10 @@ string createEbom(NodeBean topBean, boolean isTop, string &hasChange, map<string
ITKCALL(AOM_set_value_string(cLine, "bl_plmxml_occ_xform", cBean.bl_plmxml_occ_xform)); ITKCALL(AOM_set_value_string(cLine, "bl_plmxml_occ_xform", cBean.bl_plmxml_occ_xform));
ITKCALL(AOM_set_value_string(cLine, "bl_sequence_no", cBean.bl_sequence_no.c_str())); ITKCALL(AOM_set_value_string(cLine, "bl_sequence_no", cBean.bl_sequence_no.c_str()));
ITKCALL(AOM_set_value_string(cLine, "bl_occ_zt2_DtoE", "DBOM转换")); ITKCALL(AOM_set_value_string(cLine, "bl_occ_zt2_DtoE", "DBOM转换"));
//char* gremark = U2G(cBean.remark.c_str());
//char* ugremark = G2U(cBean.remark.c_str());
printf("ZT2_Remark: %d %s\n", tc_strlen(cBean.remark.c_str()), cBean.remark.c_str());
ITKCALL(AOM_set_value_string(cLine, "ZT2_Remark", cBean.remark.c_str()));
(AOM_save(cLine)); (AOM_save(cLine));
//最后unlock //最后unlock
(AOM_unlock(cLine)); (AOM_unlock(cLine));
@ -1363,10 +1512,10 @@ void copyEBomLine(tag_t matnrTop, tag_t otherPbom) {
tag_t newView, newViewBvr, pitem; tag_t newView, newViewBvr, pitem;
ITKCALL(ITEM_ask_item_of_rev(otherPbom, &pitem)); ITKCALL(ITEM_ask_item_of_rev(otherPbom, &pitem));
ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView));
ITKCALL(AOM_save(newView)); (AOM_save(newView));
ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, otherPbom, &newViewBvr)); ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, otherPbom, &newViewBvr));
ITKCALL(AOM_save(newViewBvr)); (AOM_save(newViewBvr));
ITKCALL(AOM_save(otherPbom)); (AOM_save(otherPbom));
int num = 0; int num = 0;
tag_t dsuser, *structure_revisions, *bom_view_tags, *mantrs; tag_t dsuser, *structure_revisions, *bom_view_tags, *mantrs;
ITKCALL(AOM_ask_value_tags(otherPbom, "TC_Is_Represented_By", &num, &mantrs)); ITKCALL(AOM_ask_value_tags(otherPbom, "TC_Is_Represented_By", &num, &mantrs));
@ -1387,14 +1536,18 @@ void copyEBomLine(tag_t matnrTop, tag_t otherPbom) {
ITKCALL(BOM_line_cut(c_line_tags2[i])); ITKCALL(BOM_line_cut(c_line_tags2[i]));
} }
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
tag_t newChild; char *bl_seqNo; tag_t newChild = NULLTAG;
char *bl_seqNo = NULL, *ZT2_Remark = NULL;
ITKCALL(BOM_line_copy(bom_line2, c_line_tags[i], NULLTAG, &newChild)); ITKCALL(BOM_line_copy(bom_line2, c_line_tags[i], NULLTAG, &newChild));
ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &bl_seqNo)); ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &bl_seqNo));
ITKCALL(AOM_lock(newChild)); ITKCALL(AOM_ask_value_string(c_line_tags[i], "ZT2_Remark", &ZT2_Remark));
printf("ZT2_Remark:%s\n", ZT2_Remark);
(AOM_lock(newChild));
ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", bl_seqNo)); ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", bl_seqNo));
ITKCALL(AOM_save(newChild)); ITKCALL(AOM_set_value_string(newChild, "ZT2_Remark", ZT2_Remark));
(AOM_save(newChild));
//最后unlock //最后unlock
ITKCALL(AOM_unlock(newChild)); (AOM_unlock(newChild));
} }
//tag_t newChild; //tag_t newChild;
//ITKCALL(BOM_line_copy(bom_line2, c_line_tags[i], NULLTAG, &newChild)); //ITKCALL(BOM_line_copy(bom_line2, c_line_tags[i], NULLTAG, &newChild));
@ -1466,6 +1619,7 @@ int getClassValByTop(tag_t item, string& errMessage) {
* DBOMEBOM * DBOMEBOM
*/ */
int DbomToEMethod(void* returnValue) { int DbomToEMethod(void* returnValue) {
auto start = std::chrono::high_resolution_clock::now();
int ifail = ITK_ok; int ifail = ITK_ok;
char *sql = NULL, *revUid; char *sql = NULL, *revUid;
tag_t designRev, item; tag_t designRev, item;
@ -1511,6 +1665,9 @@ int DbomToEMethod(void* returnValue) {
printf("提示:中间数据表访问失败\n"); printf("提示:中间数据表访问失败\n");
ifail = 1; ifail = 1;
} }
auto time1 = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = time1 - start;
printf("time1%f\n", elapsed.count());
string dbName; string dbName;
int url_num2 = 0; int url_num2 = 0;
char** url_vals2 = NULL; char** url_vals2 = NULL;
@ -1529,6 +1686,9 @@ int DbomToEMethod(void* returnValue) {
recyReadBom(bom_line, topBean, errBuff, dbName, loginUserId); recyReadBom(bom_line, topBean, errBuff, dbName, loginUserId);
DisConnServer(); DisConnServer();
ITKCALL(BOM_close_window(ebom_window)); ITKCALL(BOM_close_window(ebom_window));
auto time2 = std::chrono::high_resolution_clock::now();
elapsed = time2 - start;
printf("time2%f\n", elapsed.count());
//搭建BOM //搭建BOM
POM_AM__set_application_bypass(true); POM_AM__set_application_bypass(true);
printf("error %s \n", errBuff.c_str()); printf("error %s \n", errBuff.c_str());
@ -1572,6 +1732,7 @@ int DbomToEMethod(void* returnValue) {
printf("dMap[%d]", dMap.size());*/ printf("dMap[%d]", dMap.size());*/
map<string, int> dMap = getDBomMesg(topBean); map<string, int> dMap = getDBomMesg(topBean);
for (int t = 0; t < topBean.ccps.size(); t++) { for (int t = 0; t < topBean.ccps.size(); t++) {
auto sub = std::chrono::high_resolution_clock::now();
tag_t mantr = topBean.ccps[t]; tag_t mantr = topBean.ccps[t];
boolean flagChange = true; boolean flagChange = true;
bool flag = false; bool flag = false;
@ -1620,6 +1781,9 @@ int DbomToEMethod(void* returnValue) {
ITKCALL(ITEM_ask_latest_rev(topItem, &topRev)); ITKCALL(ITEM_ask_latest_rev(topItem, &topRev));
copyEBomLine(topRev, mantr); copyEBomLine(topRev, mantr);
} }
auto sub1 = std::chrono::high_resolution_clock::now();
elapsed = sub1 - sub;
printf("sub1%f\n", elapsed.count());
} }
} }
errBuff = "succ"; errBuff = "succ";
@ -1633,6 +1797,10 @@ int DbomToEMethod(void* returnValue) {
close(); close();
printf("释放数据库成功\n"); printf("释放数据库成功\n");
printf("子line数量 %d \n", topBean.childs.size()); printf("子line数量 %d \n", topBean.childs.size());
// 计算时间间隔
auto end = std::chrono::high_resolution_clock::now();
elapsed = end - start;
printf("用时:%f\n", elapsed.count());
string buff = errBuff; string buff = errBuff;
*((char**)returnValue) = (char*)MEM_alloc((strlen(buff.c_str()) + 1) * sizeof(char)); *((char**)returnValue) = (char*)MEM_alloc((strlen(buff.c_str()) + 1) * sizeof(char));
tc_strcpy(*((char**)returnValue), buff.c_str()); tc_strcpy(*((char**)returnValue), buff.c_str());
@ -1643,6 +1811,7 @@ int DbomToEMethod(void* returnValue) {
* DE * DE
*/ */
int DbomToEMethodUser(void* returnValue) { int DbomToEMethodUser(void* returnValue) {
auto start = std::chrono::high_resolution_clock::now();
int ifail = ITK_ok; int ifail = ITK_ok;
char *sql = NULL, *revUid; char *sql = NULL, *revUid;
tag_t designRev; tag_t designRev;
@ -1660,13 +1829,16 @@ int DbomToEMethodUser(void* returnValue) {
tag_t ebom_window = NULLTAG; tag_t ebom_window = NULLTAG;
tag_t bom_line = NULLTAG; tag_t bom_line = NULLTAG;
tag_t item_tag = NULLTAG, *c_line_tags; tag_t item_tag = NULLTAG, *c_line_tags;
(BOM_create_window(&ebom_window)); ITKCALL(BOM_create_window(&ebom_window));
tag_t* bvr_list = NULL; tag_t* bvr_list = NULL;
(ITEM_rev_list_bom_view_revs(designRev, &bvr_count, &bvr_list)); ITKCALL(ITEM_rev_list_bom_view_revs(designRev, &bvr_count, &bvr_list));
printf("bvr_count=%d", bvr_count); printf("bvr_count=%d", bvr_count);
(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //¶¥²ãbom»ñÈ¡ ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取
printf("顶层bom获取\n"); printf("顶层bom获取\n");
auto bomtime = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = bomtime - start;
printf("bomtime%f\n", elapsed.count());
//(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); //(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags));
NodeBean topBean; NodeBean topBean;
@ -1675,7 +1847,7 @@ int DbomToEMethodUser(void* returnValue) {
int url_num = 0; int url_num = 0;
char** url_vals = NULL; char** url_vals = NULL;
PREF_ask_char_values("database_tc", &url_num, &url_vals); ITKCALL(PREF_ask_char_values("database_tc", &url_num, &url_vals));
string url = url_vals[0]; string url = url_vals[0];
url.append("/").append(url_vals[2]); url.append("/").append(url_vals[2]);
@ -1686,10 +1858,13 @@ int DbomToEMethodUser(void* returnValue) {
printf("提示:中间数据表访问失败\n"); printf("提示:中间数据表访问失败\n");
ifail = 1; ifail = 1;
} }
auto ConnServer = std::chrono::high_resolution_clock::now();
elapsed = ConnServer - start;
printf("ConnServer%f\n", elapsed.count());
string dbName; string dbName;
int url_num2 = 0, url_num3 = 0; int url_num2 = 0, url_num3 = 0;
char** url_vals2 = NULL, **url_vals3 = NULL; char** url_vals2 = NULL, **url_vals3 = NULL;
PREF_ask_char_values("CHINT_MATERIAL_RAW", &url_num2, &url_vals2); ITKCALL(PREF_ask_char_values("CHINT_MATERIAL_RAW", &url_num2, &url_vals2));
for (int t = 0; t < url_num2; t++) { for (int t = 0; t < url_num2; t++) {
vector<string> vec; vector<string> vec;
Split(url_vals2[t], ":", vec); Split(url_vals2[t], ":", vec);
@ -1698,15 +1873,21 @@ int DbomToEMethodUser(void* returnValue) {
} }
} }
//配置哪些ID类别需要D转E //配置哪些ID类别需要D转E
PREF_ask_char_values("CHINT_M060_KJTOSAP", &url_num3, &url_vals3); ITKCALL(PREF_ask_char_values("CHINT_M060_KJTOSAP", &url_num3, &url_vals3));
vector<string> idVector; vector<string> idVector;
if (url_num3 > 0) { if (url_num3 > 0) {
Split(url_vals3[0], ";", idVector); Split(url_vals3[0], ";", idVector);
} }
auto time1 = std::chrono::high_resolution_clock::now();
elapsed = time1 - start;
printf("time1%f\n", elapsed.count());
recyReadBom(bom_line, topBean, errBuff, dbName, idVector); recyReadBom(bom_line, topBean, errBuff, dbName, idVector);
auto time2 = std::chrono::high_resolution_clock::now();
elapsed = time2 - start;
printf("time2%f\n", elapsed.count());
DisConnServer(); DisConnServer();
BOM_close_window(ebom_window); ITKCALL(BOM_close_window(ebom_window));
//搭建BOM //搭建BOM
POM_AM__set_application_bypass(true); POM_AM__set_application_bypass(true);
printf("error %s \n", errBuff.c_str()); printf("error %s \n", errBuff.c_str());
@ -1725,6 +1906,9 @@ int DbomToEMethodUser(void* returnValue) {
} }
errBuff = "succ"; errBuff = "succ";
} }
auto time3 = std::chrono::high_resolution_clock::now();
elapsed = time3 - start;
printf("time3%f\n", elapsed.count());
POM_AM__set_application_bypass(false); POM_AM__set_application_bypass(false);

@ -32,6 +32,7 @@
#include <sa/tcfile.h> #include <sa/tcfile.h>
#include <ss/ss_errors.h> #include <ss/ss_errors.h>
#include <ae/datasettype.h> #include <ae/datasettype.h>
#include <chrono>
// #include "hx_custom.h" // #include "hx_custom.h"
#include "tc_log.h" #include "tc_log.h"
// #include "jk_custom.h" // #include "jk_custom.h"
@ -159,7 +160,7 @@ void saveAsCycle(EBomBean& childPm, map<string, tag_t>& map, tag_t& topPrev) {
char* newid = NULL; char* newid = NULL;
logical isModified = FALSE; logical isModified = FALSE;
tag_t item_type_tag; tag_t item_type_tag;
TCTYPE_ask_type("Item", &item_type_tag); ITKCALL(TCTYPE_ask_type("Item", &item_type_tag));
ITKCALL(USER_new_item_id(NULLTAG, item_type_tag, &isModified, &newid)); ITKCALL(USER_new_item_id(NULLTAG, item_type_tag, &isModified, &newid));
/*ITKCALL(NR_next_value("MEProcess", "item_id", NULLTAG, "", "", "", /*ITKCALL(NR_next_value("MEProcess", "item_id", NULLTAG, "", "", "",
NULLTAG, "", "", &next_id));*/ NULLTAG, "", "", &next_id));*/
@ -167,11 +168,11 @@ void saveAsCycle(EBomBean& childPm, map<string, tag_t>& map, tag_t& topPrev) {
ITKCALL(ITEM_copy_item(childPm.eRev, newid, NULL, &newItem, &newRev)); ITKCALL(ITEM_copy_item(childPm.eRev, newid, NULL, &newItem, &newRev));
//ITKCALL(AOM_set_value_string(newRev, "zt2_PMaterial", "PBOM")); //ITKCALL(AOM_set_value_string(newRev, "zt2_PMaterial", "PBOM"));
char* matnrNo; char* matnrNo;
AOM_ask_value_string(childPm.eRev, "zt2_MaterialNo", &matnrNo); ITKCALL(AOM_ask_value_string(childPm.eRev, "zt2_MaterialNo", &matnrNo));
AOM_lock(newRev); AOM_lock(newRev);
AOM_set_value_string(newRev, "zt2_ifpbom", "P"); ITKCALL(AOM_set_value_string(newRev, "zt2_ifpbom", "P"));
AOM_set_value_string(newRev, "zt2_MaterialNo", matnrNo); ITKCALL(AOM_set_value_string(newRev, "zt2_MaterialNo", matnrNo));
AOM_save(newRev); AOM_save(newRev);
AOM_unlock(newRev); AOM_unlock(newRev);
if (topPrev == NULLTAG) { if (topPrev == NULLTAG) {
@ -181,11 +182,11 @@ void saveAsCycle(EBomBean& childPm, map<string, tag_t>& map, tag_t& topPrev) {
map[eRevUid] = newRev; map[eRevUid] = newRev;
int num = 0, revNum = 0, tagNum = 0; int num = 0, revNum = 0, tagNum = 0;
tag_t* mantrs, dsuser, *structure_revisions, *bom_view_tags; tag_t* mantrs, dsuser, *structure_revisions, *bom_view_tags;
AOM_ask_value_tags(childPm.eRev, "TC_Is_Represented_By", &num, &mantrs); ITKCALL(AOM_ask_value_tags(childPm.eRev, "TC_Is_Represented_By", &num, &mantrs));
if (num > 0) { if (num > 0) {
AOM_ask_value_tags(newRev, "structure_revisions", &revNum, &structure_revisions); ITKCALL(AOM_ask_value_tags(newRev, "structure_revisions", &revNum, &structure_revisions));
AOM_ask_value_tags(newRev, "bom_view_tags", &tagNum, &bom_view_tags); ITKCALL(AOM_ask_value_tags(newRev, "bom_view_tags", &tagNum, &bom_view_tags));
AOM_ask_value_tag(mantrs[0], "owning_user", &dsuser); ITKCALL(AOM_ask_value_tag(mantrs[0], "owning_user", &dsuser));
tag_t defGroup; tag_t defGroup;
ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup));
ITKCALL(AOM_set_ownership(newItem, dsuser, defGroup)); ITKCALL(AOM_set_ownership(newItem, dsuser, defGroup));
@ -207,18 +208,18 @@ void saveAsCycle(EBomBean& childPm, map<string, tag_t>& map, tag_t& topPrev) {
int bvr_count = 0, c_line_count; int bvr_count = 0, c_line_count;
tag_t ebom_window = NULLTAG; tag_t ebom_window = NULLTAG;
tag_t bom_line = NULLTAG, *c_line_tags; tag_t bom_line = NULLTAG, *c_line_tags;
(BOM_create_window(&ebom_window)); ITKCALL(BOM_create_window(&ebom_window));
tag_t* bvr_list = NULL; tag_t* bvr_list = NULL;
(ITEM_rev_list_bom_view_revs(pRevs[0], &bvr_count, &bvr_list)); ITKCALL(ITEM_rev_list_bom_view_revs(pRevs[0], &bvr_count, &bvr_list));
printf("bvr_count=%d\n", bvr_count); printf("bvr_count=%d\n", bvr_count);
(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //땅꿔bom삿혤 ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取
//ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &mantr)); //ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &mantr));
ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags));
for (int ind = 0; ind < c_line_count; ind++) { for (int ind = 0; ind < c_line_count; ind++) {
tag_t c_line_tag = c_line_tags[ind], mantr; tag_t c_line_tag = c_line_tags[ind], mantr;
AOM_ask_value_tag(c_line_tag, "bl_line_object", &mantr); ITKCALL(AOM_ask_value_tag(c_line_tag, "bl_line_object", &mantr));
char* eRevUid2; char* eRevUid2;
ITK__convert_tag_to_uid(mantr, &eRevUid2); ITK__convert_tag_to_uid(mantr, &eRevUid2);
if (strcmp(eRevUid2, eRevUid) == 0) { if (strcmp(eRevUid2, eRevUid) == 0) {
@ -228,8 +229,8 @@ void saveAsCycle(EBomBean& childPm, map<string, tag_t>& map, tag_t& topPrev) {
} }
} }
} }
BOM_save_window(ebom_window); ITKCALL(BOM_save_window(ebom_window));
BOM_close_window(ebom_window); ITKCALL(BOM_close_window(ebom_window));
} }
} }
} }
@ -238,10 +239,10 @@ void getSpecs(tag_t rev, vector<string> &vec) {
int cnt; int cnt;
/*AOM_ask_value_string(line, "ZT2_TYSpecifications", &ZT2_TYSpecifications); /*AOM_ask_value_string(line, "ZT2_TYSpecifications", &ZT2_TYSpecifications);
if (strcmp(ZT2_TYSpecifications, "") == 0) {*/ if (strcmp(ZT2_TYSpecifications, "") == 0) {*/
AOM_ask_value_tags(rev, "representation_for", &cnt, &comps); ITKCALL(AOM_ask_value_tags(rev, "representation_for", &cnt, &comps));
char* zt2_Specifications; char* zt2_Specifications;
//if (cnt == 0) { //if (cnt == 0) {
AOM_ask_value_string(rev, "zt2_Specifications", &zt2_Specifications); ITKCALL(AOM_ask_value_string(rev, "zt2_Specifications", &zt2_Specifications));
vec.push_back(zt2_Specifications); vec.push_back(zt2_Specifications);
// //} // //}
//} //}
@ -416,7 +417,7 @@ tag_t send1(tag_t rev, string now,
ITKCALL(AOM_set_value_string(newRev, "zt2_ClassificationCode", "230101001")); ITKCALL(AOM_set_value_string(newRev, "zt2_ClassificationCode", "230101001"));
char* zt2_unit, *newUid; char* zt2_unit, *newUid;
ITK__convert_tag_to_uid(newRev, &newUid); ITK__convert_tag_to_uid(newRev, &newUid);
ITEM_ask_item_of_rev(rev, &pitem); ITKCALL(ITEM_ask_item_of_rev(rev, &pitem));
ITKCALL(AOM_ask_value_string(pitem, "zt2_unit", &zt2_unit)); ITKCALL(AOM_ask_value_string(pitem, "zt2_unit", &zt2_unit));
ITKCALL(AOM_set_value_string(newItem, "zt2_unit", zt2_unit)); ITKCALL(AOM_set_value_string(newItem, "zt2_unit", zt2_unit));
@ -488,7 +489,7 @@ void addToAmatnr(tag_t *c_line_tags, int c_line_count, int len, tag_t newPAmatnr
ITKCALL(ITEM_rev_list_bom_view_revs(mantr, &bvr_count, &bvr_list)); ITKCALL(ITEM_rev_list_bom_view_revs(mantr, &bvr_count, &bvr_list));
if (bvr_count == 0) { if (bvr_count == 0) {
tag_t newView, newViewBvr, pitem; tag_t newView, newViewBvr, pitem;
ITEM_ask_item_of_rev(mantr, &pitem); ITKCALL(ITEM_ask_item_of_rev(mantr, &pitem));
ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView));
AOM_save(newView); AOM_save(newView);
ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, mantr, &newViewBvr)); ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, mantr, &newViewBvr));
@ -499,33 +500,33 @@ void addToAmatnr(tag_t *c_line_tags, int c_line_count, int len, tag_t newPAmatnr
ITKCALL(BOM_create_window(&ebom_window)); ITKCALL(BOM_create_window(&ebom_window));
ITKCALL(BOM_set_window_top_line(ebom_window, NULL, mantr, NULLTAG, &bom_line)); ITKCALL(BOM_set_window_top_line(ebom_window, NULL, mantr, NULLTAG, &bom_line));
char *name; char *name;
AOM_ask_value_string(mantr,"object_name",&name); ITKCALL(AOM_ask_value_string(mantr,"object_name",&name));
string xqType = getXqName(name); //ABCDE string xqType = getXqName(name); //ABCDE
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
tag_t newChild; tag_t newChild;
char* oldQty,*seqNo,*remark,*bl_line_name; char* oldQty,*seqNo,*remark,*bl_line_name;
AOM_ask_value_string(c_line_tags[i], "ZT2_Remark", &remark); ITKCALL(AOM_ask_value_string(c_line_tags[i], "ZT2_Remark", &remark));
string msg = getRemarkMsg(remark,len); string msg = getRemarkMsg(remark,len);
int xqLen = len; int xqLen = len;
if (msg.length()>0) { if (msg.length()>0) {
xqLen = msg.length(); xqLen = msg.length();
if (strstr(msg.c_str(), xqType.c_str())==NULL) { if (tc_strstr(msg.c_str(), xqType.c_str()) == NULL) {
continue; continue;
} }
} }
ITKCALL(BOM_line_copy(bom_line, c_line_tags[i], NULLTAG, &newChild)); ITKCALL(BOM_line_copy(bom_line, c_line_tags[i], NULLTAG, &newChild));
AOM_ask_value_string(c_line_tags[i], "bl_quantity", &oldQty); ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_quantity", &oldQty));
AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &seqNo); ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &seqNo));
AOM_ask_value_string(c_line_tags[i], "bl_line_name", &bl_line_name); ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_line_name", &bl_line_name));
if (lastFlag && strstr(bl_line_name, "线") != NULL) { if (lastFlag && strstr(bl_line_name, "线") != NULL) {
double blQty = atof(oldQty); double blQty = atof(oldQty);
int num = blQty / xqLen; int num = blQty / xqLen;
double fmodVal = fmod(blQty, xqLen); double fmodVal = fmod(blQty, xqLen);
double lastVal = num + fmodVal; double lastVal = num + fmodVal;
string numNew = to_string(lastVal); string numNew = to_string(lastVal);
AOM_lock(newChild); (AOM_lock(newChild));
AOM_set_value_string(newChild, "bl_quantity", numNew.c_str()); ITKCALL(AOM_set_value_string(newChild, "bl_quantity", numNew.c_str()));
AOM_set_value_string(newChild, "bl_sequence_no", seqNo); ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", seqNo));
AOM_save(newChild); AOM_save(newChild);
AOM_unlock(newChild); AOM_unlock(newChild);
} }
@ -534,8 +535,8 @@ void addToAmatnr(tag_t *c_line_tags, int c_line_count, int len, tag_t newPAmatnr
int num = blQty / xqLen; int num = blQty / xqLen;
string numNew = to_string(num); string numNew = to_string(num);
AOM_lock(newChild); AOM_lock(newChild);
AOM_set_value_string(newChild, "bl_quantity", numNew.c_str()); ITKCALL(AOM_set_value_string(newChild, "bl_quantity", numNew.c_str()));
AOM_set_value_string(newChild, "bl_sequence_no", seqNo); ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", seqNo));
AOM_save(newChild); AOM_save(newChild);
AOM_unlock(newChild); AOM_unlock(newChild);
} }
@ -645,8 +646,20 @@ void replaceBom(EBomBean& childPm, map<string, tag_t>& map, int len, tag_t dcpro
ITKCALL(BOM_line_cut(c_line_tags[i])); ITKCALL(BOM_line_cut(c_line_tags[i]));
} }
for (int t = 0; t < newPAmatnrs.size(); t++) { for (int t = 0; t < newPAmatnrs.size(); t++) {
tag_t bomLineAdd; tag_t bomLineAdd = NULLTAG;
ITKCALL(BOM_line_add(bom_line, NULLTAG, newPAmatnrs[t], NULLTAG, &bomLineAdd)); ITKCALL(BOM_line_add(bom_line, NULLTAG, newPAmatnrs[t], NULLTAG, &bomLineAdd));
char *name = NULL;
ITKCALL(AOM_ask_value_string(newPAmatnrs[t], "object_name", &name));
string seqNo = "";
if (tc_strstr(name, "A相") != NULL) {
seqNo = "10";
}else if (tc_strstr(name, "B相") != NULL) {
seqNo = "20";
}
else if(tc_strstr(name, "C相") != NULL) {
seqNo = "30";
}
ITKCALL(AOM_set_value_string(bomLineAdd, "bl_sequence_no", seqNo.c_str()));
} }
//ITKCALL(AOM_save(bom_line)); //ITKCALL(AOM_save(bom_line));
ITKCALL(BOM_save_window(ebom_window)); ITKCALL(BOM_save_window(ebom_window));
@ -664,7 +677,7 @@ void replaceBom(EBomBean& childPm, map<string, tag_t>& map, int len, tag_t dcpro
//获取分类属性 判断是否整除 //获取分类属性 判断是否整除
int getClassVal2(tag_t topItem, string& errMessage) { int getClassVal2(tag_t topItem, string& errMessage) {
tag_t top_classificationObject; tag_t top_classificationObject;
ICS_ask_classification_object(topItem, &top_classificationObject); ITKCALL(ICS_ask_classification_object(topItem, &top_classificationObject));
if (top_classificationObject == NULL_TAG) if (top_classificationObject == NULL_TAG)
{ {
errMessage.append("顶层对象没有发送到分类\n"); errMessage.append("顶层对象没有发送到分类\n");
@ -739,9 +752,9 @@ void recyReadEBom(tag_t pLine, EBomBean parentBean, vector<EBomBean>& beans, int
errBuff.append("物料:").append(pRevId).append("/").append(name).append("已封存无法转换PBOM.\n"); errBuff.append("物料:").append(pRevId).append("/").append(name).append("已封存无法转换PBOM.\n");
//return; //return;
} }
AOM_ask_value_strings(pErev, "zt2_SZProcuretype", &cnt3, &procureType); //관벵菱齡 ITKCALL(AOM_ask_value_strings(pErev, "zt2_SZProcuretype", &cnt3, &procureType)); //包含自制
AOM_ask_value_strings(pErev, "zt2_SZSealedornot", &cnt2, &sealeds); ITKCALL(AOM_ask_value_strings(pErev, "zt2_SZSealedornot", &cnt2, &sealeds));
AOM_ask_value_strings(pErev, "zt2_SZFactory", &numFac, &factorys); ITKCALL(AOM_ask_value_strings(pErev, "zt2_SZFactory", &numFac, &factorys));
boolean flagWh = false; boolean flagWh = false;
//检查物料是否符合条件 //检查物料是否符合条件
for (int i = 0; i < numFac; i++) { for (int i = 0; i < numFac; i++) {
@ -774,31 +787,31 @@ void recyReadEBom(tag_t pLine, EBomBean parentBean, vector<EBomBean>& beans, int
ITKCALL(AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs)); ITKCALL(AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs));
if (num > 0) { if (num > 0) {
char* id; char* id;
AOM_ask_value_string(mantrs[0], "item_id", &id); ITKCALL(AOM_ask_value_string(mantrs[0], "item_id", &id));
string item_id = id; string item_id = id;
smatch result;//regex qq_reg("^1ZDB5.*\\d{1,}1000X.*"); smatch result;//regex qq_reg("^1ZDB5.*\\d{1,}1000X.*");
bool ret = regex_match(item_id, result, qq_reg); bool ret = regex_match(item_id, result, qq_reg);
if (ret) { if (ret) {
char *zt2_ifpbom; char *zt2_ifpbom;
AOM_ask_value_string(eRev, "zt2_ifpbom", &zt2_ifpbom); ITKCALL(AOM_ask_value_string(eRev, "zt2_ifpbom", &zt2_ifpbom));
if (zt2_ifpbom != NULL && strcmp(zt2_ifpbom, "P") == 0) { if (zt2_ifpbom != NULL && strcmp(zt2_ifpbom, "P") == 0) {
continue; continue;
} }
int cc_cnt; int cc_cnt;
tag_t* cc_lines; tag_t* cc_lines;
BOM_line_ask_all_child_lines(c_line_tag, &cc_cnt, &cc_lines); ITKCALL(BOM_line_ask_all_child_lines(c_line_tag, &cc_cnt, &cc_lines));
//线圈下对象检查是否可以整除 取总装图分类属性线圈项数 新增逻辑 拆解ZT2_Remark上包含ABC的 //线圈下对象检查是否可以整除 取总装图分类属性线圈项数 新增逻辑 拆解ZT2_Remark上包含ABC的
//12.4新增 物料下子件名称带 线 的11.3 分成335.3 //12.4新增 物料下子件名称带 线 的11.3 分成335.3
for (int tt = 0; tt < cc_cnt; tt++) { for (int tt = 0; tt < cc_cnt; tt++) {
tag_t cc_line = cc_lines[tt], c_eRev; tag_t cc_line = cc_lines[tt], c_eRev;
char* bl_quantity, *pId, *c_pId,*remark,*bl_line_name; char* bl_quantity, *pId, *c_pId,*remark,*bl_line_name;
AOM_ask_value_string(eRev, "item_id", &pId); ITKCALL(AOM_ask_value_string(eRev, "item_id", &pId));
AOM_ask_value_string(cc_line, "bl_quantity", &bl_quantity); ITKCALL(AOM_ask_value_string(cc_line, "bl_quantity", &bl_quantity));
AOM_ask_value_string(cc_line, "ZT2_Remark", &remark); ITKCALL(AOM_ask_value_string(cc_line, "ZT2_Remark", &remark));
AOM_ask_value_string(cc_line, "bl_line_name", &bl_line_name); ITKCALL(AOM_ask_value_string(cc_line, "bl_line_name", &bl_line_name));
ITKCALL(AOM_ask_value_tag(cc_line, "bl_line_object", &c_eRev)); ITKCALL(AOM_ask_value_tag(cc_line, "bl_line_object", &c_eRev));
AOM_ask_value_string(c_eRev, "item_id", &c_pId); ITKCALL(AOM_ask_value_string(c_eRev, "item_id", &c_pId));
printf("c_pId===> %s bl_quantity ==> %s len==> %d \n", c_pId, bl_quantity, len); printf("c_pId===> %s bl_quantity ==> %s len==> %d \n", c_pId, bl_quantity, len);
if (strcmp("bl_quantity", "") == 0) { if (strcmp("bl_quantity", "") == 0) {
errBuff.append("P类物料:").append(pId).append("下子件").append(c_pId) errBuff.append("P类物料:").append(pId).append("下子件").append(c_pId)
@ -856,7 +869,7 @@ tag_t findDcUser() {
} }
int cnt; int cnt;
char** qry_entries1, **qry_values2; char** qry_entries1, **qry_values2;
QRY_find_user_entries(query, &cnt, &qry_entries1, &qry_values2); ITKCALL(QRY_find_user_entries(query, &cnt, &qry_entries1, &qry_values2));
char * qry_values[1] = { "dcproxy" }; char * qry_values[1] = { "dcproxy" };
int n_found; int n_found;
ITKCALL(QRY_execute(query, 1, qry_entries1, qry_values, &n_found, &tags)); ITKCALL(QRY_execute(query, 1, qry_entries1, qry_values, &n_found, &tags));
@ -1003,7 +1016,7 @@ tag_t saveAsUpdate(tag_t eRev, char *uid, tag_t pLine) {
char* newid = NULL; char* newid = NULL;
logical isModified = FALSE; logical isModified = FALSE;
tag_t item_type_tag, newItem, newRev; tag_t item_type_tag, newItem, newRev;
TCTYPE_ask_type("Item", &item_type_tag); ITKCALL(TCTYPE_ask_type("Item", &item_type_tag));
ITKCALL(USER_new_item_id(NULLTAG, item_type_tag, &isModified, &newid)); ITKCALL(USER_new_item_id(NULLTAG, item_type_tag, &isModified, &newid));
/*ITKCALL(NR_next_value("MEProcess", "item_id", NULLTAG, "", "", "", /*ITKCALL(NR_next_value("MEProcess", "item_id", NULLTAG, "", "", "",
NULLTAG, "", "", &next_id));*/ NULLTAG, "", "", &next_id));*/
@ -1011,21 +1024,21 @@ tag_t saveAsUpdate(tag_t eRev, char *uid, tag_t pLine) {
ITKCALL(ITEM_copy_item(eRev, newid, NULL, &newItem, &newRev)); ITKCALL(ITEM_copy_item(eRev, newid, NULL, &newItem, &newRev));
//ITKCALL(AOM_set_value_string(newRev, "zt2_PMaterial", "PBOM")); //ITKCALL(AOM_set_value_string(newRev, "zt2_PMaterial", "PBOM"));
char* matnrNo; char* matnrNo;
AOM_ask_value_string(eRev, "zt2_MaterialNo", &matnrNo); ITKCALL(AOM_ask_value_string(eRev, "zt2_MaterialNo", &matnrNo));
AOM_lock(newRev); AOM_lock(newRev);
AOM_set_value_string(newRev, "zt2_ifpbom", "P"); ITKCALL(AOM_set_value_string(newRev, "zt2_ifpbom", "P"));
AOM_set_value_string(newRev, "zt2_MaterialNo", matnrNo); ITKCALL(AOM_set_value_string(newRev, "zt2_MaterialNo", matnrNo));
AOM_save(newRev); AOM_save(newRev);
AOM_unlock(newRev); AOM_unlock(newRev);
int num = 0, revNum = 0, tagNum = 0; int num = 0, revNum = 0, tagNum = 0;
tag_t* mantrs, dsuser, *structure_revisions, *bom_view_tags; tag_t* mantrs, dsuser, *structure_revisions, *bom_view_tags;
AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs); ITKCALL(AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs));
if (num > 0) { if (num > 0) {
AOM_ask_value_tags(newRev, "structure_revisions", &revNum, &structure_revisions); ITKCALL(AOM_ask_value_tags(newRev, "structure_revisions", &revNum, &structure_revisions));
AOM_ask_value_tags(newRev, "bom_view_tags", &tagNum, &bom_view_tags); ITKCALL(AOM_ask_value_tags(newRev, "bom_view_tags", &tagNum, &bom_view_tags));
AOM_ask_value_tag(mantrs[0], "owning_user", &dsuser); ITKCALL(AOM_ask_value_tag(mantrs[0], "owning_user", &dsuser));
tag_t defGroup; tag_t defGroup;
ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup));
ITKCALL(AOM_set_ownership(newItem, dsuser, defGroup)); ITKCALL(AOM_set_ownership(newItem, dsuser, defGroup));
@ -1042,26 +1055,26 @@ tag_t saveAsUpdate(tag_t eRev, char *uid, tag_t pLine) {
int bvr_count = 0, c_line_count; int bvr_count = 0, c_line_count;
tag_t ebom_window = NULLTAG; tag_t ebom_window = NULLTAG;
tag_t bom_line = NULLTAG, *c_line_tags; tag_t bom_line = NULLTAG, *c_line_tags;
(BOM_create_window(&ebom_window)); ITKCALL(BOM_create_window(&ebom_window));
tag_t* bvr_list = NULL; tag_t* bvr_list = NULL;
(ITEM_rev_list_bom_view_revs(pLine, &bvr_count, &bvr_list)); ITKCALL(ITEM_rev_list_bom_view_revs(pLine, &bvr_count, &bvr_list));
printf("bvr_count=%d\n", bvr_count); printf("bvr_count=%d\n", bvr_count);
(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //땅꿔bom삿혤 ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取
//ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &mantr)); //ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &mantr));
ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags));
for (int ind = 0; ind < c_line_count; ind++) { for (int ind = 0; ind < c_line_count; ind++) {
tag_t c_line_tag = c_line_tags[ind], mantr; tag_t c_line_tag = c_line_tags[ind], mantr;
AOM_ask_value_tag(c_line_tag, "bl_line_object", &mantr); ITKCALL(AOM_ask_value_tag(c_line_tag, "bl_line_object", &mantr));
char* eRevUid2; char* eRevUid2;
ITK__convert_tag_to_uid(mantr, &eRevUid2); ITK__convert_tag_to_uid(mantr, &eRevUid2);
if (strcmp(eRevUid2, uid) == 0) { if (strcmp(eRevUid2, uid) == 0) {
ITKCALL(BOM_line_replace(c_line_tag, NULLTAG, newRev, NULLTAG)); ITKCALL(BOM_line_replace(c_line_tag, NULLTAG, newRev, NULLTAG));
} }
} }
BOM_save_window(ebom_window); ITKCALL(BOM_save_window(ebom_window));
BOM_close_window(ebom_window); ITKCALL(BOM_close_window(ebom_window));
} }
return newRev; return newRev;
} }
@ -1074,7 +1087,7 @@ tag_t saveAsUpdate(tag_t eRev, tag_t newChild) {
char* newid = NULL; char* newid = NULL;
logical isModified = FALSE; logical isModified = FALSE;
tag_t item_type_tag, newItem, newRev; tag_t item_type_tag, newItem, newRev;
TCTYPE_ask_type("Item", &item_type_tag); ITKCALL(TCTYPE_ask_type("Item", &item_type_tag));
ITKCALL(USER_new_item_id(NULLTAG, item_type_tag, &isModified, &newid)); ITKCALL(USER_new_item_id(NULLTAG, item_type_tag, &isModified, &newid));
/*ITKCALL(NR_next_value("MEProcess", "item_id", NULLTAG, "", "", "", /*ITKCALL(NR_next_value("MEProcess", "item_id", NULLTAG, "", "", "",
NULLTAG, "", "", &next_id));*/ NULLTAG, "", "", &next_id));*/
@ -1082,21 +1095,21 @@ tag_t saveAsUpdate(tag_t eRev, tag_t newChild) {
ITKCALL(ITEM_copy_item(eRev, newid, NULL, &newItem, &newRev)); ITKCALL(ITEM_copy_item(eRev, newid, NULL, &newItem, &newRev));
//ITKCALL(AOM_set_value_string(newRev, "zt2_PMaterial", "PBOM")); //ITKCALL(AOM_set_value_string(newRev, "zt2_PMaterial", "PBOM"));
char* matnrNo; char* matnrNo;
AOM_ask_value_string(eRev, "zt2_MaterialNo", &matnrNo); ITKCALL(AOM_ask_value_string(eRev, "zt2_MaterialNo", &matnrNo));
AOM_lock(newRev); AOM_lock(newRev);
AOM_set_value_string(newRev, "zt2_ifpbom", "P"); ITKCALL(AOM_set_value_string(newRev, "zt2_ifpbom", "P"));
AOM_set_value_string(newRev, "zt2_MaterialNo", matnrNo); ITKCALL(AOM_set_value_string(newRev, "zt2_MaterialNo", matnrNo));
AOM_save(newRev); AOM_save(newRev);
AOM_unlock(newRev); AOM_unlock(newRev);
int num = 0, revNum = 0, tagNum = 0; int num = 0, revNum = 0, tagNum = 0;
tag_t* mantrs, dsuser, *structure_revisions, *bom_view_tags; tag_t* mantrs, dsuser, *structure_revisions, *bom_view_tags;
AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs); ITKCALL(AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs));
if (num > 0) { if (num > 0) {
AOM_ask_value_tags(newRev, "structure_revisions", &revNum, &structure_revisions); ITKCALL(AOM_ask_value_tags(newRev, "structure_revisions", &revNum, &structure_revisions));
AOM_ask_value_tags(newRev, "bom_view_tags", &tagNum, &bom_view_tags); ITKCALL(AOM_ask_value_tags(newRev, "bom_view_tags", &tagNum, &bom_view_tags));
AOM_ask_value_tag(mantrs[0], "owning_user", &dsuser); ITKCALL(AOM_ask_value_tag(mantrs[0], "owning_user", &dsuser));
tag_t defGroup; tag_t defGroup;
ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup));
ITKCALL(AOM_set_ownership(newItem, dsuser, defGroup)); ITKCALL(AOM_set_ownership(newItem, dsuser, defGroup));
@ -1217,13 +1230,16 @@ void addToAmatnrUp(vector<EBomUpBean> vecs, int len, tag_t newPAmatnr, boolean l
tag_t newView, newViewBvr, pitem; tag_t newView, newViewBvr, pitem;
ITKCALL(ITEM_ask_item_of_rev(mantr, &pitem)); ITKCALL(ITEM_ask_item_of_rev(mantr, &pitem));
ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView));
ITKCALL(AOM_save(newView)); (AOM_save(newView));
ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, mantr, &newViewBvr)); ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, mantr, &newViewBvr));
ITKCALL(AOM_save(newViewBvr)); (AOM_save(newViewBvr));
ITKCALL(AOM_save(mantr)); (AOM_save(mantr));
} }
ITKCALL(BOM_create_window(&ebom_window)); ITKCALL(BOM_create_window(&ebom_window));
ITKCALL(BOM_set_window_top_line(ebom_window, NULL, mantr, NULLTAG, &bom_line)); ITKCALL(BOM_set_window_top_line(ebom_window, NULL, mantr, NULLTAG, &bom_line));
char *os = NULL;
ITKCALL(AOM_ask_value_string(bom_line, "object_string", &os));
printf("bom_line====>%s\n", os);
char *name; char *name;
ITKCALL(AOM_ask_value_string(mantr, "object_name", &name)); ITKCALL(AOM_ask_value_string(mantr, "object_name", &name));
string xqType = getXqName(name); //ABCDE string xqType = getXqName(name); //ABCDE
@ -1237,7 +1253,7 @@ void addToAmatnrUp(vector<EBomUpBean> vecs, int len, tag_t newPAmatnr, boolean l
int xqLen = len; int xqLen = len;
if (msg.length() > 0) { if (msg.length() > 0) {
xqLen = msg.length(); xqLen = msg.length();
if (strstr(msg.c_str(), xqType.c_str()) != NULL) { if (strstr(msg.c_str(), xqType.c_str()) == NULL) {
continue; continue;
} }
} }
@ -1245,6 +1261,9 @@ void addToAmatnrUp(vector<EBomUpBean> vecs, int len, tag_t newPAmatnr, boolean l
if (newChild == NULLTAG) { if (newChild == NULLTAG) {
continue; continue;
} }
char *os2 = NULL;
ITKCALL(AOM_ask_value_string(newChild, "object_string", &os2));
printf("newChild====>%s ", os2);
ITKCALL(AOM_ask_value_string(cline, "bl_quantity", &oldQty)); ITKCALL(AOM_ask_value_string(cline, "bl_quantity", &oldQty));
ITKCALL(AOM_ask_value_string(cline, "bl_sequence_no", &seqNo)); ITKCALL(AOM_ask_value_string(cline, "bl_sequence_no", &seqNo));
ITKCALL(AOM_ask_value_string(cline, "bl_line_name", &bl_line_name)); ITKCALL(AOM_ask_value_string(cline, "bl_line_name", &bl_line_name));
@ -1254,21 +1273,35 @@ void addToAmatnrUp(vector<EBomUpBean> vecs, int len, tag_t newPAmatnr, boolean l
double fmodVal = fmod(blQty, xqLen); double fmodVal = fmod(blQty, xqLen);
double lastVal = num + fmodVal; double lastVal = num + fmodVal;
string numNew = to_string(lastVal); string numNew = to_string(lastVal);
ITKCALL(AOM_lock(newChild)); printf("numNew1====> %s\n", numNew.c_str());
ITKCALL(AOM_set_value_string(newChild, "bl_quantity", numNew.c_str())); (AOM_lock(newChild));
int result = 0;
ITKCALL(result = AOM_set_value_string(newChild, "bl_quantity", numNew.c_str()));
if (result != 0) {
int iblQty = atoi(oldQty);
//double fmodVal = fmod(blQty, xqLen);
int val = iblQty / xqLen + iblQty % xqLen;
numNew = to_string(val);
printf("numNew1====> %s >>> %s\n", numNew.c_str(), vecs[i].blQuantity.c_str());
ITKCALL(AOM_set_value_string(newChild, "bl_quantity", numNew.c_str()));
//ITKCALL(AOM_set_value_string(newChild, "bl_quantity", vecs[i].blQuantity.c_str()));
}
ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", seqNo)); ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", seqNo));
ITKCALL(AOM_save(newChild)); ITKCALL(AOM_set_value_string(newChild, "ZT2_Remark", remark));
ITKCALL(AOM_unlock(newChild)); (AOM_save(newChild));
(AOM_unlock(newChild));
} }
else { else {
int blQty = atoi(oldQty); int blQty = atoi(oldQty);
int num = blQty / len; int num = blQty / xqLen;
string numNew = to_string(num); string numNew = to_string(num);
ITKCALL(AOM_lock(newChild)); printf("numNew2====> %s\n", numNew.c_str());
(AOM_lock(newChild));
ITKCALL(AOM_set_value_string(newChild, "bl_quantity", numNew.c_str())); ITKCALL(AOM_set_value_string(newChild, "bl_quantity", numNew.c_str()));
ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", seqNo)); ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", seqNo));
ITKCALL(AOM_save(newChild)); ITKCALL(AOM_set_value_string(newChild, "ZT2_Remark", remark));
ITKCALL(AOM_unlock(newChild)); (AOM_save(newChild));
(AOM_unlock(newChild));
} }
} }
@ -1409,12 +1442,12 @@ boolean combEAndDbom(map<string, double> dMap, map<string, double> eMap) {
void changeCoilOwner(tag_t newPMantr, tag_t oldPMantr) { void changeCoilOwner(tag_t newPMantr, tag_t oldPMantr) {
tag_t dsuser, *oldRevisions; tag_t dsuser, *oldRevisions;
int revNum = 0, revNumOld = 0; int revNum = 0, revNumOld = 0;
AOM_ask_value_tags(newPMantr, "structure_revisions", &revNumOld, &oldRevisions); ITKCALL(AOM_ask_value_tags(newPMantr, "structure_revisions", &revNumOld, &oldRevisions));
if (revNumOld > 0) { if (revNumOld > 0) {
AOM_ask_value_tag(oldRevisions[0], "owning_user", &dsuser); ITKCALL(AOM_ask_value_tag(oldRevisions[0], "owning_user", &dsuser));
tag_t defGroup, *structure_revisions; tag_t defGroup, *structure_revisions;
ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup));
AOM_ask_value_tags(newPMantr, "structure_revisions", &revNum, &structure_revisions); ITKCALL(AOM_ask_value_tags(newPMantr, "structure_revisions", &revNum, &structure_revisions));
if (revNum > 0) { if (revNum > 0) {
ITKCALL(AOM_set_ownership(structure_revisions[0], dsuser, defGroup)); ITKCALL(AOM_set_ownership(structure_revisions[0], dsuser, defGroup));
} }
@ -1469,7 +1502,7 @@ tag_t saveAsMaterial(EBomUpBean topBean, boolean isTop,
} }
for (int i = 0; i < termCoils.size(); i++) { for (int i = 0; i < termCoils.size(); i++) {
char* itemId; char* itemId;
AOM_ask_value_string(termCoils[i], "item_id", &itemId); ITKCALL(AOM_ask_value_string(termCoils[i], "item_id", &itemId));
printf("=======itemId====== %s \n", itemId); printf("=======itemId====== %s \n", itemId);
if (isTcm(termCoils[i]) && isBomViewTcm(termCoils[i])) { if (isTcm(termCoils[i]) && isBomViewTcm(termCoils[i])) {
tag_t newPMantr; tag_t newPMantr;
@ -1485,7 +1518,7 @@ tag_t saveAsMaterial(EBomUpBean topBean, boolean isTop,
/** /**
* PBOM * PBOM
* @param upBean EBOM * @param upBean EBOM
* @param bom_line PBOM * @param pBomTag PBOM
* @param len * @param len
* @param dcproxy dcproxy * @param dcproxy dcproxy
* @param isTop * @param isTop
@ -1534,14 +1567,14 @@ void startUpdate(EBomUpBean upBean, tag_t pBomTag, int len, tag_t dcproxy,
//A项线圈是不带P的 //A项线圈是不带P的
matnrVec.push_back(matnrNo); matnrVec.push_back(matnrNo);
pBomMap[matnrNo] = c_line_tag; pBomMap[matnrNo] = c_line_tag;
//BOM_line_cut(c_line_tag); //ITKCALL(BOM_line_cut(c_line_tag));
}
else if (!checkName(name)) {
ITKCALL(BOM_line_cut(c_line_tag));//pBomMap[matnrNo] = c_line_tag;
} }
else if (checkName(name)) { else if (checkName(name)) {
xqTagVec.push_back(c_line_tag); xqTagVec.push_back(c_line_tag);
} }
else {
ITKCALL(BOM_line_cut(c_line_tag));//pBomMap[matnrNo] = c_line_tag;
}
} }
//移除所有非P 再从EBOM复制 //移除所有非P 再从EBOM复制
printf("xqTagVec===>%d\n", xqTagVec.size()); printf("xqTagVec===>%d\n", xqTagVec.size());
@ -1572,13 +1605,11 @@ void startUpdate(EBomUpBean upBean, tag_t pBomTag, int len, tag_t dcproxy,
//重新复制 //重新复制
if (std::find(matnrVec.begin(), matnrVec.end(), cupBean.matnrNo) != matnrVec.end()) { if (std::find(matnrVec.begin(), matnrVec.end(), cupBean.matnrNo) != matnrVec.end()) {
printf("matnrVec ===>%s\n", cupBean.matnrNo.c_str()); printf("matnrVec ===>%s\n", cupBean.matnrNo.c_str());
tag_t c_line_tag = pBomMap[cupBean.matnrNo]; tag_t c_line_tag = pBomMap[cupBean.matnrNo], bomView = NULLTAG, childPTag = NULLTAG;
tag_t c_Rev, bomView = NULLTAG;
ITKCALL(AOM_ask_value_tag(c_line_tag, "bl_line_object", &c_Rev));
boolean flagAs = false; boolean flagAs = false;
tag_t childPTag;
ITKCALL(AOM_ask_value_tag(c_line_tag, BL_LINE_OBJECT, &childPTag)); ITKCALL(AOM_ask_value_tag(c_line_tag, BL_LINE_OBJECT, &childPTag));
//ITKCALL(BOM_line_cut(c_line_tag));
startUpdate(cupBean, childPTag, len, dcproxy, isTop, hasChange, saveAsMap); startUpdate(cupBean, childPTag, len, dcproxy, isTop, hasChange, saveAsMap);
if (bomView != NULLTAG && flagAs) { if (bomView != NULLTAG && flagAs) {
ITKCALL(BOM_save_window(bomView)); ITKCALL(BOM_save_window(bomView));
@ -1588,20 +1619,21 @@ void startUpdate(EBomUpBean upBean, tag_t pBomTag, int len, tag_t dcproxy,
} }
else { else {
boolean flagLc = false; boolean flagLc = false;
char* seq; char* seq = NULL, *ZT2_Remark = NULL;
printf("matnrVecNotP===>%s\n", cupBean.matnrNo.c_str()); printf("matnrVecNotP===>%s\n", cupBean.matnrNo.c_str());
tag_t cline = cupBean.bomline; tag_t cline = cupBean.bomline, newChild = NULLTAG;
tag_t newChild;
ITKCALL(BOM_line_copy(bom_line, cline, NULLTAG, &newChild)); ITKCALL(BOM_line_copy(bom_line, cline, NULLTAG, &newChild));
if (newChild == NULLTAG) { if (newChild == NULLTAG) {
printf(" newChild === NULLTAG 没有权限修改BOM视图 \n"); printf(" newChild === NULLTAG 没有权限修改BOM视图 \n");
continue; continue;
} }
ITKCALL(AOM_ask_value_string(cline, "bl_sequence_no", &seq)); ITKCALL(AOM_ask_value_string(cline, "bl_sequence_no", &seq));
ITKCALL(AOM_lock(newChild)); ITKCALL(AOM_ask_value_string(cline, "ZT2_Remark", &ZT2_Remark));
(AOM_lock(newChild));
ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", seq)); ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", seq));
ITKCALL(AOM_save(newChild)); ITKCALL(AOM_set_value_string(newChild, "ZT2_Remark", ZT2_Remark));
ITKCALL(AOM_unlock(newChild)); (AOM_save(newChild));
(AOM_unlock(newChild));
tag_t c_Rev; tag_t c_Rev;
ITKCALL(AOM_ask_value_tag(cline, "bl_line_object", &c_Rev)); ITKCALL(AOM_ask_value_tag(cline, "bl_line_object", &c_Rev));
@ -1623,6 +1655,20 @@ void startUpdate(EBomUpBean upBean, tag_t pBomTag, int len, tag_t dcproxy,
} }
} }
} }
for (int i = 0; i < matnrVec.size(); i++) {
bool cut = true;
for (int j = 0; j < vecs.size(); j++) {
if (tc_strcmp(vecs[j].matnrNo.c_str(), matnrVec[i].c_str()) == 0) {
cut = false;
break;
}
}
if (cut) {
printf(" cut === %s\n", matnrVec[i].c_str());
tag_t c_line_tag = pBomMap[matnrVec[i]];
ITKCALL(BOM_line_cut(c_line_tag));
}
}/**/
} }
//移除所有非P 再从EBOM复制 //移除所有非P 再从EBOM复制
@ -1659,10 +1705,10 @@ void copyBomLine(tag_t matnrTop, tag_t otherPbom) {
tag_t newView, newViewBvr, pitem; tag_t newView, newViewBvr, pitem;
ITKCALL(ITEM_ask_item_of_rev(otherPbom, &pitem)); ITKCALL(ITEM_ask_item_of_rev(otherPbom, &pitem));
ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView));
ITKCALL(AOM_save(newView)); (AOM_save(newView));
ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, otherPbom, &newViewBvr)); ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, otherPbom, &newViewBvr));
ITKCALL(AOM_save(newViewBvr)); (AOM_save(newViewBvr));
ITKCALL(AOM_save(otherPbom)); (AOM_save(otherPbom));
//return; //return;
ITKCALL(ITEM_rev_list_bom_view_revs(otherPbom, &bvr_count2, &bvr_list2)); ITKCALL(ITEM_rev_list_bom_view_revs(otherPbom, &bvr_count2, &bvr_list2));
} }
@ -1675,7 +1721,7 @@ void copyBomLine(tag_t matnrTop, tag_t otherPbom) {
} }
for (int i = 0; i < c_line_count; i++) { for (int i = 0; i < c_line_count; i++) {
tag_t newChild = NULLTAG; tag_t newChild = NULLTAG;
char *bl_seqNo = NULL; char *bl_seqNo = NULL, *ZT2_Remark = NULL;
ITKCALL(BOM_line_copy(bom_line2, c_line_tags[i], NULLTAG, &newChild)); ITKCALL(BOM_line_copy(bom_line2, c_line_tags[i], NULLTAG, &newChild));
char* pos = NULL; char* pos = NULL;
@ -1683,8 +1729,10 @@ void copyBomLine(tag_t matnrTop, tag_t otherPbom) {
printf("copyBomLine:%s\n", pos); printf("copyBomLine:%s\n", pos);
ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &bl_seqNo)); ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &bl_seqNo));
ITKCALL(AOM_ask_value_string(c_line_tags[i], "ZT2_Remark", &ZT2_Remark));
AOM_lock(newChild); AOM_lock(newChild);
ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", bl_seqNo)); ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", bl_seqNo));
ITKCALL(AOM_set_value_string(newChild, "ZT2_Remark", ZT2_Remark));
AOM_save(newChild); AOM_save(newChild);
//最后unlock //最后unlock
AOM_unlock(newChild); AOM_unlock(newChild);
@ -1699,6 +1747,7 @@ void copyBomLine(tag_t matnrTop, tag_t otherPbom) {
//EBOM转PBOM //EBOM转PBOM
int EbomToPMethod(void* returnValue) { int EbomToPMethod(void* returnValue) {
auto start = std::chrono::high_resolution_clock::now();
int ifail = ITK_ok; int ifail = ITK_ok;
char *sql = NULL, *revUid; char *sql = NULL, *revUid;
tag_t matnrRev1; tag_t matnrRev1;
@ -1750,6 +1799,9 @@ int EbomToPMethod(void* returnValue) {
} }
} }
close(); close();
auto time1 = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = time1 - start;
printf("time1%f\n", elapsed.count());
//遍历design BOM 获取物料信息 //遍历design BOM 获取物料信息
int bvr_count = 0, c_line_count; int bvr_count = 0, c_line_count;
tag_t ebom_window = NULLTAG; tag_t ebom_window = NULLTAG;
@ -1797,7 +1849,7 @@ int EbomToPMethod(void* returnValue) {
ITKCALL(AOM_ask_value_string(topMatnrs[t], "zt2_ifpbom", &isPm)); ITKCALL(AOM_ask_value_string(topMatnrs[t], "zt2_ifpbom", &isPm));
string key = ""; string key = "";
key.append(zt2_WBSNo).append(zt2_MaterialNo); key.append(zt2_WBSNo).append(zt2_MaterialNo);
printf("key===>%d\n", key.c_str()); printf("key===>%s\n", key.c_str());
if (wlbmMap.count(key) > 0) { if (wlbmMap.count(key) > 0) {
E2PBean &bean = wlbmMap[key]; E2PBean &bean = wlbmMap[key];
@ -1841,6 +1893,10 @@ int EbomToPMethod(void* returnValue) {
isUpdate = true; isUpdate = true;
} }
} }
auto time2 = std::chrono::high_resolution_clock::now();
elapsed = time2 - start;
printf("time2%f\n", elapsed.count());
POM_AM__set_application_bypass(true); POM_AM__set_application_bypass(true);
tag_t dcproxy = findDcUser(); tag_t dcproxy = findDcUser();
//创建PBOM原来逻辑 //创建PBOM原来逻辑
@ -1881,8 +1937,11 @@ int EbomToPMethod(void* returnValue) {
recyReadEBom(bom_line, topBean, beans, len, matnrTop, errBuff); recyReadEBom(bom_line, topBean, beans, len, matnrTop, errBuff);
printf("read end %d\n", beans.size()); printf("read end %d\n", beans.size());
BOM_close_window(ebom_window); ITKCALL(BOM_close_window(ebom_window));
//搭建BOM //搭建BOM
auto time3 = std::chrono::high_resolution_clock::now();
elapsed = time3 - start;
printf("time3%f\n", elapsed.count());
printf("buff %s==>\n", errBuff.c_str()); printf("buff %s==>\n", errBuff.c_str());
tag_t topPrev = NULLTAG; tag_t topPrev = NULLTAG;
@ -1904,8 +1963,13 @@ int EbomToPMethod(void* returnValue) {
replaceBom(beans[t], map, len, dcproxy, topPrev); replaceBom(beans[t], map, len, dcproxy, topPrev);
} }
DisConnServer(); DisConnServer();
auto time4 = std::chrono::high_resolution_clock::now();
elapsed = time4 - start;
printf("time4%f\n", elapsed.count());
//多个产成品直接复制BOM //多个产成品直接复制BOM
for (it2 = wlbmMap.begin(); it2 != wlbmMap.end(); it2++) { for (it2 = wlbmMap.begin(); it2 != wlbmMap.end(); it2++) {
auto sub = std::chrono::high_resolution_clock::now();
string ss = it2->first; string ss = it2->first;
tag_t eMantr = wlbmMap[ss].eMantr; tag_t eMantr = wlbmMap[ss].eMantr;
if (keyNum.compare(ss) == 0) { if (keyNum.compare(ss) == 0) {
@ -1949,6 +2013,9 @@ int EbomToPMethod(void* returnValue) {
} }
//复制一份 //复制一份
copyBomLine(topPrev, newRev); copyBomLine(topPrev, newRev);
auto sub1 = std::chrono::high_resolution_clock::now();
elapsed = sub1 - sub;
printf("sub1%f\n", elapsed.count());
} }
} }
} }
@ -1982,6 +2049,9 @@ int EbomToPMethod(void* returnValue) {
//遍历获取EBOM信息 //遍历获取EBOM信息
updatePbomCycle(bom_line, errBuff, len, upBean); updatePbomCycle(bom_line, errBuff, len, upBean);
auto time3 = std::chrono::high_resolution_clock::now();
elapsed = time3 - start;
printf("time3%f\n", elapsed.count());
//ITKCALL(BOM_set_window_top_line_bvr(ebom_window2, bvr_list2[0], &bom_line2)); //顶层bom获取 //ITKCALL(BOM_set_window_top_line_bvr(ebom_window2, bvr_list2[0], &bom_line2)); //顶层bom获取
int url_num = 0; int url_num = 0;
char** url_vals = NULL; char** url_vals = NULL;
@ -2000,6 +2070,10 @@ int EbomToPMethod(void* returnValue) {
startUpdate(upBean, pBomTop, len, dcproxy, true, hasChange, saveAsMap); startUpdate(upBean, pBomTop, len, dcproxy, true, hasChange, saveAsMap);
DisConnServer(); DisConnServer();
//保存PBOM //保存PBOM
auto time4 = std::chrono::high_resolution_clock::now();
elapsed = time4 - start;
printf("time4%f\n", elapsed.count());
//ITKCALL(BOM_save_window(ebom_window2)); //ITKCALL(BOM_save_window(ebom_window2));
////ITKCALL(AOM_unlock(ebom_window2)); ////ITKCALL(AOM_unlock(ebom_window2));
//ITKCALL(BOM_close_window(ebom_window2)); //ITKCALL(BOM_close_window(ebom_window2));
@ -2010,6 +2084,7 @@ int EbomToPMethod(void* returnValue) {
printf("keyNum===>%s\n", keyNum.c_str()); printf("keyNum===>%s\n", keyNum.c_str());
map<string, E2PBean>::iterator it2; map<string, E2PBean>::iterator it2;
for (it2 = wlbmMap.begin(); it2 != wlbmMap.end(); it2++) { for (it2 = wlbmMap.begin(); it2 != wlbmMap.end(); it2++) {
auto sub = std::chrono::high_resolution_clock::now();
string ss = it2->first; string ss = it2->first;
E2PBean tagBean = wlbmMap[ss]; E2PBean tagBean = wlbmMap[ss];
printf("ss===>%s\n", ss.c_str()); printf("ss===>%s\n", ss.c_str());
@ -2054,6 +2129,9 @@ int EbomToPMethod(void* returnValue) {
ITKCALL(AOM_ask_value_string(newRev, "object_string", &nos)); ITKCALL(AOM_ask_value_string(newRev, "object_string", &nos));
printf("copyBomLine:%s ==> %s\n", pos, nos); printf("copyBomLine:%s ==> %s\n", pos, nos);
copyBomLine(newP, newRev); copyBomLine(newP, newRev);
auto sub1 = std::chrono::high_resolution_clock::now();
elapsed = sub1 - sub;
printf("sub1%f\n", elapsed.count());
} }
} }
@ -2065,6 +2143,10 @@ int EbomToPMethod(void* returnValue) {
buff = "succ"; buff = "succ";
} }
CloseTcLog(); CloseTcLog();
// 计算时间间隔
auto end = std::chrono::high_resolution_clock::now();
elapsed = end - start;
printf("用时:%f\n", elapsed.count());
*((char**)returnValue) = (char*)MEM_alloc((strlen(buff.c_str()) + 1) * sizeof(char)); *((char**)returnValue) = (char*)MEM_alloc((strlen(buff.c_str()) + 1) * sizeof(char));
tc_strcpy(*((char**)returnValue), buff.c_str()); tc_strcpy(*((char**)returnValue), buff.c_str());
return ifail; return ifail;

@ -181,7 +181,9 @@
<ClCompile Include="ChintSendMessage.cpp" /> <ClCompile Include="ChintSendMessage.cpp" />
<ClCompile Include="chintSignChange.cpp" /> <ClCompile Include="chintSignChange.cpp" />
<ClCompile Include="chint_add_to_workflow.cpp" /> <ClCompile Include="chint_add_to_workflow.cpp" />
<ClCompile Include="CHINT_CHANGEBOM_TO_SRM.cxx" />
<ClCompile Include="chint_changenotice.cpp" /> <ClCompile Include="chint_changenotice.cpp" />
<ClCompile Include="chint_changenoticebm.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" />
@ -215,6 +217,7 @@
<ClCompile Include="EbomToPMethod.cpp" /> <ClCompile Include="EbomToPMethod.cpp" />
<ClCompile Include="epm_register_handler.cpp" /> <ClCompile Include="epm_register_handler.cpp" />
<ClCompile Include="General.cpp" /> <ClCompile Include="General.cpp" />
<ClCompile Include="getBomDetails.cxx" />
<ClCompile Include="HXC_create_item_post.cpp" /> <ClCompile Include="HXC_create_item_post.cpp" />
<ClCompile Include="libGeneral_custom_main.cpp" /> <ClCompile Include="libGeneral_custom_main.cpp" />
<ClCompile Include="Modify_Attributes.cpp" /> <ClCompile Include="Modify_Attributes.cpp" />

@ -233,5 +233,14 @@
<ClCompile Include="chint_check_materialstatus.cpp"> <ClCompile Include="chint_check_materialstatus.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="chint_changenoticebm.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="getBomDetails.cxx">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CHINT_CHANGEBOM_TO_SRM.cxx">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -41,6 +41,7 @@
#include <property/nr.h> #include <property/nr.h>
#include "CRUL_server_call_httpserver.h" #include "CRUL_server_call_httpserver.h"
#include "common_itk_util.h" #include "common_itk_util.h"
#include <chrono>
#define EPM_HANDLER_COMMON #define EPM_HANDLER_COMMON
#define MAX_PATH_LENGTH 200 #define MAX_PATH_LENGTH 200
#define MAX_PRINTLINE_LENGTH 400000 #define MAX_PRINTLINE_LENGTH 400000
@ -133,7 +134,7 @@ int chint_changenotice(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;
@ -154,7 +155,7 @@ int chint_changenotice(EPM_action_message_t msg) {
for (int j = 0; j < c_sql_value_count; j++) { for (int j = 0; j < c_sql_value_count; j++) {
/*值:第一行为通知信息。 /*值:第一行为通知信息。
:; :;
M060shaojq@chint.com M060shaojq@chint.com
M060 : shaojq*/ M060 : shaojq*/
if (j != 0) { if (j != 0) {
@ -240,13 +241,47 @@ int chint_changenotice(EPM_action_message_t msg) {
cJSON_AddItemToArray(emails, new_string); cJSON_AddItemToArray(emails, new_string);
} }
//找项目信息
//拼接content //拼接content
tag_t user; tag_t user;
char* duser,* itemId; char* duser, *itemId;
char* zt2_WBSNo, *zt2_ContractName;
AOM_ask_value_string(tagt, "item_id", &itemId); 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);
string th = "";
int wlNum; tag_t* wlTags;
ITKCALL(AOM_ask_value_tags(tagt, "ZT2_ChangeAfter", &wlNum, &wlTags));
printf("wlNum======%d\n", wlNum);
for (int j = 0; j < wlNum; j++) {
char* thType;
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);
th.append(thid).append(";");
}
}
printf("th======%s\n", th);
AOM_ask_value_tag(tagt, "owning_user", &user); AOM_ask_value_tag(tagt, "owning_user", &user);
AOM_ask_value_string(user, "user_name", &duser); AOM_ask_value_string(user, "user_name", &duser);
contentStr.append(duser).append(" 发起的").append(itemId).append(c_sql_values[0]);
//获取当前时间
auto now = std::chrono::system_clock::now();
std::time_t time = std::chrono::system_clock::to_time_t(now);
std::tm* ptm = std::localtime(&time);
char buf[128];
strftime(buf, sizeof(buf), "%Y.%m.%d", ptm);
printf("time===%s\n", buf);
contentStr.append(duser).append(" 发起的").append(itemId).append(c_sql_values[0]).append("(").append(th).append("-").append(zt2_WBSNo).append("-").append(zt2_ContractName).append(") 发起人:").append(duser).append("发布时间:").append(buf);
cJSON_AddStringToObject(top, "content", contentStr.c_str()); cJSON_AddStringToObject(top, "content", contentStr.c_str());
//sms //sms

@ -0,0 +1,408 @@
#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"
#include <chrono>
#define EPM_HANDLER_COMMON
#define MAX_PATH_LENGTH 200
#define MAX_PRINTLINE_LENGTH 400000
char* concat(char** s, int size) {
int length = 0;
for (int i = 0; i < size; i++) {
length += strlen(s[i]);
}
char* result = new char[length + 1];
int index = 0;
for (int i = 0; i < size; i++) {
int len = strlen(s[i]);
memcpy(result + index, s[i], len);
index += len;
}
result[length] = '\0';
return result;
}
char* utogbm(const char* src_str)
{
int len = MultiByteToWideChar(CP_UTF8, 0, src_str, -1, NULL, 0);
wchar_t* wszGBK = (wchar_t*)MEM_alloc((len + 1) * sizeof(wchar_t));
memset(wszGBK, 0, len * 2 + 2);
MultiByteToWideChar(CP_UTF8, 0, src_str, -1, wszGBK, len);
len = WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, NULL, 0, NULL, NULL);
char* szGBK = (char*)MEM_alloc((len + 1) * sizeof(char));
memset(szGBK, 0, len + 1);
WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, szGBK, len, NULL, NULL);
return szGBK;
}
char* gtoubm(const char* src_str)
{
int len = MultiByteToWideChar(CP_ACP, 0, src_str, -1, NULL, 0);
wchar_t* wstr = (wchar_t*)MEM_alloc((len + 1) * sizeof(wchar_t));
memset(wstr, 0, len + 1);
MultiByteToWideChar(CP_ACP, 0, src_str, -1, wstr, len);
len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
char* str = (char*)MEM_alloc((len + 1) * sizeof(char));
memset(str, 0, len + 1);
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);
return str;
}
// 写入回调函数实现
size_t WriteCallbackbm(void* contents, size_t size, size_t nmemb, void* userp) {
size_t totalSize = size * nmemb;
char* buffer = (char*)userp;
// 追加内容到缓冲区
strncat(buffer, (char*)contents, totalSize);
return totalSize; // 返回实际接收的字节数
}
void feishuSplitbm(string strArg, string spliter, vector<string>& ans)
{
ans.clear();
size_t index0 = 0;
string one_arg;
if (strArg.find_first_not_of(' ') == string::npos)
strArg = "";
while (strArg.size() > 0)
{
index0 = strArg.find_first_of(spliter);
if (index0 != string::npos)
{
one_arg = strArg.substr(0, index0);
strArg = strArg.substr(index0 + 1);
ans.push_back(one_arg);
}
else
{
ans.push_back(strArg);
break;
}
}
}
void WriteLogbm(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_changenoticebm(EPM_action_message_t msg) {
tag_t task_tag = NULL_TAG,
root_task_tag = NULLTAG,
*attachments;;
task_tag = msg.task;
int att_cnt = 0, ifail = 0;
int c_sql_value_count = 0;
char** c_sql_values = NULL;
ITKCALL(PREF_ask_char_values("CHINT_ChangeNoticeBM", &c_sql_value_count, &c_sql_values));
WriteLogbm(true, "------------------------------------------------------------------------------------");
WriteLogbm(true, "=========================");
WriteLogbm(true, "chint_changenoticebm start");
WriteLogbm(true, "=========================");
EPM_ask_root_task(task_tag, &root_task_tag);
EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments);
WriteLogbm(true, "流程目标下的对象数量:%d", att_cnt);
//分割首选项
string finalUsers = "";
std::map<std::string, std::string> prefMap;//统计集合
std::map<std::string, std::string> zt2_ChangeUnit1Map;//zt2_ChangeUnit1 map
for (int j = 0; j < c_sql_value_count; j++) {
/*触发handler后获取当前流程目标下 “ZT2_Change”对象的item属性更改单发放部门“zt2_ChangeUnit1”
CHINT_ChangeNoticeBM |
|
+ + - wbs - xx; xx*/
if (j != 0) {
vector<string> ans;
feishuSplitbm(c_sql_values[j], "|", ans);
prefMap[ans[0]] = ans[1];
}
}
WriteLogbm(true, "首选项条数:%d", prefMap.size());
for (int i = 0; i < att_cnt; i++)
{
tag_t tagt = NULLTAG;
tagt = attachments[i];
char* type, *zt2_ChangeUnit1;
//获取版本下的数据集
int dataset_num = 0;
tag_t* dataset_tags = NULL;
char* tempValue = NULL;
char taskpuid[56] = "\0";
ITK__convert_tag_to_uid(task_tag, &tempValue);
tc_strcpy(taskpuid, tempValue);
ITKCALL(AOM_ask_value_string(tagt, "object_type", &type));
printf("object_type=%s\n", type);
//获取当前登入人组
//char* groupName = NULL;
//tag_t t_group = NULLTAG;
//ITKCALL(POM_ask_group(&groupName, &t_group));
//printf("g=%s\n", groupName);
//获取当前登入人的名称和id
tag_t group;
char* group_name;
AOM_ask_value_tag(tagt, "owning_group", &group);
AOM_ask_value_string(group, "name", &group_name);
char* name;
char* id;
tag_t user;
POM_get_user(&name, &user);
POM_get_user_id(&id);
printf("name================%s\n", name);
printf("id================%s\n", id);
printf("group_name================%s\n", group_name);
string users = "";
//判断组是否在首选项中存在
for (auto it = prefMap.begin(); it != prefMap.end(); it++) {
//当前组和首选项中组匹配
if (strcmp(it->first.c_str(), group_name) == 0) {
users = it->second;
break;
}
}
printf("users================%s\n", users.c_str());
if (strcmp(users.c_str(), "") != 0) {
//判断目标下是否存在 ZT2_Change
if (strcmp("ZT2_Change", type) == 0) {
//获取zt2_ChangeUnit1的值
int num; char** getValues;
ITKCALL(AOM_UIF_ask_values(tagt, "zt2_ChangeUnit1", &num, &getValues));
zt2_ChangeUnit1 = concat(getValues, num);
printf("zt2_ChangeUnit1===========%s\n", zt2_ChangeUnit1);
//分割";"
vector<string> zt2_ChangeUnit1Ans;
feishuSplitbm(users, ";", zt2_ChangeUnit1Ans);
for (int z = 0; z < zt2_ChangeUnit1Ans.size(); z++) {
vector<string> tempSplit;
feishuSplitbm(zt2_ChangeUnit1Ans[z], ":", tempSplit);
zt2_ChangeUnit1Map[tempSplit[0]] = tempSplit[1];
}
printf("zt2_ChangeUnit1Map===========%d\n", zt2_ChangeUnit1Map.size());
//遍历zt2_ChangeUnit1Map把zt2_ChangeUnit1中与首选项匹配
for (auto it = zt2_ChangeUnit1Map.begin(); it != zt2_ChangeUnit1Map.end(); it++) {
//当前组和首选项中组匹配
if (strstr(zt2_ChangeUnit1, it->first.c_str())) {
finalUsers.append(it->second).append(",");
}
}
printf("finalUsers===========%s\n", finalUsers.c_str());
if (strcmp(finalUsers.c_str(), "") != 0) {
//拼接json
char* json = NULL;
string contentStr;
cJSON* top = cJSON_CreateObject();
cJSON* emails = cJSON_CreateArray();
cJSON* mobiles = cJSON_CreateArray();
//拼接emails
vector<string> usersVector;
std::map<std::string, std::string> tempMap;//zt2_ChangeUnit1 map
//取唯一先放入map里
feishuSplitbm(finalUsers, ",", usersVector);
for (int h = 0; h < usersVector.size(); h++) {
tempMap[usersVector[h].c_str()] = usersVector[h].c_str();
}
for (auto it = tempMap.begin(); it != tempMap.end(); it++) {
//当前组和首选项中组匹配
cJSON* new_string = cJSON_CreateString(it->first.c_str());
cJSON_AddItemToArray(emails, new_string);
}
//找项目信息
//拼接content
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);
string th = "";
int wlNum; tag_t* wlTags;
ITKCALL(AOM_ask_value_tags(tagt, "ZT2_ChangeAfter", &wlNum, &wlTags));
printf("wlNum======%d\n", wlNum);
for (int j = 0; j < wlNum; j++) {
char* thType;
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);
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);
//获取当前时间
auto now = std::chrono::system_clock::now();
std::time_t time = std::chrono::system_clock::to_time_t(now);
std::tm* ptm = std::localtime(&time);
char buf[128];
strftime(buf, sizeof(buf), "%Y.%m.%d", ptm);
printf("time===%s\n", buf);
contentStr.append(duser).append(" 发起的").append(itemId).append(c_sql_values[0]).append("(").append(th).append("-").append(zt2_WBSNo).append("-").append(zt2_ContractName).append(") 发起人:").append(duser).append("发布时间:").append(buf);
cJSON_AddStringToObject(top, "content", contentStr.c_str());
//sms
cJSON_AddStringToObject(top, "sms", "false");
cJSON_AddItemToObject(top, "emails", emails);
cJSON_AddItemToObject(top, "mobiles", mobiles);
json = cJSON_Print(top);
printf("json================%s\n", json);
//调用接口
CURL* curl;
CURLcode res;
char readBuffer[10000];
memset(readBuffer, 0, 10000);
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "http://10.128.10.170/api/feishu/Message/sendMessages");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist* headers = NULL;
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallbackbm);
// 设置写入数据的目标缓冲区
curl_easy_setopt(curl, CURLOPT_WRITEDATA, readBuffer);
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
//const char* data = "{\"emails\":[\"shaojq@chint.com\",\"zouy5@chint.com\"],\"mobiles\":[],\"sms\":false,\"content\":\"项目编号:P2303344售前资料已经获取完毕请 登陆PLM系统查看。\"}";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, gtoubm(json));
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
char* gbk_readBuffer = utogbm(readBuffer);
printf("json================%s\n", gbk_readBuffer);
cJSON* result_json = cJSON_Parse(gbk_readBuffer);
cJSON* code = cJSON_GetObjectItem(result_json, "code");
int code_int = code->valueint;
if (code_int != 0) {
printf("发送飞书失败\n");
}
}
}
}
}
DOFREE(attachments);
WriteLogbm(true, "=========================");
WriteLogbm(true, "chint_changenoticebm end");
WriteLogbm(true, "=========================");
return ifail;
}

@ -72,7 +72,7 @@ int chint_check_materialstatus(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;
@ -96,12 +96,12 @@ int chint_check_materialstatus(EPM_action_message_t msg) {
tag_t target = NULLTAG; tag_t target = NULLTAG;
target = attachments[i]; target = attachments[i];
char* objectType = NULL; char* objectType = NULL;
char* fcStr = NULL,* tyStr = NULL,* zt2_State = NULL; char* fcStr = NULL, *tyStr = NULL, *zt2_State = NULL;
//三种处理逻辑 物料 物料bom 图纸 //三种处理逻辑 物料 物料bom 图纸
ITKCALL(AOM_ask_value_string(target, "object_type", &objectType)); ITKCALL(AOM_ask_value_string(target, "object_type", &objectType));
//物料 //物料
printf("objectType======%s\n", objectType); printf("objectType======%s\n", objectType);
if (strcmp(objectType,"Part Revision") == 0) { if (strcmp(objectType, "Part Revision") == 0) {
//获取物料编码和物料名称 //获取物料编码和物料名称
char* zt2_MaterialNo = NULL; char* zt2_MaterialNo = NULL;
char* object_name = NULL; char* object_name = NULL;
@ -110,7 +110,7 @@ int chint_check_materialstatus(EPM_action_message_t msg) {
ITKCALL(AOM_ask_value_string(target, "object_desc", &tyStr)); ITKCALL(AOM_ask_value_string(target, "object_desc", &tyStr));
ITKCALL(AOM_UIF_ask_value(target, "zt2_State", &zt2_State)); ITKCALL(AOM_UIF_ask_value(target, "zt2_State", &zt2_State));
printf("tyStr======%s\n", tyStr); printf("tyStr======%s\n", tyStr);
if (strstr(tyStr,"停用")) { if (strstr(tyStr, "停用")) {
//放入停用map //放入停用map
tyMap[zt2_MaterialNo] = object_name; tyMap[zt2_MaterialNo] = object_name;
continue; continue;
@ -174,15 +174,16 @@ int chint_check_materialstatus(EPM_action_message_t msg) {
ITKCALL(AOM_ask_value_string(rev, "zt2_MaterialNo", &zt2_MaterialNo)); ITKCALL(AOM_ask_value_string(rev, "zt2_MaterialNo", &zt2_MaterialNo));
ITKCALL(AOM_ask_value_string(rev, "object_desc", &tyStr)); ITKCALL(AOM_ask_value_string(rev, "object_desc", &tyStr));
ITKCALL(AOM_UIF_ask_value(rev, "zt2_State", &zt2_State)); ITKCALL(AOM_UIF_ask_value(rev, "zt2_State", &zt2_State));
if (strstr(tyStr, "停用")) {
//放入停用map if (strstr(zt2_State, "封存")) {
tyMap[zt2_MaterialNo] = object_name;
continue;
}
else if (strstr(zt2_State, "封存")) {
//放入封存map //放入封存map
fcMap[zt2_MaterialNo] = object_name; fcMap[zt2_MaterialNo] = object_name;
continue;
}
else if (strstr(tyStr, "停用")) {
//放入停用map
tyMap[zt2_MaterialNo] = object_name;
} }
} }
@ -235,36 +236,36 @@ int chint_check_materialstatus(EPM_action_message_t msg) {
if (strcmp(objectType, "ZT2_Design3DRevision") == 0) { if (strcmp(objectType, "ZT2_Design3DRevision") == 0) {
//获取关系文件夹下的物料 //获取关系文件夹下的物料
int wlNum; tag_t* wlTags; int wlNum; tag_t* wlTags;
ITKCALL(AOM_ask_value_tags(target, "representation_for", &wlNum, &wlTags)); ITKCALL(AOM_ask_value_tags(target, "representation_for", &wlNum, &wlTags));
printf("wlNum======%d\n", wlNum); printf("wlNum======%d\n", wlNum);
for (int j = 0; j < wlNum; j++) { for (int j = 0; j < wlNum; j++) {
//获取rev属性判断 //获取rev属性判断
char* objectType_rev = NULL; char* objectType_rev = NULL;
ITKCALL(AOM_ask_value_string(wlTags[j], "object_type", &objectType_rev)); ITKCALL(AOM_ask_value_string(wlTags[j], "object_type", &objectType_rev));
//物料 //物料
printf("objectType_rev======%s\n", objectType_rev); printf("objectType_rev======%s\n", objectType_rev);
if (strcmp(objectType_rev, "Part Revision") == 0) { if (strcmp(objectType_rev, "Part Revision") == 0) {
//获取物料编码和物料名称 //获取物料编码和物料名称
char* zt2_MaterialNo = NULL; char* zt2_MaterialNo = NULL;
char* object_name = NULL; char* object_name = NULL;
ITKCALL(AOM_ask_value_string(wlTags[j], "object_name", &object_name)); ITKCALL(AOM_ask_value_string(wlTags[j], "object_name", &object_name));
ITKCALL(AOM_ask_value_string(wlTags[j], "zt2_MaterialNo", &zt2_MaterialNo)); ITKCALL(AOM_ask_value_string(wlTags[j], "zt2_MaterialNo", &zt2_MaterialNo));
ITKCALL(AOM_ask_value_string(wlTags[j], "object_desc", &tyStr)); ITKCALL(AOM_ask_value_string(wlTags[j], "object_desc", &tyStr));
ITKCALL(AOM_UIF_ask_value(wlTags[j], "zt2_State", &zt2_State)); ITKCALL(AOM_UIF_ask_value(wlTags[j], "zt2_State", &zt2_State));
printf("zt2_State======%s\n", zt2_State); printf("zt2_State======%s\n", zt2_State);
if (strstr(tyStr, "停用")) { if (strstr(tyStr, "停用")) {
//放入停用map //放入停用map
tyMap[zt2_MaterialNo] = object_name; tyMap[zt2_MaterialNo] = object_name;
printf("00000000000000000000000000\n"); printf("00000000000000000000000000\n");
continue; continue;
} }
else if (strstr(zt2_State, "封存")) { else if (strstr(zt2_State, "封存")) {
//放入封存map //放入封存map
fcMap[zt2_MaterialNo] = object_name; fcMap[zt2_MaterialNo] = object_name;
printf("11111111111111111111111111\n"); printf("11111111111111111111111111\n");
continue; continue;
} }
} }
} }
} }

@ -143,6 +143,61 @@ int chint_ecn_signoff(EPM_action_message_t msg) {
EMH_store_error(EMH_severity_error, ifail); EMH_store_error(EMH_severity_error, ifail);
return ifail; return ifail;
} }
//lidy20240531不是指派了dcproxy 那么会签就取这个节点对应人员的会签时间
int cnt = 0;
tag_t ptask = NULLTAG, flow = NULLTAG, *sub_tasks = NULLTAG, hq_task = NULLTAG;
//ITKCALL(EPM_ask_parent_task(msg.task, &flow));
ITKCALL(EPM_ask_root_task(msg.task, &flow));
ITKCALL(EPM_ask_sub_tasks(flow, &cnt, &sub_tasks));
for (int i = 0; i < cnt; i++) {
char *os = NULL;
ITKCALL(AOM_ask_value_string(sub_tasks[i], "object_name", &os));
printf("sub_tasks:%s\n", os);
if (tc_strcmp(os, "会签") == 0) {
int cnt2 = 0;
tag_t *sub_tasks2 = NULLTAG;
ITKCALL(EPM_ask_sub_tasks(sub_tasks[i], &cnt2, &sub_tasks2));
for (int j = 0; j < cnt2; j++) {
char *type = NULL;
ITKCALL(WSOM_ask_object_type2(sub_tasks2[j], &type));
if (tc_strcmp(type, "EPMPerformSignoffTask") == 0) {
hq_task = sub_tasks2[j];
}
}
break;
}
}
int num = 0;
tag_t responsibleParty = NULLTAG, *signoff_attachments = NULLTAG;
//ITKCALL(EPM_ask_responsible_party(msg.task, &responsibleParty));
bool dcproxy = false;
string huiqian = "";
if (hq_task != NULLTAG) {
ITKCALL(AOM_ask_value_tags(hq_task, "signoff_attachments", &num, &signoff_attachments));
printf("signoff_attachments:%d\n", num);
for (int i = 0; i < num; i++) {
SIGNOFF_TYPE_t type;
EPM_signoff_decision_t decision;
tag_t member = NULLTAG, user = NULLTAG;
date_t date;
char *comment = NULL;
ITKCALL(EPM_ask_signoff_member(signoff_attachments[i], &member, &type));
ITKCALL(EPM_ask_signoff_decision(signoff_attachments[i], &decision, &comment, &date));
char *mem = NULL, *dates = NULL;
ITKCALL(AOM_ask_value_tag(member, "user", &user));
ITKCALL(AOM_UIF_ask_value(user, "user_name", &mem));
if (tc_strcmp(mem, "dcproxy") == 0) {
dcproxy = true;
break;
}
ITKCALL(DATE_date_to_string(date, "%Y-%m-%d", &dates));// %H-%M-%S
printf("decision:%s==%s\n", mem, dates);
if (huiqian.size() > 0)
huiqian.append(" ");
huiqian.append(mem).append(dates);
}
}
ITKCALL(EPM_ask_root_task(msg.task, &root_task)); ITKCALL(EPM_ask_root_task(msg.task, &root_task));
ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &targets)); ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &targets));
for (int t = 0; t < occur_of_counts; t++) { for (int t = 0; t < occur_of_counts; t++) {
@ -151,9 +206,6 @@ int chint_ecn_signoff(EPM_action_message_t msg) {
if (tc_strcmp(type, "ZT2_Change") != 0) { if (tc_strcmp(type, "ZT2_Change") != 0) {
continue; continue;
} }
char* id = NULL;
ITKCALL(AOM_ask_value_string(targets[t], "item_id", &id));
printf("id ===>%s\n", id);
/*if (tc_strcmp(task_name, "»áÇ©") == 0) { /*if (tc_strcmp(task_name, "»áÇ©") == 0) {
ITKCALL(AOM_set_value_string(targets[t], "zt2_Countersign", name.c_str())); ITKCALL(AOM_set_value_string(targets[t], "zt2_Countersign", name.c_str()));
char now_date_str[128 + 1] = { "\0" }; char now_date_str[128 + 1] = { "\0" };
@ -163,31 +215,40 @@ int chint_ecn_signoff(EPM_action_message_t msg) {
printf("now_date_str ===>%s\n", now_date_str); printf("now_date_str ===>%s\n", now_date_str);
ITKCALL(AOM_set_value_string(targets[t], "zt2_CountersignTime", now_date_str)); ITKCALL(AOM_set_value_string(targets[t], "zt2_CountersignTime", now_date_str));
}*/ }*/
string sql = "select \"principal\" FROM CHINT_ECN_NOTIFICATION where \"result\"='ÊÇ' and \"ecncode\"='"; char* id = NULL;
sql.append(id).append("'"); ITKCALL(AOM_ask_value_string(targets[t], "item_id", &id));
int outputColumn1 = 0, outputValueCount1 = 0; printf("id ===>%s\n", id);
char*** outputValue1 = NULL; string name = "";
printf("sql ===>%s\n", sql.c_str()); if (dcproxy) {
QuerySQLNoInputParam((char*)sql.c_str(), &outputColumn1, &outputValueCount1, &outputValue1); vector<string> name_vec;
vector<string> name_vec; string sql = "select \"principal\",\"coudata\" FROM CHINT_ECN_NOTIFICATION where \"result\"='是' and \"ecncode\"='";
for (int i = 0; i < outputValueCount1; i++) { sql.append(id).append("'");
vector<string> names; int outputColumn1 = 0, outputValueCount1 = 0;
if (tc_strstr(outputValue1[i][0], ":") == NULL) { char*** outputValue1 = NULL;
Split(outputValue1[i][0], ";", names); printf("sql ===>%s\n", sql.c_str());
QuerySQLNoInputParam((char*)sql.c_str(), &outputColumn1, &outputValueCount1, &outputValue1);
for (int i = 0; i < outputValueCount1; i++) {
vector<string> names;
if (tc_strstr(outputValue1[i][0], ":") == NULL) {
Split(outputValue1[i][0], ";", names);
}
else {
Split(outputValue1[i][0], ":", names);
}
string name_date = names[0].append(outputValue1[i][1]);
if (find(name_vec.begin(), name_vec.end(), name_date) == name_vec.end())
name_vec.push_back(name_date);
} }
else { for (int i = 0; i < name_vec.size(); i++) {
Split(outputValue1[i][0], ":", names); if (name.size() > 0)
name.append(" ");
name.append(name_vec[i]);
} }
if (find(name_vec.begin(), name_vec.end(), names[0]) == name_vec.end()) printf("name ===>%s\n", name.c_str());
name_vec.push_back(names[0]);
} }
string name = ""; else {
for (int i = 0; i < name_vec.size(); i++) { name.append(huiqian);
if (name.size() > 0)
name.append(" ");
name.append(name_vec[i]);
} }
printf("name ===>%s\n", name.c_str());
tag_t *datasets = NULL; tag_t *datasets = NULL;
int cnt = 0; int cnt = 0;

@ -65,6 +65,11 @@ int chint_ecn_assign(EPM_action_message_t msg);
int CHINT_DRAWING_TO_SRM(EPM_action_message_t msg); int CHINT_DRAWING_TO_SRM(EPM_action_message_t msg);
int chint_changenotice(EPM_action_message_t msg); int chint_changenotice(EPM_action_message_t msg);
int chint_check_materialstatus(EPM_action_message_t msg); int chint_check_materialstatus(EPM_action_message_t msg);
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);
//user service end //user service end
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -320,6 +320,33 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar
printf("Registering action handler chint_check_materialstatus failed %d\n", ifail); printf("Registering action handler chint_check_materialstatus failed %d\n", ifail);
} }
//飞书通知bm
ITKCALL(ifail = EPM_register_action_handler("chint_changenoticebm", "chint_changenoticebm", (EPM_action_handler_t)chint_changenoticebm));
if (ifail == 0) {
printf("Registering action handler chint_changenoticebm successful\n");
}
else {
printf("Registering action handler chint_changenoticebm failed %d\n", ifail);
}
//PLM推送变更通知单数据流信息
ITKCALL(ifail = EPM_register_action_handler("CHINT_CHANGEITEM_TO_SRM", "CHINT_CHANGEITEM_TO_SRM", (EPM_action_handler_t)CHINT_CHANGEITEM_TO_SRM));
if (ifail == 0) {
printf("Registering action handler CHINT_CHANGEITEM_TO_SRM successful\n");
}
else {
printf("Registering action handler CHINT_CHANGEITEM_TO_SRM failed %d\n", ifail);
}
//PLM推送BOM差异表数据流信息
ITKCALL(ifail = EPM_register_action_handler("CHINT_CHANGEBOM_TO_SRM", "CHINT_CHANGEBOM_TO_SRM", (EPM_action_handler_t)CHINT_CHANGEBOM_TO_SRM));
if (ifail == 0) {
printf("Registering action handler CHINT_CHANGEBOM_TO_SRM successful\n");
}
else {
printf("Registering action handler CHINT_CHANGEBOM_TO_SRM failed %d\n", ifail);
}
return ifail; return ifail;
} }
// //
@ -329,7 +356,7 @@ extern DLLAPI int USERSERVICE_custom_register_methods(int *decision, va_list arg
{ {
{ //2023 12 27 新增项目更新后操作 { //2023 12 27 新增项目更新后操作
METHOD_id_t mth_tag; METHOD_id_t mth_tag;
METHOD_find_method("Item", "IMAN_save", &mth_tag); ITKCALL(METHOD_find_method("Item", "IMAN_save", &mth_tag));
if (mth_tag.id != 0) { if (mth_tag.id != 0) {
METHOD_add_action(mth_tag, METHOD_post_action_type, (METHOD_function_t)CHINT_SavePost, NULL); METHOD_add_action(mth_tag, METHOD_post_action_type, (METHOD_function_t)CHINT_SavePost, NULL);
printf("注册ItemRevision函数成功\n"); printf("注册ItemRevision函数成功\n");
@ -459,6 +486,28 @@ extern DLLAPI int USERSERVICE_custom_register_methods(int *decision, va_list arg
} }
MEM_free(argumentList); MEM_free(argumentList);
} }
{
//武汉组织BOM汇总清单接口改为C组织数据
int numberOfArguments = 1;
int returnValueType = USERARG_STRING_TYPE;
int *argumentList = NULL;
USER_function_t functionPtr = NULL;
functionPtr = getBomDetails;
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int));
argumentList[0] = USERARG_STRING_TYPE;
int status = USERSERVICE_register_method("getBomDetails", functionPtr,
numberOfArguments, argumentList, returnValueType);
if (status == ITK_ok)
{
printf("Registering getBomDetails finished\n");
}
else
{
printf("Registering getBomDetails failed %d\n", status);
}
MEM_free(argumentList);
}
return ITK_ok; return ITK_ok;
} }

@ -0,0 +1,281 @@
#include "epm_handler_common.h"
#include <unidefs.h>
#include <tc/tc_macros.h>
#include <ict/ict_userservice.h>
#include <qry/qry.h>
#include <tccore/aom_prop.h>
#include <map>
#include "cJSON.h"
#include "tc_log.h"
#include "tc_util.h"
using namespace std;
/**
*
*
* @param material
* @return
*/
boolean isOutBuy(tag_t material) {
int factory = 0, procure = 0;
char **zt2_SZFactory = NULL, **zt2_SZProcuretype = NULL;
ITKCALL(AOM_UIF_ask_values(material, "zt2_SZFactory", &factory, &zt2_SZFactory));
ITKCALL(AOM_UIF_ask_values(material, "zt2_SZProcuretype", &procure, &zt2_SZProcuretype));
for (int i = 0; i < factory; i++) {
if (tc_strcmp(zt2_SZFactory[i], "M060") == 0 && procure > i && tc_strcmp(zt2_SZProcuretype[i], "外购") == 0) {
return true;
}
}
return false;
}
/**
* BOM
*
* @param parentLine BOM
* @param itemRevOfBOMLine BOM
* @param materialMap Map -
* @param qty
* @param level BOM
*/
void getProcessBomMsg(tag_t parentLine, tag_t itemRevOfBOMLine, map<string, double>& materialMap, vector<string>& materialVec, double qty, int level) {
char *material = NULL;
//ITKCALL(AOM_UIF_ask_value(itemRevOfBOMLine, "zt2_MaterialNo", &material));
ITK__convert_tag_to_uid(itemRevOfBOMLine, &material);
WriteTcLog("GetBomDetails getProcessBomMsg = %s", material);
char *blQty = NULL;
double qtyDouble = 1.0;
ITKCALL(AOM_UIF_ask_value(parentLine, "bl_quantity", &blQty));
if (blQty && tc_strlen(blQty) > 0) {
qtyDouble = atof(blQty);
}
// 0为工艺层1、2为工序层3为辅料层
if (level == 3) {
char *bl_occ_type = NULL;
ITKCALL(AOM_UIF_ask_value(parentLine, "bl_occ_type", &bl_occ_type));
if (tc_strcmp(bl_occ_type, "Fu Liao") != 0)
return;
char *materialNo = NULL;
ITKCALL(AOM_UIF_ask_value(itemRevOfBOMLine, "zt2_MaterialNo", &materialNo));
if (materialMap.count(materialNo) > 0) {
double q = materialMap[materialNo];
materialMap[materialNo] = q + qty * qtyDouble;
}
else {
materialVec.push_back(materialNo);
materialMap[materialNo] = qty * qtyDouble;
}
}
else {
//获取当前层级数量,然后累乘
int c_line_count = 0;
tag_t* c_line_tags = NULLTAG;
ITKCALL(BOM_line_ask_all_child_lines(parentLine, &c_line_count, &c_line_tags));
for (int i = 0; i < c_line_count; i++) {
tag_t rev2 = NULLTAG;
ITKCALL(AOM_ask_value_tag(c_line_tags[i], "bl_line_object", &rev2));
getProcessBomMsg(c_line_tags[i], rev2, materialMap, materialVec, qty * qtyDouble, level + 1);
}
}
}
/**
* BOM
*
* @param parentLine BOM
* @param itemRevOfBOMLine BOM
* @param materialMap Map -
* @param qty
*/
void getChildBomMsg(tag_t parentLine, tag_t itemRevOfBOMLine, map<string, double>& materialMap, vector<string>& materialVec, double qty) {
char *material = NULL;
ITKCALL(AOM_UIF_ask_value(itemRevOfBOMLine, "zt2_MaterialNo", &material));
//ITK__convert_tag_to_uid(itemRevOfBOMLine, &material);
WriteTcLog("GetBomDetails getChildBomMsg = %s", material);
int n_references = 0;
int* levels = 0;
tag_t* references_tag;
char** relation_type_name = NULL;
//通过出厂编号查找到图纸
ITKCALL(WSOM_where_referenced(itemRevOfBOMLine, 1, &n_references, &levels, &references_tag, &relation_type_name));
tag_t procModel = NULLTAG;
for (int i = 0; i < n_references; i++) {
if (tc_strcmp(relation_type_name[i], "IMAN_METarget") == 0) {
procModel = references_tag[i];
break;
}
}
if (procModel != NULLTAG) {
WriteTcLog("procModel != NULLTAG");
tag_t bom_window = NULLTAG, topLine = NULLTAG;
ITKCALL(BOM_create_window(&bom_window));
ITKCALL(BOM_set_window_top_line(bom_window, NULL, procModel, NULLTAG, &topLine));
getProcessBomMsg(topLine, procModel, materialMap, materialVec, 1.0, 0);
ITKCALL(BOM_close_window(bom_window));
}
char *blQty = NULL;
double qtyDouble = 1.0;
ITKCALL(AOM_UIF_ask_value(parentLine, "bl_quantity", &blQty));
if (blQty && tc_strlen(blQty) > 0) {
qtyDouble = atof(blQty);
}
// 数量为0为底层数据
int c_line_count = 0;
tag_t* c_line_tags = NULLTAG;
ITKCALL(BOM_line_ask_all_child_lines(parentLine, &c_line_count, &c_line_tags));
WriteTcLog("GetBomDetails c_line_count = %d", c_line_count);
if (c_line_count == 0) {
if (!isOutBuy(itemRevOfBOMLine))
return;
if (materialMap.count(material) > 0) {
double q = materialMap[material];
materialMap[material] = q + qty * qtyDouble;
}
else {
materialVec.push_back(material);
materialMap[material] = qty * qtyDouble;
}
}
else {
WriteTcLog("GetBomDetails 开始遍历");
for (int i = 0; i < c_line_count; i++) {
tag_t rev2 = NULLTAG;
ITKCALL(AOM_ask_value_tag(c_line_tags[i], "bl_line_object", &rev2));
getChildBomMsg(c_line_tags[i], rev2, materialMap, materialVec, qty * qtyDouble);
}
WriteTcLog("GetBomDetails 结束遍历");
}
}
//武汉组织BOM汇总清单接口改为C组织数据
int getBomDetails(void *returnValue) {
string log_path = getenv("TEMP");
log_path.append("\\getBomDetails").append(getNow("yyyyMMddHHmmss")).append(".log");
CreateTcLogFile(log_path.c_str());
WriteTcLog("******************* getBomDetails start2 %s *******************", getNow("LOG").c_str());
int ifail = ITK_ok;
char* jsonObject = NULL;
ITKCALL(USERARG_get_string_argument(&jsonObject));
WriteTcLog("GetBomDetails 入参===>%s", jsonObject);
cJSON* jsonObject1 = cJSON_Parse(jsonObject);
//产成品物料编码 WBS号
char* wbsNo = cJSON_GetObjectItem(jsonObject1, "wbsno")->valuestring;
char* materialNo = cJSON_GetObjectItem(jsonObject1, "ccpmaterialno")->valuestring;
//返回信息
cJSON* result = cJSON_CreateObject();
cJSON_AddStringToObject(result, "wbsno", wbsNo);
cJSON_AddStringToObject(result, "ccpmaterialno", materialNo);
//查询物料
tag_t query_tag = NULLTAG;
ITKCALL(QRY_find2("chint_query_material_getbomdetails", &query_tag));//chint_query_material_test
if (query_tag == NULL) {
printf("Could not found query:chint_query_material_getbomdetails\n");
cJSON_AddStringToObject(result, "code", "500");
cJSON_AddStringToObject(result, "msg", "Could not found query:chint_query_material_getbomdetails");
return ifail;
}
char **qkey = NULL, **qvalue = NULL;
int num_found = 0;//查询结果数量
tag_t *modelObjects = NULL;//查询结果集
const char *key1 = "materialno", *key2 = "wbsno";//WBS No//WBS号
qkey = (char **)MEM_alloc(2 * sizeof(char*));
qvalue = (char **)MEM_alloc(2 * sizeof(char*));
qkey[0] = (char *)MEM_alloc((tc_strlen(key1) + 1)*sizeof(char));
qvalue[0] = (char *)MEM_alloc((tc_strlen(materialNo) + 1)*sizeof(char));
tc_strcpy(qkey[0], key1);
tc_strcpy(qvalue[0], materialNo);
qkey[1] = (char *)MEM_alloc((tc_strlen(key2) + 1)*sizeof(char));
qvalue[1] = (char *)MEM_alloc((tc_strlen(wbsNo) + 1)*sizeof(char));
tc_strcpy(qkey[1], key2);
tc_strcpy(qvalue[1], wbsNo);
ITKCALL(QRY_execute(query_tag, 2, qkey, qvalue, &num_found, &modelObjects));
WriteTcLog("GetBomDetails 查询===>%d", num_found);
if (num_found == 0) {
//没有查询到产成品 返回500
cJSON_AddStringToObject(result, "code", "500");
cJSON_AddStringToObject(result, "msg", "数据组织失败");
}
else {
//查询到产成品 返回200 如果有P物料获取P物料
cJSON_AddStringToObject(result, "code", "200");
cJSON_AddStringToObject(result, "msg", "成功组织数据");
//BOM全展开 获取到底层物料 数量累乘 相同物料合并数量 物料查询查的版本
tag_t ccpRevision = NULLTAG;
//如果有P物料遍历P物料的BOM
for (int i = 0; i < num_found; i++) {
char *os = NULL, *ifPbom = NULL;
//ITKCALL(AOM_UIF_ask_value(modelObjects[i], "object_string", &os));
ITK__convert_tag_to_uid(modelObjects[i], &os);
WriteTcLog("GetBomDetails 查询===>%s", os);
ITKCALL(AOM_UIF_ask_value(modelObjects[i], "zt2_ifpbom", &ifPbom));
if (tc_strcmp(ifPbom, "P") == 0) {
ccpRevision = modelObjects[i];
break;
}
}
if (ccpRevision == NULLTAG)
ccpRevision = modelObjects[0];
//遍历
char *ztQuantity = NULL;
ITKCALL(AOM_UIF_ask_value(ccpRevision, "zt2_Quantity", &ztQuantity));
if (!ztQuantity || tc_strlen(ztQuantity) == 0) {
DOFREE(ztQuantity);
ztQuantity = (char *)MEM_alloc(2 * sizeof(char));
tc_strcpy(ztQuantity, "1");
}
tag_t bom_window = NULLTAG, topLine = NULLTAG;
ITKCALL(BOM_create_window(&bom_window));
ITKCALL(BOM_set_window_top_line(bom_window, NULL, ccpRevision, NULLTAG, &topLine));
map<string, double> materialMap;
vector<string> materialVec;
getChildBomMsg(topLine, ccpRevision, materialMap, materialVec, 1.0);
ITKCALL(BOM_close_window(bom_window));
//信息搭建JSON
cJSON* array = cJSON_CreateArray();
cJSON_AddStringToObject(result, "ccpquantity", ztQuantity);
cJSON* factoryno = cJSON_GetObjectItem(jsonObject1, "factoryno");
if (factoryno) {
cJSON_AddStringToObject(result, "factoryno", factoryno->valuestring);
}
else {
cJSON_AddStringToObject(result, "factoryno", "");
}
WriteTcLog("GetBomDetails materialVec===>%zd", materialVec.size());
//map<string, double>::iterator it;
//for (it = materialMap.begin(); it != materialMap.end(); it++) {
for (int i = 0; i < materialVec.size(); i++) {
//string key = it->first;
string key = materialVec[i];
double qty = materialMap[key];
cJSON* object = cJSON_CreateObject();
char no_str[4] = "";
sprintf(no_str, "%03d", i + 1);
cJSON_AddStringToObject(object, "no", no_str);
cJSON_AddStringToObject(object, "materialno", key.c_str());
char qty_str[16] = "";
sprintf(qty_str, "%.3f", qty);
cJSON_AddStringToObject(object, "quantity", qty_str);
cJSON_AddItemToArray(array, object);
}
cJSON_AddItemToObject(result, "contents", array);
}
char *json_to_char = cJSON_Print(result);
string msg = "GetBomDetails json_to_char===>";
msg.append(json_to_char);
WriteTcLog2(msg);
//string buff = "";
*((char**)returnValue) = (char*)MEM_alloc((tc_strlen(json_to_char) + 1) * sizeof(char));
tc_strcpy(*((char**)returnValue), json_to_char);
//WriteTcLog("GetBomDetails 返回");
cJSON_Delete(result);
cJSON_Delete(jsonObject1);
//WriteTcLog("GetBomDetails log关闭");
CloseTcLog();
//printf("GetBomDetails end");
return ifail;
}

@ -14,9 +14,9 @@
#include <fclasses/tc_string.h> #include <fclasses/tc_string.h>
#include <stdlib.h> #include <stdlib.h>
#include <string>
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include <string>
using namespace std; using namespace std;
// //
#ifdef WIN32 #ifdef WIN32
@ -103,6 +103,17 @@ void WriteTcLog(const char* format, ...)
} }
} }
void WriteTcLog2(string msg) {
if (log_file) {
printf("%s\n", msg.c_str());
fprintf(log_file, "%s\n", msg.c_str());
fflush(log_file);
}
else {
printf("*!Error!*: Log File Not Exist\n");
}
}
void CloseTcLog(void) void CloseTcLog(void)
{ {
if(log_file) if(log_file)
@ -153,5 +164,13 @@ string getNow(char* format) {
.append(getNum(tm_t->tm_min)).append(":") .append(getNum(tm_t->tm_min)).append(":")
.append(getNum(tm_t->tm_sec)); .append(getNum(tm_t->tm_sec));
} }
else if (tc_strcmp(format, "yyyyMMddHHmmss") == 0) {//yyyy-MM-dd HH:mi:ss
str.append(to_string(tm_t->tm_year + 1900))
.append(getNum(tm_t->tm_mon + 1))
.append(getNum(tm_t->tm_mday))
.append(getNum(tm_t->tm_hour))
.append(getNum(tm_t->tm_min))
.append(getNum(tm_t->tm_sec));
}
return str; return str;
} }

@ -17,6 +17,7 @@ extern "C" {
void CreateTcLogFile(const char* logFileName); void CreateTcLogFile(const char* logFileName);
void WriteTcLog(const char* format, ...); void WriteTcLog(const char* format, ...);
void WriteTcLog2(string msg);
void CloseTcLog(void); void CloseTcLog(void);
void log_open(void); void log_open(void);
void log_close(void); void log_close(void);

@ -84,3 +84,6 @@ void ECHO(char *format, ...);
} }
int ITEM_list_all_revs_alpha(tag_t item_tag,int *rev_cnt,tag_t **revs); int ITEM_list_all_revs_alpha(tag_t item_tag,int *rev_cnt,tag_t **revs);
char* G2U(const char* gb2312);
char* U2G(const char* utf8);
Loading…
Cancel
Save