TC13 两层使用soa登录的方法

#------Login User Information.------#
#TC Login UserID
UserID=000001
TCUser=000001
#TC Login Password
Password=1
#TC Login Group
Group=dba
#TC Login Role
Role=DBA
#TC Login Address
TCServerURL=tccs://TcEnv1
#TCServerURL=iiop:localhost:1572/TcServer1
#TCServerURL=http://localhost:7001/tc
#TCServerURL=http://10.39.168.51:7001/tc/
#------Login User Information.------#

#------TC Config Information.------#
EPMJobService_TaskState=8
DivisionGeneralPartsProcessTemplate=*
PreferenceName_RecordOfServiceTime=cust_ControlCabin_RecordOfServiceTime
#------TC Config Information.------#

#------Kafka Information.------#
KafkaUrl=10.39.52.27:9092
#------Kafka Information.------#

#------Kafka Topic Information.------#
EPMTasksTopic=signaturesubject
EPMTaskTemplatesTopic=TaskTemplatesSubject
ECNTopic=changesubject
ECNChangeReasonsTopic=ChangeReasonsSubject
#Design_PartTopic=designsubject_basic
#Design_PartRevisionTopic=designsubject_version
Project_BaseDataTopic=projectsubject_basic
Project_StageDataTopic=projectsubject_stage
Project_TypeDataTopic=ProjectSubject_Type
ProductsTopic=productsubject
DivisionGeneralPartsLibTopic=commonpartssubject
DesignTopic=designsubject_basic
#------Kafka Topic Information.------#

#------Database Configuration For MySQL.------#
MySQL_url=jdbc:mysql://10.39.52.58:3306/zoomspace11?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true&autoReconnect=true&autoReconnectForPools=true&failOverReadOnly=false
MySQL_user=zoomlion
MySQL_password=1qazXSW.2021
InsertJsonFileToDB_SQL=INSERT INTO UFC_CONTROLCABIN_JSON_FILES(FILENAME, CONTENT, DATATYPE) VALUES(?, ?, ?)
SelectJsonFile_SQL=SELECT CONTENT FROM UFC_CONTROLCABIN_JSON_FILES WHERE FILENAME=? FOR UPDATE
UpdateJsonFile_SQL=UPDATE UFC_CONTROLCABIN_JSON_FILES SET CONTENT=? WHERE FILENAME=?
SelectJsonFileByDataType_SQL=SELECT * FROM UFC_CONTROLCABIN_JSON_FILES WHERE DATATYPE=? ORDER BY INSERTDATE ASC
DeleteJsonFileByFileName_SQL=DELETE FROM UFC_CONTROLCABIN_JSON_FILES JSONFILE WHERE JSONFILE.FILENAME=?
#------Database Configuration For MySQL.------#

#------Database Configuration For PICM0.------#
DB_url=localhost:1521:onetc
DB_user=infodba
DB_password=infodba
PICM0_SQL=SELECT * FROM INFODBA.PICM0 WHERE to_date(PCR_DATE, 'yyyy-MM-dd hh24:mi:ss') BETWEEN to_date(?, 'yyyy-MM-dd hh24:mi:ss') and to_date(?, 'yyyy-MM-dd hh24:mi:ss') AND PCID IN(?, ?, ?)
#InsertJsonFileToDB_SQL=INSERT INTO UFC_CONTROLCABIN_JSON_FILES(FILENAME, CONTENT, DATATYPE) VALUES(?, EMPTY_BLOB(), ?)
#SelectJsonFile_SQL=SELECT CONTENT FROM UFC_CONTROLCABIN_JSON_FILES WHERE FILENAME=? FOR UPDATE
#UpdateJsonFile_SQL=UPDATE UFC_CONTROLCABIN_JSON_FILES SET CONTENT=? WHERE FILENAME=?
#SelectJsonFileByDataType_SQL=SELECT * FROM UFC_CONTROLCABIN_JSON_FILES WHERE DATATYPE=? ORDER BY INSERTDATE ASC
#DeleteJsonFileByFileName_SQL=DELETE FROM UFC_CONTROLCABIN_JSON_FILES JSONFILE WHERE JSONFILE.FILENAME=?
#------Database Configuration For PICM0.------#

