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.

192 lines
5.2 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 "epm_handler_common.h"
#include "jk_custom_erp.h"
#include <tc/tc.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 <map>
#include "epm/signoff.h"
#include <ctime>
#include <vector>
#include <locale>
#include <codecvt>
#include "ae/dataset.h"
#include <server_exits/user_server_exits.h>
#include <tccore/custom.h>
#include <epm/epm.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <ict/ict_userservice.h>
#include <tccore/item.h>
#include <ae/ae.h>
#include <tc/folder.h>
#include <tccore/aom.h>
#include <sa/sa.h>
#include <tccore/aom_prop.h>
#include <property/prop_errors.h>
#include <tccore/workspaceobject.h>
#include <tc/preferences.h>
#include <tccore/imantype.h>
#include <tccore//grm.h>
#include <tccore/grmtype.h>
#include <sa/am.h>
#include <cfm/cfm.h>
#include <bom/bom.h>
#include <tccore/uom.h>
#include <ps/ps.h>
#include <epm/signoff.h>
#include <fclasses/tc_date.h>
#include <form/form.h>
#include <form/formtype.h>
#include <ics\ics.h>
#include <stdarg.h>
#include <iostream>
extern "C" int POM_AM__set_application_bypass(logical bypass);
using namespace std;
void removeReleaseStatusByName(string statusName,tag_t rootTask,vector<tag_t> revVec);
void removeRevFromTask(tag_t rootTask,vector<tag_t> revVec);
int removeBaseLine(EPM_action_message_t msg)
{
int ifail=ITK_ok;
EPM_decision_t decision = EPM_go;
tag_t task_tag = NULLTAG, rootTask_tag = NULLTAG, *attachments = NULLTAG,*revision_list=NULLTAG;
int arg_cnt = 0, i = 0, att_cnt = 0,revtion_nums=0;
int release_nums=0;
tag_t *release_list=NULLTAG;
char* object_type;
tag_t release_stat = NULLTAG;
// string dateType="ena";
vector<tag_t> attatchments;
vector<tag_t> target_vec;
//获取当前触发的任务
task_tag = msg.task;
//获取根流程节点
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
//获取目标引用对象
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
//循环目标对象
cout<<"数量--qq----->"<<att_cnt<<endl;
for (i = 0; i < att_cnt; i++)
{
//获得该物料下所有版本版本revision_list
ITKCALL(ifail=AOM_ask_value_string(attachments[i],"object_type",&object_type));
if(strcmp("JK8Material",object_type)==0)//LP2_Design_Part JK8Material
{
ITKCALL(ifail=AOM_ask_value_tags(attachments[i],"revision_list",&revtion_nums,&revision_list));
for (int j=0;j<revtion_nums;j++)
{
target_vec.push_back(revision_list[j]);
if(j==revtion_nums-1)
{
attatchments.push_back(revision_list[j]);
}
}
}
}
//删除物料和版本的状态
POM_AM__set_application_bypass(true);
// removeReleaseStatus("删除状态流程",target_vec);
cout<<"mark1"<<endl;
removeReleaseStatusByName("Baselined",rootTask_tag,target_vec);//TODO
cout<<"mark2"<<endl;
removeRevFromTask(rootTask_tag,target_vec);
cout<<"mark3"<<endl;
POM_AM__set_application_bypass(false);
cout<<"mark4"<<endl;
//
if (attachments != NULL)
{
MEM_free(attachments);
attachments = NULL;
}
if (revision_list != NULL)
{
MEM_free(revision_list);
revision_list = NULL;
}
if (object_type != NULL)
{
MEM_free(object_type);
object_type = NULL;
}
cout<<"mark5"<<endl;
printf("ifail=>%d\n",ifail);
return 0;
}
void removeReleaseStatusByName(string statusName,tag_t rootTask,vector<tag_t> revVec){
tag_t release_status =NULLTAG;
tag_t * attachments = NULL;
int *att_types=NULL;
int ifail = 0;
att_types = (int*) MEM_alloc (sizeof(int) * ( revVec.size() ));
attachments = (tag_t*) MEM_alloc (sizeof(tag_t) * ( revVec.size() ));
//制定目标,数组转换
for ( int indx = 0; indx < revVec.size(); indx++ )
{
att_types[indx] = EPM_target_attachment;//EPM_reference_attachment;
attachments[indx] = revVec[indx];
}
//把所有的版本都添加到流程中
printf("1ifail=>%d\n",ifail);
ITKCALL(ifail=EPM_add_attachments(rootTask,revVec.size(),attachments,att_types));
printf("2ifail=>%d\n",ifail);
ITKCALL(ifail =CR_create_release_status(statusName.c_str(),&release_status));
printf("4ifail=>%d\n",ifail);
if(release_status!=NULLTAG){
POM_AM__set_application_bypass(true);
ITKCALL(ifail =EPM_remove_status_from_targets(release_status,rootTask));
printf("6ifail=>%d\n",ifail);
POM_AM__set_application_bypass(false);
}
if(att_types)
{
MEM_free(att_types);
att_types = NULL;
}
if(attachments)
{
MEM_free(attachments);
attachments = NULL;
}
}
void removeRevFromTask(tag_t rootTask,vector<tag_t> revVec){
cout<<"enter removeRevFromTask "<<endl;
tag_t * attachments = NULL;
attachments = (tag_t*) MEM_alloc (sizeof(tag_t) * ( revVec.size() ));
//制定目标,数组转换
for ( int indx = 0; indx < revVec.size(); indx++ )
{
attachments[indx] = revVec[indx];
}
cout<<"mark1--"<<endl;
POM_AM__set_application_bypass(true);
ITKCALL(EPM_remove_attachments(rootTask,revVec.size(),attachments));
POM_AM__set_application_bypass(false);
cout<<"mark2--"<<endl;
if(attachments)
{
MEM_free(attachments);
attachments = NULL;
}
}