You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

897 lines
29 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "Supor_register.h"
#define SIGN_RELATION "S8SignOffR"
#define SIGN_INFO_OPTION "Supor_signoff_dataset"
extern "C" int POM_AM__set_application_bypass(logical bypass);
using namespace std;
int getPrefStrings( const char *preference, vector<string> &pref_vec )
{
int ifail = ITK_ok , i = 0, j = 0, k =0, num = 0;
char **values;
ITKCALL2( ifail = PREF_ask_char_values( preference, &num, &values ) );
for(i = 0; i < num; i++)
{
pref_vec.push_back(values[i]);
}
DOFREE(values);
return ifail;
}
/**
*
* 判断某个对象是否为ItemRevision
*
*/
int checkIsItemRevision(tag_t objtag,logical & isItems){
tag_t type = NULLTAG;
tag_t item_type = NULLTAG;
ITKCALL2(TCTYPE_ask_object_type(objtag,&type));
ITKCALL2(TCTYPE_find_type("ItemRevision","",&item_type));
if(item_type != NULLTAG){
logical isok = FALSE;
ITKCALL2(TCTYPE_is_type_of(type,item_type,&isok));
if(isok){
isItems = TRUE;
}else{
isItems = FALSE;
}
}
return 0;
}
/**
* 用来拼接签名信息mapping为json
* paramMap 签名mapping
* jsonString 拼接后的json字符串
*/
int stringToJson(map<string,string> paramMap,string &jsonString)
{
std::map<string, string>::iterator iter;
jsonString.assign("{");
int tempIndex = 0;
int mapCount = paramMap.size();
for (iter=paramMap.begin(); iter!=paramMap.end(); iter++)
{
jsonString.append("\"");
jsonString.append(iter->first);
jsonString.append("\":\"");
jsonString.append(iter->second);
jsonString.append("\"");
if(tempIndex != (mapCount-1)){
jsonString.append(",");
}
tempIndex ++ ;
}
jsonString.append("}");
return 0;
}
/**
* 拼接电子签名字符串
* paramMap 签名对象信息
* paraName signinfos
* json 签名信息json
* jsonString 汇总签名信息
*/
int stringToJsonPlus(map<string,string> paramMap, string paraName,string json ,string &jsonString)
{
std::map<string, string>::iterator iter;
jsonString.assign("{");
for (iter=paramMap.begin(); iter!=paramMap.end(); iter++)
{
jsonString.append("\"");
jsonString.append(iter->first);
jsonString.append("\":\"");
jsonString.append(iter->second);
jsonString.append("\",");
}
jsonString.append("\"");
jsonString.append(paraName);
jsonString.append("\":");
jsonString.append(json);
jsonString.append("}");
return 0;
}
/**
* 拼接签名信息
* paramMap 签名对象信息
* signInfoMap 签名信息
* signJson 签名汇总信息json
*/
//void getSignoffInfoJson(map<string,string> paramMap ,map<string,string> signInfoMap,string &signJson)
//{
// string signInfo ;
// stringToJson(signInfoMap,signInfo);
// stringToJsonPlus(paramMap,"signinfos",signInfo,signJson);
//}
/**
* 获取签名信息到map
* revisionRevTag 版本对象
* signInfoMap 签名信息map
*/
void getSignoffInfoJson(tag_t revisionRevTag,map<string,string> &signInfoMap,char * processid,char *sign_relation,char *sign_info_option){
tag_t * signoffFormTags = NULL;
tag_t signFormTag = NULLTAG;
int signoffFormCount = 0;
char* tempValue = NULL;
ITKCALL2(AOM_ask_value_tags(revisionRevTag, sign_relation,&signoffFormCount,&signoffFormTags));
WriteLog("签名表单个数:%d\n",signoffFormCount);
if(signoffFormCount > 0){
signFormTag = signoffFormTags[0];
}
DOFREE(signoffFormTags);
if(signFormTag == NULLTAG){
WriteLog("没有获取到签名表单\n");
return;
}
vector<string> signoffVec ;
getPrefStrings(sign_info_option,signoffVec);
WriteLog("首选项[%s]=[%d]\n", sign_info_option,signoffVec.size());
for (int i = 0; i < signoffVec.size(); i++) {
vector<string> secondVec ;
Split(signoffVec[i],":",secondVec);
string signinfoValue ;
if(secondVec.size() !=2){
secondVec.clear();
continue;
}
if(strcmp(secondVec[0].c_str(),processid) != 0){
secondVec.clear();
continue;
}
signinfoValue.assign(secondVec[1]);
secondVec.clear();
Split( signinfoValue,";",secondVec);
for(int j = 0;j <secondVec.size();j++){
WriteLog("111\n");
vector<string> thirdVec ;
WriteLog("222\n");
Split( secondVec[j],"=",thirdVec);
WriteLog("333\n");
if(thirdVec.size() == 2){
PROP_value_type_t propertyValueType;
char * propertyType = NULL;
WriteLog("444\n");
ITKCALL2(AOM_ask_value_type(signFormTag,thirdVec[0].c_str(),&propertyValueType,&propertyType));
WriteLog("属性:%s\n", thirdVec[0].c_str());
if(propertyValueType == 8){
char valueTemp[128] = "\0";
ITKCALL2(AOM_ask_value_string(signFormTag,thirdVec[0].c_str(),&tempValue));
WriteLog("属性:%s, 内容:%s\n", thirdVec[0].c_str(), tempValue);
if (strcmp(ISNULL(tempValue), "") != 0) {
//char* tempValueGBK = tempValue;
// char* thirdVecGBK = thirdVec[1].c_str();
//sprintf(valueTemp, "%s%s%s", picpath, tempValueGBK, picext);
signInfoMap.insert(pair<string, string>(thirdVec[1], tempValue));
DOFREE(tempValue);
// DOFREE(tempValueGBK);
// DOFREE(thirdVecGBK);
}
}else if(propertyValueType == 2){
date_t date;
AOM_ask_value_date(signFormTag,thirdVec[0].c_str(),&date);
if(date.year > 1000){
// char* thirdVecGBK = thirdVec[1].c_str());
ITKCALL2(DATE_date_to_string(date,"%Y/%m/%d",&tempValue));
signInfoMap.insert(pair<string,string>(thirdVec[1],tempValue));
DOFREE(tempValue);
// DOFREE(thirdVecGBK);
}
}
DOFREE(propertyType);
}
thirdVec.clear();
}
secondVec.clear();
break;
}
}
void sendMessageToService(tag_t attachTag, tag_t rootTask,tag_t datasetTag,vector<string> parameterVec,string relation,string ismergepdf, string signInfo) {
string signJson;
char* tempValue = NULL;
char tcdepartmentid[56] = "\0",
tccomponentuid[56] = "\0",
tcdatasetuid[56] = "\0",
tccomponentrelation[56] = "\0",
userid[56] = "\0",
taskpuid[56] = "\0",
pdfuid[56] = "\0",
objectType[56] = "\0";
char issignpdf[56] = "\0",
dwgtype[56] = "\0",
tcpdfrelation[56] = "\0",
tcstatus[56] = "\0",
serverhost[56] = "\0",
isaddtask[16] = "\0",
isdwgtopdf[16] = "\0";
strcpy(issignpdf, parameterVec[0].c_str());
strcpy(dwgtype, parameterVec[1].c_str());
strcpy(tcpdfrelation, parameterVec[2].c_str());
strcpy(tcstatus, parameterVec[3].c_str());
strcpy(serverhost, parameterVec[6].c_str());
strcpy(tcdepartmentid, parameterVec[7].c_str());
strcpy(isaddtask, parameterVec[8].c_str());
strcpy(isdwgtopdf, parameterVec[9].c_str());
strcpy(tccomponentrelation,relation.c_str());
ITK__convert_tag_to_uid(attachTag, &tempValue);
tc_strcpy(tccomponentuid, tempValue);
DOFREE(tempValue);
ITK__convert_tag_to_uid(rootTask, &tempValue);
tc_strcpy(taskpuid, tempValue);
DOFREE(tempValue);
ITKCALL2(AOM_ask_value_string(datasetTag, "object_type", &tempValue));
tc_strcpy(objectType, tempValue);
DOFREE(tempValue);
map<string, string> inMap;
//数据集转换uid
ITK__convert_tag_to_uid(datasetTag, &tempValue);
tc_strcpy(tcdatasetuid, tempValue);
DOFREE(tempValue);
tag_t owningUser = NULLTAG;
ITKCALL2(AOM_ask_value_tag(datasetTag, "owning_user", &owningUser));
ITKCALL2(AOM_ask_value_string(owningUser, "user_id", &tempValue));
tc_strcpy(userid, tempValue);
DOFREE(tempValue);
WriteLog("添加的对象:%s添加的数据集%s,添加的关系%s\n", tccomponentuid, tcdatasetuid, tccomponentrelation);
WriteLog("类型是%s\n", objectType);
//如果数据集是PDF先判断是否是转PDF系统生成的
if (strcmp("PDF", objectType) == 0) {
char selectRecord[1024] = "";
int outputValueCount = 0, outputColumn = 0;
char*** outputValue = NULL;
sprintf(selectRecord, "select itempuid from CONNOR_PDFMESSAGE where pdfpuid='%s' and pdfpuid != datasetpuid ", tcdatasetuid);
if (QuerySQLNoInputParam(selectRecord, &outputColumn, &outputValueCount, &outputValue) != -1) {
if (outputValueCount > 0) {
WriteLog("是系统生成的,跳过:%s\n", tcdatasetuid);
return;
}
}
}
char selectRecord[1024] = "";
int outputValueCount = 0, outputColumn = 0;
char*** outputValue = NULL;
sprintf(selectRecord, "select itempuid,pdfpuid,tcstatus from CONNOR_PDFMESSAGE where itempuid='%s' and datasetpuid='%s' and tcstatus='%s'", tccomponentuid, tcdatasetuid, tcstatus);
WriteLog("查找的数据:%s\n", selectRecord);
if (QuerySQLNoInputParam(selectRecord, &outputColumn, &outputValueCount, &outputValue) != -1) {
WriteLog("查找的结果数量:%d\n", outputValueCount);
if (outputValueCount > 0) {
char updateRecord[1024] = "";
sprintf(updateRecord, "update CONNOR_PDFMESSAGE set taskpuid = :1,signinfo = :2,tcstatus=:3,stage=:4,createdate=sysdate where itempuid='%s' and datasetpuid = '%s' and tcstatus='%s'", tccomponentuid, tcdatasetuid, tcstatus);
WriteLog("更新数据:%s\n", updateRecord);
char** params = (char**)MEM_alloc(4 * sizeof(char*));
params[0] = taskpuid;
params[1] = (char*)signInfo.c_str();
params[2] = tcstatus;
params[3] = ("正在发送到服务");
if (ExecuteSQL(updateRecord, 4, params) == -1)
{
WriteLog("更新数据失败:%s", tcdatasetuid);
}
else
{
ExecuteSQLNoInputParam("commit");
WriteLog("更新数据成功");
}
if (strcmp("", outputValue[0][1]) == 0) {
tc_strcpy(pdfuid, "nopdf");
}
else
{
char selectRecord2[1024] = "";
int outputValueCount2 = 0, outputColumn2 = 0;
char*** outputValue2 = NULL;
sprintf(selectRecord2, "select puid from INFODBA.PPOM_APPLICATION_OBJECT where puid='%s'", outputValue[0][1]);
WriteLog("查找的数据:%s\n", selectRecord2);
if (QuerySQLNoInputParam(selectRecord2, &outputColumn2, &outputValueCount2, &outputValue2) != -1) {
if (outputValueCount2 > 0) {
tc_strcpy(pdfuid, outputValue[0][1]);
}
else
{
WriteLog("数据库查询出的PDF%s 已不存在\n", outputValue[0][1]);
tc_strcpy(pdfuid, "nopdf");
}
}
else
{
WriteLog("数据库查询PDF%s 失败\n", outputValue[0][1]);
tc_strcpy(pdfuid, "nopdf");
}
}
}
else {
char selectRecord3[1024] = "";
int outputValueCount3 = 0, outputColumn3 = 0;
char*** outputValue3 = NULL;
sprintf(selectRecord3, "select itempuid,pdfpuid,tcstatus from CONNOR_PDFMESSAGE where itempuid='%s' and datasetpuid='%s' and tcstatus is null", tccomponentuid, tcdatasetuid);
if (QuerySQLNoInputParam(selectRecord3, &outputColumn3, &outputValueCount3, &outputValue3) != -1) {
WriteLog("查找的结果数量:%d\n", outputValueCount3);
if (outputValueCount3> 0) {
char updateRecord[1024] = "";
sprintf(updateRecord, "update CONNOR_PDFMESSAGE set taskpuid = :1,signinfo = :2,tcstatus=:3,stage=:4,createdate=sysdate where itempuid='%s' and datasetpuid = '%s' and tcstatus is null", tccomponentuid, tcdatasetuid);
WriteLog("更新数据:%s\n", updateRecord);
char** params = (char**)MEM_alloc(4 * sizeof(char*));
params[0] = taskpuid;
params[1] = (char*)signInfo.c_str();
params[2] = tcstatus;
params[3] = ("正在发送到服务");
if (ExecuteSQL(updateRecord, 4, params) == -1)
{
WriteLog("更新数据失败:%s", tcdatasetuid);
}
else
{
ExecuteSQLNoInputParam("commit");
WriteLog("更新数据成功");
}
if (strcmp("", outputValue3[0][1]) == 0) {
tc_strcpy(pdfuid, "nopdf");
}
else
{
char selectRecord2[1024] = "";
int outputValueCount2 = 0, outputColumn2 = 0;
char*** outputValue2 = NULL;
sprintf(selectRecord2, "select puid from INFODBA.PPOM_APPLICATION_OBJECT where puid='%s'", outputValue3[0][1]);
WriteLog("查找的数据:%s\n", selectRecord2);
if (QuerySQLNoInputParam(selectRecord2, &outputColumn2, &outputValueCount2, &outputValue2) != -1) {
if (outputValueCount2 > 0) {
tc_strcpy(pdfuid, outputValue3[0][1]);
}
else
{
WriteLog("数据库查询出的PDF%s 已不存在\n", outputValue3[0][1]);
tc_strcpy(pdfuid, "nopdf");
}
}
else
{
WriteLog("数据库查询PDF%s 失败\n", outputValue3[0][1]);
tc_strcpy(pdfuid, "nopdf");
}
}
}
else
{
char insertRecord[1024] = "";
sprintf(insertRecord, "insert into CONNOR_PDFMESSAGE(itempuid,datasetpuid,signinfo,serverhost,stage,owninguser,departmentid,taskpuid,tcrelation,tcstatus,createdate) values(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,sysdate)");
WriteLog("插入数据:%s\n", insertRecord);
char** params = (char**)MEM_alloc(10 * sizeof(char*));
params[0] = tccomponentuid;
params[1] = tcdatasetuid;
params[2] = (char*)signInfo.c_str();
params[3] = serverhost;
params[4] = "正在发送到服务";
params[5] = userid;
params[6] = tcdepartmentid;
params[7] = taskpuid;
params[8] = tccomponentrelation;
params[9] = tcstatus;
if (ExecuteSQL(insertRecord, 10, params) == -1)
{
WriteLog("保存数据失败2%s", tcdatasetuid);
}
else
{
ExecuteSQLNoInputParam("commit");
WriteLog("保存数据成功");
}
tc_strcpy(pdfuid, "nopdf");
}
}
}
}
else {
WriteLog("查询失败");
tc_strcpy(pdfuid, "nopdf");
}
if (strcmp("PDF", objectType) == 0) {
tc_strcpy(pdfuid, tcdatasetuid);
}
inMap.insert(pair<string, string>("issignpdf", issignpdf));
inMap.insert(pair<string, string>("tccomponentuid", tccomponentuid));
inMap.insert(pair<string, string>("tcdatasetuid", tcdatasetuid));
inMap.insert(pair<string, string>("tccomponentrelation", tccomponentrelation));
inMap.insert(pair<string, string>("pdfuid", pdfuid));
inMap.insert(pair<string, string>("tcdepartmentid", tcdepartmentid));
inMap.insert(pair<string, string>("dwgtype", dwgtype));
inMap.insert(pair<string, string>("isdwgtopdf", isdwgtopdf));
inMap.insert(pair<string, string>("tcpdfrelation", tcpdfrelation));
inMap.insert(pair<string, string>("tcstatus", tcstatus));
inMap.insert(pair<string, string>("taskpuid", taskpuid));
inMap.insert(pair<string, string>("picture", parameterVec[4]));
inMap.insert(pair<string, string>("location", parameterVec[5]));
inMap.insert(pair<string, string>("ismergepdf", ismergepdf));
inMap.insert(pair<string, string>("isaddtask", parameterVec[8]));
// *
//inMap.insert(pair<string, string>("ismj", ismj));
stringToJsonPlus(inMap, "signinfos", signInfo, signJson);
WriteLog("发送的签字数据:%s\n", signJson.c_str());
callHttpserver(signJson, serverhost);
inMap.clear();
map<string, string>().swap(inMap);
}
void sendMessage(tag_t attachTag,tag_t rootTask,vector<string>relationVec, vector<string> datasetTypeVec,vector<string> parameterVec,string signInfo) {
string signJson;
tag_t relationTag=NULLTAG,* grmSecondTags=NULLTAG;
int grmSecondCount = 0;
tag_t datasetTag = NULLTAG;
char* tempValue = NULL;
char objectType[56] = "\0";
for (int j = 0;j < relationVec.size();j++)
{
ITKCALL2(GRM_find_relation_type(relationVec[j].c_str(), &relationTag));
ITKCALL2(GRM_list_secondary_objects_only(attachTag, relationTag, &grmSecondCount, &grmSecondTags));
for (int k = 0;k < grmSecondCount;k++) {
datasetTag = grmSecondTags[k];
ITKCALL2(AOM_ask_value_string(datasetTag, "object_type", &tempValue));
tc_strcpy(objectType, tempValue);
if (std::find(datasetTypeVec.begin(), datasetTypeVec.end(), tempValue) == datasetTypeVec.end())
{
DOFREE(tempValue);
continue;
}
DOFREE(tempValue);
sendMessageToService(attachTag,rootTask,datasetTag,parameterVec,relationVec[j],"",signInfo);
}
DOFREE(grmSecondTags);
}
}
/**
* Connor_signoff_dataset
* 签名到数据集handler
* -issignpdf=true 是否签字 非必填
* -tcdepartmentid=sx 基地ID用于对PDF签字位置的定位 必填
* -relation=IMAN_specification,IMAN_reference 要转PDF或签字的数据集和版本的关系 必填
* -datasettype=MSExcel,MSExcelX,MSWord,MSWordX,PDF 要转PDF或签字的数据集类型 必填
* -sign_relation=S8SignOffR 审签表单和版本的关系 必填
* -sign_info_option=Supor_signoff_dataset 签字配置的首选项名字 必填
* -serverhost=172.24.14.164 签字服务所在的服务器IP 必填
* -tcpdfrelation=IMAN_specification 转换出来的PDF挂载到对象下的关系 必填
* -processid=D 签名首选项值的开头符号 必填
* -dwgtype=S8AutoCAD Dwg的类型 非必填
* -tcstatus PDF要添加的流程状态 非必填
*/
int Connor_signoff_dataset(EPM_action_message_t msg)
{
char *log_file=NULL;
CreateLogFile("Connor_signoff_dataset", &log_file);
WriteLog("*************************************************************\n");
WriteLog("* Connor_signoff_dataset is strat ! *\n");
WriteLog("*************************************************************\n");
starTime();
//===============业务====================
string signJson ;
string signInfo;
int arg_cnt = 0 ,
ifail = ITK_ok,
attachesCount = 0;
char *arg = NULL,
*argflag =NULL,
*argvalue=NULL,
typeClass[TCTYPE_class_name_size_c+1]="\0";
char issignpdf[16] = "true",
sign_relation[56] = "\0",
sign_info_option[56] = "\0",
tcdepartmentid[56] = "\0",
tccomponentuid[56] = "\0",
tcdatasetuid[56] = "\0",
tccomponentrelation[56] = "\0",
pdfuid[56] = "\0",
tcpdfrelation[56] = "\0",
serverhost[56] = "\0",
processid[56] = "\0",
dwgtype[56] = "\0",
userid[56] = "\0",
objectType[56] = "\0",
tcstatus[56] = "\0",
taskpuid[56] = "\0",
picture[1024] = "\0",
location[1024] = "\0",
picture2[1024] = "\0",
location2[1024] = "\0",
ismergepdf[16] = "\0",
isaddtask[16] = "\0",
isdwgtopdf[16] = "\0";// *
//ismj[16] = "\0";
vector<string> relationVec;
vector<string> datasetTypeVec;
vector<string> parameterVec;
tag_t rootTask =NULLTAG,
*taskAttches =NULL,
attachTag=NULLTAG,
relation = NULLTAG;
int grmSecondCount =0 ;
tag_t *grmSecondTags = NULL;
char * tempValue = NULL;
arg_cnt = TC_number_of_arguments(msg.arguments);
if (arg_cnt > 0)
{
for (int i=0;i<arg_cnt;i++)
{
arg = TC_next_argument(msg.arguments);
ITKCALL2( ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue));
if (stricmp(argflag, "issignpdf") == 0){
if(argvalue != NULL)
{
WriteLog("-issignpdf=%s",argvalue);
tc_strcpy(issignpdf,argvalue);
}
}
if(stricmp(argflag, "processid") == 0){
if(argvalue != NULL)
{
WriteLog("-processid=%s",argvalue);
tc_strcpy(processid,argvalue);
}
}
if (stricmp(argflag, "sign_relation") == 0) {
if (argvalue != NULL)
{
WriteLog("-sign_relation=%s", argvalue);
tc_strcpy(sign_relation, argvalue);
}
}
if (stricmp(argflag, "sign_info_option") == 0) {
if (argvalue != NULL)
{
WriteLog("-sign_info_option=%s", argvalue);
tc_strcpy(sign_info_option, argvalue);
}
}
if(stricmp(argflag, "serverhost") == 0){
if(argvalue != NULL)
{
WriteLog("-serverhost=%s",argvalue);
tc_strcpy(serverhost,argvalue);
}
}
if(stricmp(argflag, "relation") == 0){
if(argvalue != NULL)
{
WriteLog("-relation=%s",argvalue);
Split(argvalue,",",relationVec);
}
}
if(stricmp(argflag, "datasettype") == 0){
if(argvalue != NULL)
{
WriteLog("-datasettype=%s",argvalue);
Split(argvalue,",",datasetTypeVec);
}
}
if(stricmp(argflag, "dwgtype") == 0){
if(argvalue != NULL)
{
WriteLog("-dwgtype=%s",argvalue);
tc_strcpy(dwgtype,argvalue);
}
}
if(stricmp(argflag, "tcdepartmentid") == 0){
if(argvalue != NULL)
{
WriteLog("-tcdepartmentid=%s",argvalue);
tc_strcpy(tcdepartmentid,argvalue);
}
}
if(stricmp(argflag, "tcpdfrelation") == 0){
if(argvalue != NULL)
{
WriteLog("-tcpdfrelation=%s\n",argvalue);
tc_strcpy(tcpdfrelation,argvalue);
}
}
if (stricmp(argflag, "tcstatus") == 0) {
if (argvalue != NULL)
{
WriteLog("-tcstatus=%s\n", argvalue);
tc_strcpy(tcstatus, argvalue);
}
}
if (stricmp(argflag, "picture") == 0) {
if (argvalue != NULL)
{
WriteLog("-picture=%s\n", argvalue);
tc_strcpy(picture, argvalue);
}
}
if (stricmp(argflag, "location") == 0) {
if (argvalue != NULL)
{
WriteLog("-location=%s\n", argvalue);
tc_strcpy(location, argvalue);
}
}
if (stricmp(argflag, "picture2") == 0) {
if (argvalue != NULL)
{
WriteLog("-picture2=%s\n", argvalue);
tc_strcpy(picture2, argvalue);
}
}
if (stricmp(argflag, "location2") == 0) {
if (argvalue != NULL)
{
WriteLog("-location2=%s\n", argvalue);
tc_strcpy(location2, argvalue);
}
}
if (stricmp(argflag, "ismergepdf") == 0) {
if (argvalue != NULL)
{
WriteLog("-ismergepdf=%s\n", argvalue);
tc_strcpy(ismergepdf, argvalue);
}
}
if (stricmp(argflag, "isaddtask") == 0) {
if (argvalue != NULL)
{
WriteLog("-isaddtask=%s\n", argvalue);
tc_strcpy(isaddtask, argvalue);
}
}
if (stricmp(argflag, "isdwgtopdf") == 0) {
if (argvalue != NULL)
{
WriteLog("-isdwgtopdf=%s\n", argvalue);
tc_strcpy(isdwgtopdf, argvalue);
}
}
MEM_free(argflag);
MEM_free(argvalue);
}
}
parameterVec.push_back(issignpdf);
parameterVec.push_back(dwgtype);
parameterVec.push_back(tcpdfrelation);
parameterVec.push_back(tcstatus);
parameterVec.push_back(picture);
parameterVec.push_back(location);
parameterVec.push_back(serverhost);
parameterVec.push_back(tcdepartmentid);
parameterVec.push_back(isaddtask);
parameterVec.push_back(isdwgtopdf);
//================遍历流程对象====================
ITKCALL2(EPM_ask_root_task( msg.task, &rootTask ));
ITKCALL2(EPM_ask_attachments(rootTask, EPM_target_attachment, &attachesCount, &taskAttches));
WriteLog("流程目标个数:%d\n",attachesCount);
if (SuporConnectionDB() == -1) {
WriteLog("数据库连接失败,请检查配置文件配置\n");
CloseLog();
EMH_store_error_s1(EMH_severity_error, EMH_AE_error_base, "数据库连接失败,请检查配置文件配置");
return 1;
}
POM_AM__set_application_bypass(true);
vector<tag_t> gywdVec;
for(int i=0; i<attachesCount; i++ )
{
attachTag = taskAttches[i];
logical isRev = false;
checkIsItemRevision(attachTag,isRev);
if(!isRev)
{
WriteLog("对象[%d]不是ItemRevision\n",taskAttches[i]);
continue;
}
//从工艺文档下获取工艺路线从工艺路线bom获取没有状态的工序版本
ITKCALL2(AOM_ask_value_string(attachTag, "object_type", &tempValue));
if (strcmp(ismergepdf, "") != 0) {
if (strcmp(tempValue, "LB2_GYWDRevision") == 0) {
gywdVec.push_back(attachTag);
}
else if (strcmp(tempValue, "LB2_MJRevision") == 0) {
map<string, string> inSignoffMap;
getSignoffInfoJson(attachTag, inSignoffMap, processid, sign_relation, sign_info_option);
stringToJson(inSignoffMap, signInfo);
map<tag_t,string> mjMap;
tag_t* grmSecondTags2 = NULLTAG;
int grmSecondCount2 = 0;
char* objectType = NULL;
WriteLog("是模具,开始遍历配置参数中的特定类型\n");
// *
//char *ismj = "1";
for (int j = 0;j < relationVec.size();j++)
{
tag_t relationTag = NULLTAG;
ITKCALL2(GRM_find_relation_type(relationVec[j].c_str(), &relationTag));
ITKCALL2(GRM_list_secondary_objects_only(attachTag, relationTag, &grmSecondCount2, &grmSecondTags2));
for (int k = 0;k < grmSecondCount2;k++) {
ITKCALL2(AOM_ask_value_string(grmSecondTags2[k], "object_type", &objectType));
char* dwg_str = NULL;
ITKCALL2(AOM_ask_value_string(grmSecondTags2[k], "object_string", &dwg_str));
WriteLog("当前dwg:%s\n", dwg_str);
if (std::find(datasetTypeVec.begin(), datasetTypeVec.end(), objectType) == datasetTypeVec.end())
{
WriteLog("跳过\n");
continue;
}
// *在此添加逻辑加入一个判断数据集状态没有状态的加入到mjMap
// 获取发布状态
tag_t *status = NULL;
int snum = 0;
ITKCALL(AOM_ask_value_tags(grmSecondTags2[k], "release_status_list", &snum, &status));
if (snum == 0) {
WriteLog("无状态,加入\n");
mjMap.insert(pair<tag_t, string>(grmSecondTags2[k], relationVec[j]));
}
else{
char *dwg_status_name2 = NULL;
AOM_ask_value_string(status[0], "object_name", &dwg_status_name2);
WriteLog("表面状态:%s\n", dwg_status_name2);
if ((strcmp("TCM Released", dwg_status_name2) != 0) &&
(strcmp("TCM 已发布", dwg_status_name2) != 0) ) {
WriteLog("状态符合,加入\n");
mjMap.insert(pair<tag_t, string>(grmSecondTags2[k], relationVec[j]));
}
/*char *dwg_status_name = NULL;
RELSTAT_ask_release_status_type(grmSecondTags2[k], &dwg_status_name);
WriteLog("状态:%s\n", dwg_status_name);
if ((strcmp("TCM Released", dwg_status_name) != 0)) {
WriteLog("状态符合,加入\n");
mjMap.insert(pair<tag_t, string>(grmSecondTags2[k], relationVec[j]));
}
DOFREE(dwg_status_name);*/
}
}
}
DOFREE(objectType);
int len = 0;
std::map<tag_t, string>::iterator iter;
for (iter = mjMap.begin(); iter != mjMap.end(); iter++) {
if (len == (mjMap.size() - 1)) {
sendMessageToService(attachTag, rootTask, iter->first, parameterVec, iter->second, ismergepdf, signInfo);
}
else
{
sendMessageToService(attachTag, rootTask, iter->first, parameterVec, iter->second, "", signInfo);
}
len++;
}
DOFREE(grmSecondTags2);
inSignoffMap.clear();
map<string, string>().swap(inSignoffMap);
mjMap.clear();
map<tag_t, string>().swap(mjMap);
}
else
{
map<string, string> inSignoffMap;
getSignoffInfoJson(attachTag, inSignoffMap, processid, sign_relation, sign_info_option);
stringToJson(inSignoffMap, signInfo);
if (checkIsInType(attachTag, "MEOPRevision")) {
tag_t* chi_form_list = NULLTAG;
int chi_form_count = 0;
char* lb2_sfgjgx = NULL;
AOM_ask_value_tags(attachTag, "IMAN_master_form_rev", &chi_form_count, &chi_form_list);
if (chi_form_count > 0) {
AOM_ask_value_string(chi_form_list[0], "lb2_sfgjgx", &lb2_sfgjgx);
if (strcmp("", lb2_sfgjgx) == 0 || strcmp("1", lb2_sfgjgx) == 0) {
if (strcmp(picture, "") != 0 && strcmp(picture2, "") != 0) {
string picture_gjgx;
string location_gjgx;
picture_gjgx.assign(picture).append(";").append(picture2);
location_gjgx.assign(location).append(";").append(location2);
parameterVec[4] = picture_gjgx;
parameterVec[5] = location_gjgx;
sendMessage(attachTag, rootTask, relationVec, datasetTypeVec, parameterVec, signInfo);
parameterVec[4] = picture;
parameterVec[5] = location;
}
else
{
sendMessage(attachTag, rootTask, relationVec, datasetTypeVec, parameterVec, signInfo);
}
}
else
{
sendMessage(attachTag, rootTask, relationVec, datasetTypeVec, parameterVec, signInfo);
}
}
else
{
sendMessage(attachTag, rootTask, relationVec, datasetTypeVec, parameterVec, signInfo);
}
DOFREE(lb2_sfgjgx);
DOFREE(chi_form_list);
}
else
{
if (strcmp(tempValue, "PSBOMViewRevision") != 0) {
sendMessage(attachTag, rootTask, relationVec, datasetTypeVec, parameterVec, signInfo);
}
}
}
}
else
{
map<string, string> inSignoffMap;
getSignoffInfoJson(attachTag, inSignoffMap, processid, sign_relation, sign_info_option);
stringToJson(inSignoffMap, signInfo);
sendMessage(attachTag, rootTask, relationVec,datasetTypeVec,parameterVec,signInfo);
}
DOFREE(tempValue);
}
WriteLog("工艺文档数量%d\n",gywdVec.size());
for (int i = 0; i < gywdVec.size(); i++) {
map<string, string> inSignoffMap;
getSignoffInfoJson(gywdVec[i], inSignoffMap, processid, sign_relation, sign_info_option);
stringToJson(inSignoffMap, signInfo);
map<tag_t, string> gywdMap;
tag_t* grmSecondTags2 = NULLTAG, fmTag = NULLTAG;
int grmSecondCount2 = 0;
char* objectType = NULL, * objectName = NULL;
for (int j = 0;j < relationVec.size();j++)
{
tag_t relationTag = NULLTAG;
ITKCALL2(GRM_find_relation_type(relationVec[j].c_str(), &relationTag));
ITKCALL2(GRM_list_secondary_objects_only(gywdVec[i], relationTag, &grmSecondCount2, &grmSecondTags2));
for (int k = 0;k < grmSecondCount2;k++) {
ITKCALL2(AOM_ask_value_string(grmSecondTags2[k], "object_type", &objectType));
if (std::find(datasetTypeVec.begin(), datasetTypeVec.end(), objectType) == datasetTypeVec.end())
{
continue;
}
ITKCALL2(AOM_ask_value_string(grmSecondTags2[k], "object_name", &objectName));
if (strstr(objectName, "封面") != NULL) {
fmTag = grmSecondTags2[k];
}
gywdMap.insert(pair<tag_t, string>(grmSecondTags2[k], relationVec[j]));
}
}
DOFREE(objectType);
DOFREE(objectName);
std::map<tag_t, string>::iterator iter;
for (iter = gywdMap.begin(); iter != gywdMap.end(); iter++) {
if (fmTag == iter->first) {
continue;
}
sendMessageToService(gywdVec[i], rootTask, iter->first, parameterVec, iter->second, "", signInfo);
}
if (fmTag != NULLTAG) {
sendMessageToService(gywdVec[i], rootTask, fmTag, parameterVec, gywdMap[fmTag], ismergepdf, signInfo);
}
DOFREE(grmSecondTags2);
inSignoffMap.clear();
map<string, string>().swap(inSignoffMap);
gywdMap.clear();
map<tag_t, string>().swap(gywdMap);
}
gywdVec.clear();
vector<tag_t>().swap(gywdVec);
POM_AM__set_application_bypass(false);
DisConnServer();
WriteLog("*************************************************************\n");
WriteLog("* Connor_signoff_dataset is end ! *\n");
WriteLog("*************************************************************\n");
CloseLog();
return ifail;
}