#------Database Configuration For Sending Design Data In Bulk------#
DesignDataCount_SQL=SELECT COUNT(*) FROM ZOOMLION.ZL_COCKPIT_ITEM tem,INFODBA.PITEM it WHERE tem.ITEM_ID = it.PITEM_ID AND tem.OBJECT_TYPE = 'QN3PartRevision'
DesignData_SQL=SELECT h.* from(SELECT ROWNUM r, t.* from(SELECT it.PUID,tem.ITEM_ID FROM ZOOMLION.ZL_COCKPIT_ITEM tem,INFODBA.PITEM it WHERE tem.ITEM_ID = it.PITEM_ID AND tem.OBJECT_TYPE = 'QN3PartRevision') t) h where r BETWEEN ? and ?
#------Database Configuration For Sending Design Data In Bulk------#

 

 

package com.ufc.Utils;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
* 读取功能配置文件的工具类
*
* @author TB
*/
public class Config_Utils {

/**
* Properties类继承自Hashtable类并且实现了Map接口,也是使用一种键值对的形式来保存属性集。不过Properties有特殊的地方,就是它的键和值都是字符串类型。
**/
private Properties props = null;

/**
* 构造方法
*
* @throws FileNotFoundException 配置文件没有找到
* @throws IOException 关闭资源文件,或者加载配置文件错误
*/
public Config_Utils() {
InputStream inputStream = getClass().getResourceAsStream("/Config.properties");
this.props = new Properties();
try {
/* 避免中文乱码问题,设置编码为‘UTF-8’ */
InputStreamReader isr = new InputStreamReader(inputStream, "UTF-8");
this.props.load(isr);
/* 关闭资源 */
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
System.out.println("读取功能配文件发生异常,请联系管理员!异常信息如下:\n\n" + e.toString());
}
}

/**
* 根据key值读取配置的值
*
* @param key key值
* @return key 键对应的值
*/
public String readValue(String key) {
String value = this.props.getProperty(key);
return value;
}

/**
* 读取properties的全部信息
*/
public Map<String, String> readAllProperties() {
/* 保存所有的键值 */
Map<String, String> map = new HashMap<String, String>();
Enumeration<?> en = this.props.propertyNames();
while (en.hasMoreElements()) {
String key = (String) en.nextElement();
String Property = this.props.getProperty(key);
map.put(key, Property);
}
return map;
}

/**
* TestDemo
*/
public static void main(String[] args) {
Config_Utils Util = new Config_Utils();
Map<String, String> a = Util.readAllProperties();
System.out.println(a);
}
}

 

 

package com.ufc.ControlCabinService;

import java.util.ArrayList;
import java.util.Map;
import java.util.ResourceBundle;

import javax.swing.JOptionPane;

import com.teamcenter.clientx.AppXSession;
import com.teamcenter.soa.client.model.strong.User;
import com.ufc.Utils.Config_Utils;
import com.ufc.Utils.JsonLogs_Utils;

