private Hashtable loadAgentReference(int cond) throws Exception{
if (agentFeedPath == null || agentFeedPath.length() == 0){
Properties pathProperties = new Properties();
pathProperties.load(new FileInputStream("deliveryxxx.properties"));
for (Enumeration upProp = pathProperties.keys() ; upProp.hasMoreElements() ;){
String ketStr = (String)upProp.nextElement();
//System.out.println(getLogMessage(ketStr+"="+pathProperties.getProperty(ketStr)));
}
agentFeedPath = pathProperties.getProperty("ftpFilePath")
+ pathProperties.getProperty("agentFeedFile");
}
Hashtable agentTable = new Hashtable();
BufferedReader br = new BufferedReader(new FileReader(agentFeedPath));
String line = "";
String agentCode = "";
AgentIdentification agent;
AgentIdentification branch;
ArrayList missEmailBranchHead = new ArrayList();
//200904 add for Checking agent
boolean isActiveAgent = true;
CSMSUserInterface csmsUserDAO = (CSMSUserInterface) new CSMSUserImpl();
CSMSUserVO csmsUser = null;
ArrayList csmsUserList = new ArrayList();
csmsUserList = csmsUserDAO.searchCSMSUserList(null, null);
if (csmsUserList != null) {
csmsUser = (CSMSUserVO)csmsUserList.get(0);
if (csmsUser != null) {
if (!csmsUser.checkUser()) {
csmsUser = null;
System.out.println("CSMS is not available");
}
}
}
//200904<--
while ((line = br.readLine()) != null){
/** Feed Layout AGT_TRACK.DAT
AgentCode X(6)
AgentName X(30)
UnitCode X(5)
BranchCode X(5)
BranchHead X(30)
BranchName X(30)
AgentEmail X(60)
*/
if (line.startsWith("HEADER") || line.startsWith("TRAILER"))
continue;
agentCode = line.substring(0, 6).trim();
agent = new AgentIdentification();
agent.setAgentCode(agentCode);
agent.setAgentName(line.substring(6, 36).trim());
agent.setUnitCode(line.substring(36, 41).trim());
agent.setBranchCode(line.substring(41, 46).trim());
agent.setBranchHead(line.substring(46, 76).trim());
agent.setBranchName(line.substring(76, 106).trim());
agent.setAgentEmail(line.substring(106, 166).trim());
if (cond == BY_AGENT){
agentTable.put(agentCode, agent);
} else if (cond == BY_BRANCH_HEAD){
if (agent.getAgentName().equalsIgnoreCase(agent.getBranchHead())){
if (agent.getAgentEmail().equals("")){
missEmailBranchHead.add(agent);
if (!agentTable.containsKey(agent.getBranchCode())){
agentTable.put(agent.getBranchCode(), agent);
}
} else{
//----------------------
// Check Hashtable
// Assumption: latest agent code value should be the larger
// Keith 2006-02-07
if (agentTable.containsKey(agent.getBranchCode())){
branch = (AgentIdentification)agentTable.get(agent.getBranchCode());
//200904 check if agent active
if (csmsUser != null) {
isActiveAgent = true;
if (csmsUser.searchAgent(agent.getAgentCode())) {
if (!csmsUser.getIsActiveAgent()) {
isActiveAgent = false;
}
} else {
isActiveAgent = false;
}
}
if (isActiveAgent) {
// System.out.println("update branch head: [" + agent.getBranchCode() + "] "
// + branch.getAgentCode() + " >> " + agent.getAgentCode());
agentTable.put(agent.getBranchCode(), agent);
}
// if (Integer.parseInt(agentCode) > Integer.parseInt(branch.getAgentCode()))
// {
// agentTable.put(agent.getBranchCode(), agent);
// } else {
// //Skip record
// }
} else
{
agentTable.put(agent.getBranchCode(), agent);
}
//----------------------
//agentTable.put(agent.getBranchCode(), agent);
}
}
}
}
if (cond == BY_BRANCH_HEAD){
for (int i = 0 ; i < missEmailBranchHead.size() ; i++){
agent = (AgentIdentification)missEmailBranchHead.get(i);
for (Enumeration n = agentTable.keys() ; n.hasMoreElements() ;){
branch = (AgentIdentification)agentTable.get((String)n.nextElement());
if (agent.getBranchHead().equalsIgnoreCase(branch.getBranchHead()) && !branch.getAgentEmail().equals("")){
agent.setAgentEmail(branch.getAgentEmail());
//-----KW060207
if (Integer.parseInt(agent.getAgentCode()) > Integer.parseInt(branch.getAgentCode()))
{
//200904 check if agent active
if (csmsUser != null) {
isActiveAgent = true;
if (csmsUser.searchAgent(agent.getAgentCode())) {
if (!csmsUser.getIsActiveAgent()) {
isActiveAgent = false;
}
} else {
isActiveAgent = false;
}
}
if (isActiveAgent) {
agentTable.put(agent.getBranchCode(), agent);
}
}
//-----
//agentTable.put(agent.getBranchCode(), agent);
break;
}
}
}
}
return agentTable;
}
从.property文件中取值:并处理之
原创
©著作权归作者所有:来自51CTO博客作者nethub的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:java 压缩文件
下一篇:Ctrl+Enter提交内容信息
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
java cell 读取值 java读取excel表格并处理
相信很多程序猿朋友碰到上传、读取Excel文件的问题,做个小结,权当是笔记收着吧。 之前做金融报表,是把Excel内嵌到页面中的,技术上采用ZK结合POI读取和插入Excel数据,后台方法比较死,比较程式化。
java cell 读取值 java excel apache List