#include "util.h" #include "test.h" #include #include #include #include #include struct user_info { string time; string img_path; string id; bool operator < (const user_info &a) const { return a.id < id; } }; int wx_signoff2(tag_t task) { //USES_CONVERSION; int index, size, att_count, rowFirst, rowLast, colFirst, colLast, pref_count, forms_count; //Book* book = nullptr; tag_t img_tag, rootTask, *attachments, type_tag, word_tag, wordx_tag, ref_obj, excel_ref, excel_tag, excelx_tag, user_tag, person_tag, forms_tag, *forms_tags; char *comp_name, *type_class, *temp_path, *user_name, **pref_val, *wx3_psbm = nullptr, *wx3_psr = nullptr, *wx3_fwdw = nullptr, *wx3_qsr = nullptr; //森威新增 char *wx3_jgb = NULLTAG, *wx3_cgb = NULLTAG, *wx3_cwb = NULLTAG, *wx3_jdb = NULLTAG, *wx3_jszx = NULLTAG, *wx3_mjzx = NULLTAG, *wx3_scb = NULLTAG, *wx3_scwlzx = NULLTAG, *wx3_zlb = NULLTAG; date_t creation_date; string wx_empty; time_t t; time(&t); tm* local = localtime(&t); string pre, cmp, bz_val, bz_date_val, word_path; vector empty_imgs, wx_vec, wx_sw; map user_map, role_sign_map; map> role_map; map role_is_sign_map; vector> user_info_vec2; map>> map_user_info_vec; map>> map_user_info_ids; vector> user_id_set; AE_reference_type_t ae_ref; for (auto i = 0; i < 6; i++) { vector temp; set temp_set; user_id_set.push_back(temp_set); user_info_vec2.push_back(temp); } TCHAR *excel_names[6] = { L"编制", L"会签", L"审核", L"批准", L"校对", L"标准化" }; TCHAR *excel_dates[6] = { L"编制日期", L"会签日期", L"审核日期", L"批准日期", L"校对日期", L"标准化日期" }; char *img_suffix[6] = { "编制人.jpg", "会签人.jpg", "审核人.jpg", "批准人.jpg", "校对人.jpg", "标准化人.jpg" }; char *word_names[6] = { "编制人", "会签人", "审核人", "批准人", "校对人", "标准化人" }; char *word_times[6] = { "编制日期", "会签日期", "审核日期", "批准日期", "校对日期", "标准化日期" }; char *date_suffix[5] = { " \\* MERGEFORMAT", "", " \\@ \"yyyy-MM-dd\"", " \\@ \"yyyy-MM-DD\"", " \\@ \"YYYY-MM-dd\"" }; char *reviews[5] = { "质量", "设计", "工艺", "生产", "财务" }; POM_AM__set_application_bypass(true); EPM_ask_root_task(task, &rootTask); PREF_ask_char_values("WXSignoffMapping", &pref_count, &pref_val); AOM_ask_owner(rootTask, &user_tag); SA_ask_user_identifier2(user_tag, &user_name); SA_ask_user_person(user_tag, &person_tag); SA_ask_person_attribute2(person_tag, "PA6", &comp_name); for (auto i = 0; i < pref_count; i++) { string str(pref_val[i]); index = str.find('='); if (index != -1) { printf("user_map[%s] = %s\n", str.substr(0, index), str.substr(index + 1)); user_map[str.substr(0, index)] = str.substr(index + 1); } } if (pref_count) MEM_free(pref_val); PREF_ask_char_values("WXGroupNameMapping", &pref_count, &pref_val); if (comp_name && strlen(comp_name) > 0) { cmp = comp_name; for (auto i = 0; i < pref_count; i++) { string str(pref_val[i]); if (str.find(comp_name) != -1) { int index1 = str.find(','); if (index1 == -1) break; int index2 = str.find(',', index1 + 1); if (index2 == -1) break; cmp = str.substr(index1 + 1, index2 - index1 - 1); break; } } MEM_free(comp_name); } if (pref_count) MEM_free(pref_val); PREF_ask_char_values("WX_ECR_RoleMapping", &pref_count, &pref_val); for (auto i = 0; i < pref_count; i++) { string str(pref_val[i]); int index = str.find('='); if (index == -1) continue; vector temp; split(str.substr(index + 1), ",", &temp); role_map[str.substr(0, index)] = temp; } if (pref_count) MEM_free(pref_val); TCTYPE_find_type("MSExcelX", "Dataset", &excelx_tag); TCTYPE_find_type("MSExcel", "Dataset", &excel_tag); TCTYPE_find_type("MSWord", "Dataset", &word_tag); TCTYPE_find_type("MSWordX", "Dataset", &wordx_tag); temp_path = getenv("temp"); { stringstream ss; ss << temp_path; ss << "\\export"; ss << local->tm_year; ss << local->tm_mon; ss << local->tm_mday; ss << local->tm_hour; ss << local->tm_min; ss << local->tm_sec; pre = ss.str(); } char * temp_date_val; AOM_UIF_ask_value(rootTask, "creation_date", &temp_date_val); stringstream temp_date_ss; int len = strlen(temp_date_val); for (auto i = 0; i < len; i++) { if (temp_date_val[i] == ' ') break; if (temp_date_val[i + 1] == '-'&&temp_date_val[i - 1] == '-') temp_date_ss << '0'; temp_date_ss << temp_date_val[i]; } bz_date_val = temp_date_ss.str(); printf("bz_date_val:%s\n", bz_date_val.c_str()); ITK__convert_uid_to_tag(user_map[user_name].c_str(), &img_tag); char *object_name; if (img_tag != NULLTAG) { AE_ask_dataset_named_ref2(img_tag, "Image", &ae_ref, &ref_obj); stringstream img_path; img_path << pre; img_path << user_name; MEM_free(user_name); img_path << "编制人.jpg"; IMF_export_file(ref_obj, img_path.str().c_str()); bz_val = img_path.str(); printf("bz_val:%s\n", bz_val.c_str()); } EPM_ask_attachments(rootTask, EPM_target_attachment, &att_count, &attachments); for (auto i = 0; i < att_count; i++) { if (checkIsTypeOrSubtype(attachments[i], "ChangeRequestRevision")) { printf("ChangeRequestRevision属性获取\n"); AOM_ask_value_string(attachments[i], "wx3_psbm", &wx3_psbm); AOM_ask_value_string(attachments[i], "wx3_psr", &wx3_psr); AOM_ask_value_tags(attachments[i], "IMAN_master_form_rev", &forms_count, &forms_tags);//获取子件的版本主表单 if (forms_count > 0) { forms_tag = forms_tags[0]; //森威新增 AOM_ask_value_string(forms_tag, "wx3_ggpsr_cgb", &wx3_cgb); AOM_ask_value_string(forms_tag, "wx3_ggpsr_cwb", &wx3_cwb); AOM_ask_value_string(forms_tag, "wx3_ggpsr_jdb", &wx3_jdb); AOM_ask_value_string(forms_tag, "wx3_ggpsr_jgb", &wx3_jgb); AOM_ask_value_string(forms_tag, "wx3_ggpsr_jszx", &wx3_jszx); AOM_ask_value_string(forms_tag, "wx3_ggpsr_mjzx", &wx3_mjzx); AOM_ask_value_string(forms_tag, "wx3_ggpsr_scb", &wx3_scb); AOM_ask_value_string(forms_tag, "wx3_ggpsr_scwlzx", &wx3_scwlzx); AOM_ask_value_string(forms_tag, "wx3_ggpsr_zlb", &wx3_zlb); printf("wx3_cgb:%s\n", wx3_cgb); printf("wx3_cwb:%s\n", wx3_cwb); printf("wx3_jdb:%s\n", wx3_jdb); printf("wx3_jgb:%s\n", wx3_jgb); printf("wx3_jszx:%s\n", wx3_jszx); printf("wx3_mjzx:%s\n", wx3_mjzx); printf("wx3_scb:%s\n", wx3_scb); printf("wx3_scwlzx:%s\n", wx3_scwlzx); printf("wx3_zlb:%s\n", wx3_zlb); } split(wx3_psr, ",", &wx_vec); for (auto j = 0; j> user_info_vec; vector> user_info_ids; for (auto z = 0; z < 6; z++) { vector temp; user_info_vec.push_back(temp); vector ids; user_info_ids.push_back(ids); } AOM_ask_value_string(attachments[i],"object_name",&object_name); LINFO<<"对象"< temp_vec; split(temp, " ", &temp_vec); printf("temp_vec.size:%d\n", temp_vec.size()); for (auto j = 0; j < temp_vec.size(); j++) { index = temp_vec[j].find("="); if (index == -1) continue; vector temp_vec2; split(temp_vec[j].substr(index + 1), ",", &temp_vec2); index = temp_vec[j][0] - '0'; if (index > 6 || index < 0) continue; for (auto k = 0; k < temp_vec2.size(); k++) { user_info temp_info; int temp_index = temp_vec2[k].find(":"); if (temp_index == -1) continue; temp_info.id = temp_vec2[k].substr(0, temp_index); temp_info.time = temp_vec2[k].substr(temp_index + 1); user_id_set[index].insert(temp_info); map_user_info_ids[attachments[i]][index].push_back(temp_info.id); LINFO<<"对象"<id].c_str(), &img_tag); if (img_tag == NULLTAG) continue; AE_ask_dataset_named_ref2(img_tag, "Image", &ae_ref, &ref_obj); stringstream img_path; img_path << pre; img_path << j->id; img_path << img_suffix[i]; IMF_export_file(ref_obj, img_path.str().c_str()); user_info temp = *j; temp.img_path = img_path.str(); user_info_vec2[i].push_back(temp); for (auto it = map_user_info_ids.begin(); it != map_user_info_ids.end(); it++) { vector> user_info_ids = it->second; vector ids = user_info_ids[i]; if (find(ids.begin(), ids.end(), temp.id.c_str()) != ids.end()) { map_user_info_vec[it->first][i].push_back(temp); } } if (i == 2) { bool find = false; for (auto k = role_map.begin(); k != role_map.end(); k++) { for (auto l = 0; l < k->second.size(); l++) { if (k->second[l].find(j->id) != -1) { string temp_str = img_path.str(); int temp_index = temp_str.find(j->id); role_sign_map[k->first] = temp_str.substr(0, temp_index) + k->first + temp_str.substr(temp_index); find = true; IMF_export_file(ref_obj, role_sign_map[k->first].c_str()); printf("k->first:%s", k->first.c_str()); role_is_sign_map[k->first] = true; break; } } if (find) break; } } } } ITK__convert_uid_to_tag(user_map["empty"].c_str(), &img_tag); if (img_tag != NULLTAG) { AE_ask_dataset_named_ref2(img_tag, "Image", &ae_ref, &ref_obj); for (auto i = 0; i < 10; i++) { stringstream img_path; img_path << pre; img_path << "empty"; if (i >= 5) { img_path << reviews[i - 5]; img_path << img_suffix[2]; } else img_path << img_suffix[i]; IMF_export_file(ref_obj, img_path.str().c_str()); empty_imgs.push_back(img_path.str()); } if (tc_strlen(wx3_psr) || tc_strlen(wx3_qsr)) { stringstream img_path; img_path << pre; img_path << "empty"; img_path << (tc_strlen(wx3_psr) == 0 ? "评审人员" : "签收人"); img_path << ".jpg"; IMF_export_file(ref_obj, img_path.str().c_str()); wx_empty = img_path.str(); } } LINFO<<"-----遍历自定义Map---------------------------------"; int v_index = 0; for(auto it = map_user_info_vec.begin();it!=map_user_info_vec.end();it++) { AOM_ask_value_string(it->first,"object_name",&object_name); LINFO<<"第"<> user_info_vec; for (auto s = 0; s < cout; s++) { AOM_ask_value_string(refs[s],"object_name",&object_name); LINFO<<"第"<> user_info_vec; for (auto s = 0; s < cout; s++) { AOM_ask_value_string(refs[s],"object_name",&object_name); LINFO<<"第"< vecs = user_info_vec[f]; int f_vecs = vecs.size(); LINFO<<"第"<