/**
* 可执行Jar包的程序入口
*
* @author TianBin
*/
public class ProgramEntrance {
/** 读取资源文件 **/
private static ResourceBundle bundle = ResourceBundle.getBundle("Config");
/** JSON日志文件工具类 **/
private static JsonLogs_Utils logUtils = new JsonLogs_Utils();

public static void main(String[] args) {
ArrayList<String> argumentList = new ArrayList<String>();
for (String arg : args) {
argumentList.add(arg);
System.out.println(arg);
}

if (null == args || 0 == args.length) {
tooltip("请输入指定的参数,区分大小写:", JOptionPane.ERROR_MESSAGE);
return;
} else {
if ("-h".equalsIgnoreCase(args[0])) {
tooltip("可以使用的指定参数,区分大小写:", JOptionPane.INFORMATION_MESSAGE);
return;
} else if (!argumentList.contains("EPMTask") && !argumentList.contains("ECN") && !argumentList.contains("Product")
&& !argumentList.contains("DivisionGeneralPartsLib") && !argumentList.contains("Design") && !argumentList.contains("Project")
&& !argumentList.contains("Schedules") && !argumentList.contains("Design_DB")) {
tooltip("参数无效!可以使用以下指定参数,区分大小写:", JOptionPane.WARNING_MESSAGE);
return;
}
}

Config_Utils Util = new Config_Utils();
Map<String, String> configMap = Util.readAllProperties();
if (configMap.isEmpty()) {
System.out.println("***===ErrorMessage:The user's login information is not configured!!!!");
return;
} else {
if (!configMap.containsKey("UserID") || !configMap.containsKey("Password")) {
System.out.println("***===ErrorMessage:The user's login information is misconfigured!!!!");
return;
}
}

System.out.println("\n--------------[正在登陆Teamcenter,请稍等……………]--------------");
String serverHost = configMap.get("TCServerURL");
System.out.println("TCServerURL=" + serverHost);

String userID = configMap.get("UserID");
System.out.println("UserID=" + userID);

String password = configMap.get("Password");
System.out.println("Password=" + password);

String group = configMap.get("Group");
System.out.println("Group=" + group);

String role = configMap.get("Role");
System.out.println("Role=" + role);

AppXSession session = new AppXSession(serverHost, userID, password, group, role);
User currentUser = session.login();
System.out.println(currentUser);
System.out.println("--------------[~~~~~~~~~~登陆成功~~~~~~~~~~]--------------\n");

if (argumentList.contains("EPMTask")) {
EPMJobService epmJobService = new EPMJobService(bundle, logUtils);
/* 先传递模板数据 */
epmJobService.executeForTaskTemplate();
epmJobService.execute();
}
if (argumentList.contains("ECN")) {
ECNService ecnService = new ECNService(bundle, logUtils);
/* 先发送更改原因 */
ecnService.executeForChangeReasons();
ecnService.execute();
}
if (argumentList.contains("Product")) {
ProductService productService = new ProductService(bundle, logUtils);
productService.execute();
}
if (argumentList.contains("DivisionGeneralPartsLib")) {
DivisionGeneralPartsLibService_New divisionGeneralPartsLibService = new DivisionGeneralPartsLibService_New(bundle, logUtils);
divisionGeneralPartsLibService.execute();
}
if (argumentList.contains("Design")) {
DesignService designService = new DesignService(bundle, logUtils);
designService.execute();
}
if (argumentList.contains("Project")) {
ProjectService projectService = new ProjectService(bundle, logUtils);
/* 先发送项目类型数据 */
projectService.sendProjectTypeData();
projectService.sendBaseData(null);
// projectService.sendStageData();
}

if (argumentList.contains("Schedules")) {
SchedulesService scheduleTaskService = new SchedulesService(bundle, logUtils);
scheduleTaskService.execute();
}

if (argumentList.contains("Design_DB")) {
BatchSendDesignService batchSendDesignService = new BatchSendDesignService(bundle, logUtils);
batchSendDesignService.execute();
}

session.logout();
System.out.println("--------------[~~~~~~~~~已退出登录!~~~~~~~~~]--------------\n");
}

/**
* 提示信息
*
* @param message 信息
* @param messageType 提示类型
*/
private static void tooltip(String message, int messageType) {
System.out.println(message);
System.out.println("\tEPMTask\t:审批流程主题");
System.out.println("\tECN\t:更改单主题");
System.out.println("\tProduct\t:产品主题");
System.out.println("\tDivisionGeneralPartsLib\t:事业部通用件库主题");
System.out.println("\tDesign\t:设计主题");
System.out.println("\tProject\t:项目主题");
System.out.println("\tSchedules\t:时间表主题");
JOptionPane.showMessageDialog(null, message
+ "\nEPMTask\t:审批流程主题\nECN\t:更改单主题\nProduct\t:产品主题\nDivisionGeneralPartsLib\t:事业部通用件库主题\nDesign\t:设计主题\nProject\t:项目主题\nSchedules\t:时间表主题",
"提示……", messageType);
}
}

 

上一篇:在Windows 10的cmd输出彩色文本


下一篇:Java 中判断一个字符串是否包含另外一个字符串的方法