public class DrpToOAInfo {
@PersistenceContext
EntityManager entityManager;
private final static String CONFIGURETION_FILE = "send_message_zh.properties";
private static Properties properties = null;
public static Properties readConfiguretion()
{
if (properties == null)
{
try
{
properties = new Properties();
ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream inputStream = null;
if (cl != null)
{
inputStream = cl.getResourceAsStream(CONFIGURETION_FILE);
}
if (inputStream != null)
{
properties.load(inputStream);
inputStream.close();
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
return properties;
}
/**
*
* @param type 接收者类型
* @param id 接收者id
* @param name 接收者名称
* @param contentVariable 内容中的变动部分
* @param url IP地址、端口号、项目
* @param value 生产计划单号
* @param configureInformType 通知类型
*/
public static void sendMessage(int type,
String id,
String name,
Object[] contentVariable,
String url,
Object[] value,
String configureInformType)
{
String applictionName = "";
String content = "";
String URL = "";
ReceiveType rt = ReceiveType.DEPARTMENT;
//读取资源文件
Properties properties = readConfiguretion();
applictionName = properties.getProperty("system.module.appliction.name");
content = MessageFormat.format(properties.getProperty(configureInformType), contentVariable);
URL = url + MessageFormat.format(properties.getProperty(configureInformType + ".url"), value);;
if(type == 0)
{
rt = ReceiveType.PEOPLE;
}
if(type == 1)
{
rt = ReceiveType.DEPARTMENT;
}
if(type == 2)
{
rt = ReceiveType.ROLE;
}
System.out.println("******************************************");
System.out.println("* 类型:"+rt);
System.out.println("* ID:"+id);
System.out.println("* 接收者名称:"+name);
System.out.println("* 内容:"+content);
System.out.println("* url:"+URL);
System.out.println("******************************************");
StartupMessage sm = new StartupMessage(applictionName, rt,"117", "tonywu", id, name, content, URL);
SendMessage s = new SendMessage();
s.sendMessage(sm);
}
/**
* 从request中得到地址中的参数,
* @param taskID 接收者类型
* @param processorID 处理者ID
* @param processorName 处理者名称
* @param processorTime 处理时间
*/
public static void overMessage(String[] processorInfo)
{
// 读取资源文件
Properties properties = readConfiguretion();
String applictionName = properties.getProperty("system.module.appliction.name");
// Calendar date = Calendar.getInstance();
// String t = date.get(Calendar.YEAR)+"-"+date.get(Calendar.MONTH)+"-"+date.get(Calendar.DATE);
BeOverMessage bm = new BeOverMessage(applictionName, processorInfo[1],
"117", "tonywu",new Date());
System.out.println("******************************************");
System.out.println("* taskID类型:"+processorInfo[1]);
System.out.println("* processorIDID:"+processorInfo[2]);
System.out.println("* processorName接收者名称:"+processorInfo[3]);
System.out.println("* 时间:"+new Date());
System.out.println("******************************************");
SendMessage s = new SendMessage();
s.sendMessage(bm);
}
}