📄 wsyusuan.java
字号:
package com.mdcl.mocha.jlcmcc.interfaceforWS;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.StringReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import com.mdcl.mocha.bpm.sdk.ServiceManager;
import com.mdcl.mocha.bpm.sdk.license.ExpiryException;
import com.mdcl.mocha.bpm.sdk.license.LicenseException;
import com.mdcl.mocha.bpm.sdk.license.NotFoundModuleException;
import com.mdcl.mocha.jlcmcc.configmanager.ConfigManager;
/**
* <strong>Title : WSYuSuan<br></strong>
* <strong>Description : </strong>吉林移动BPM预算系统接口类<br>
* <strong>Create on : 2007-10-11<br></strong>
* <p>
* <strong>Copyright (C) Mocha Software Co.,Ltd.<br></strong>
* <p>
* @author liulf@mochasoft.com.cn<br>
* @version <strong>Mocha BPM v6.2</strong><br>
* <br>
* <strong>修改历史:</strong><br>
* 修改人 修改日期 修改描述<br>
* -------------------------------------------<br>
* <br>
* <br>
*/
public class WSYuSuan {
private String YSurl="";
public WSYuSuan(){
this.YSurl=this.getPath("url.WS.yusuan");
}
/**
*
* 通过机构编码、事项所属年份、事项类型从预算系统取回:事项编号、事项名称、事项剩余金额。
* 事项所属年份:用8位字符表示,如'20070000'表示2007年;
* 事项类型:为0表示只返回接收参数所表示机构的事项信息,为1表示返回接收参数所表示机构及其下级机构的事项信息。
*
* @param OADptCodeIn
* <i>机构编码</i>
* @param StartDate
* <i>事项开始年份</i>
* @param EndDate
* <i>事项结束年份</i>
* @param SubordinateFlag
* <i>事项类型</i>
* @return 包括项目编号、项目名称、剩余项目金额Map的List
*/
public List getGetProceedingMsg(String OADptCodeIn, String StartDate ,String EndDate, String SubordinateFlag){
List result=new ArrayList();
try {
//获得URL连接
URL url = new URL(YSurl);
URLConnection uc = url.openConnection();
uc.setDoOutput(true);
uc.setDoInput(true);
uc.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
//生成请求消息
StringBuffer buf = new StringBuffer();
buf.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
buf.append("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
buf.append("<soap:Body>");
buf.append("<GetProceedingMsg xmlns=\"http://bcms.jlmc.com\">");
buf.append("<OADptCodeIn>"+OADptCodeIn+"</OADptCodeIn>");
buf.append("<StartDate>"+StartDate+"</StartDate>");
buf.append("<EndDate>"+EndDate+"</EndDate>");
buf.append("<SubordinateFlag>"+SubordinateFlag+"</SubordinateFlag>");
buf.append("</GetProceedingMsg>");
buf.append("</soap:Body>");
buf.append("</soap:Envelope>");
//发送请求
OutputStreamWriter out = new OutputStreamWriter(uc.getOutputStream(), "8859_1");
out.write(buf.toString());
out.flush();
out.close();
//获得数据结果存到StringBuffer
SAXReader saxReader = new SAXReader();
InputStreamReader in=new InputStreamReader(uc.getInputStream(),"UTF-8");
Document document = saxReader.read(in);
List list = document.selectNodes("/soap:Envelope/soap:Body");
Iterator iter = list.iterator();
StringBuffer line=new StringBuffer();
if(iter.hasNext()){
Element ownerElement = (Element)iter.next();
line.append(ownerElement.getStringValue());
}
in.close();
//拆分数据
document = saxReader.read(new StringReader(line.toString()));
list = document.selectNodes("/ProceedingMsg/Row");
iter = list.iterator();
//System.out.println(list.size());
while(iter.hasNext()){
//System.out.println("start2");
Element ownerElement = (Element)iter.next();
Map t_map=new HashMap();
t_map.put("chengbenxiangmubianhao", getElementVaule(ownerElement,"ProceedingID"));
t_map.put("chengbenxiangmumingcheng", getElementVaule(ownerElement,"ProceedingName"));
t_map.put("shengyuxiangmujine", getElementVaule(ownerElement,"Balance"));
result.add(t_map);
}
}
catch (Exception e) {
e.printStackTrace();
}
return result;
}
/**
*
* 通过合同编号从预算系统取回"合同已支付的金额"。
*
* @param ContractCode
* <i>合同编号</i>
* @return 合同已支付的金额
*/
public String getGetContractMoneyPayed(String ContractCode){
String result="";
try {
//获得URL连接
URL url = new URL(YSurl);
URLConnection uc = url.openConnection();
uc.setDoOutput(true);
uc.setDoInput(true);
uc.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
//生成请求消息
StringBuffer buf = new StringBuffer();
buf.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
buf.append("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
buf.append("<soap:Body>");
buf.append("<GetContractMoneyPayed xmlns=\"http://bcms.jlmc.com\">");
buf.append("<ContractCode>"+ContractCode+"</ContractCode>");
buf.append("</GetContractMoneyPayed>");
buf.append("</soap:Body>");
buf.append("</soap:Envelope>");
//发送请求
OutputStreamWriter out = new OutputStreamWriter(uc.getOutputStream(), "8859_1");
out.write(buf.toString());
out.flush();
out.close();
//获得数据结果存到StringBuffer
SAXReader saxReader = new SAXReader();
InputStreamReader in=new InputStreamReader(uc.getInputStream(),"UTF-8");
Document document = saxReader.read(in);
List list = document.selectNodes("/soap:Envelope/soap:Body");
Iterator iter = list.iterator();
StringBuffer line=new StringBuffer();
if(iter.hasNext()){
Element ownerElement = (Element)iter.next();
line.append(ownerElement.getStringValue());
}
in.close();
result=line.toString();
}
catch (Exception e) {
e.printStackTrace();
}
return result;
}
/**
*
* 向预算系统传入合同信息
*
* @param BDbean
* <i>合同信息</i>
* @return 成功:true 失败:false
*/
public boolean setSendContractMsg(BiaoDianBean BDbean){
try {
//获得URL连接
URL url = new URL(YSurl);
URLConnection uc = url.openConnection();
uc.setDoOutput(true);
uc.setDoInput(true);
uc.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
//生成请求消息
StringBuffer buf = new StringBuffer();
buf.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
buf.append("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
buf.append("<soap:Body>");
buf.append("<SendContractMsg xmlns=\"http://bcms.jlmc.com\">");
buf.append("<CreateMan>"+BDbean.chengbanren+"</CreateMan>");
buf.append("<CreateDpt>"+BDbean.chengbanbumen+"</CreateDpt>");
buf.append("<CreateTime>"+BDbean.qicaoshijian+"</CreateTime>");
buf.append("<Urgency>"+BDbean.jinjichengdu+"</Urgency>");
buf.append("<ContractCode>"+BDbean.hetongbianhao+"</ContractCode>");
buf.append("<ContractName>"+BDbean.hetongmingcheng+"</ContractName>");
buf.append("<IsFactualContract>"+BDbean.shishihetong+"</IsFactualContract>");
buf.append("<MoneyPayed>"+BDbean.yifujine+"</MoneyPayed>");
buf.append("<CurrencyType>"+BDbean.huobileixing+"</CurrencyType>");
buf.append("<ContractSum>"+BDbean.hetongjine+"</ContractSum>");
buf.append("<PayConditionMode>"+BDbean.fukuantiaojian+"</PayConditionMode>");
buf.append("<GoodsarrivalTime>"+BDbean.daohuoriqi+"</GoodsarrivalTime>");
buf.append("<ContractTypeFirst>"+BDbean.hetongdalei+"</ContractTypeFirst>");
buf.append("<ContractTypeSecond>"+BDbean.hetongxiaolei+"</ContractTypeSecond>");
buf.append("<ContractModel>"+BDbean.hiddenhetongfanben+"</ContractModel>");
buf.append("<PurveyorNum>"+BDbean.lianxidianhua+"</PurveyorNum>");
buf.append("<OpposingParty>"+BDbean.duifangdangshiren+"</OpposingParty>");
buf.append("<Bank>"+BDbean.kaihuhang+"</Bank>");
buf.append("<Account>"+BDbean.zhanghu+"</Account>");
buf.append("<ContactMan>"+BDbean.lianxiren+"</ContactMan>");
buf.append("<ContactNum>"+BDbean.lianxidianhua+"</ContactNum>");
buf.append("<SelfSummary>"+BDbean.benfanglvxingzhaiyao+"</SelfSummary>");
buf.append("<OpposingSummary>"+BDbean.duifanglvxingzhaiyao+"</OpposingSummary>");
buf.append("<ExpetationPeriod>"+BDbean.kaishishijian+"至"+BDbean.jieshushijian+"</ExpetationPeriod>");
buf.append("<SignMan>"+BDbean.shiyinren+"</SignMan>");
buf.append("<TaxType>"+BDbean.yinhuashuileixign+"</TaxType>");
buf.append("<ProjectName>"+BDbean.chengbenxiangmumingcheng+"</ProjectName>");
buf.append("<ProjectCode>"+BDbean.chengbenyusuanbianhao+"</ProjectCode>");
buf.append("<AccessoriesName>"+BDbean.fujian_all+"</AccessoriesName>");
buf.append("<Attitude>"+BDbean.yijianbianqianliebiao+"</Attitude>");
buf.append("</SendContractMsg>");
buf.append("</soap:Body>");
buf.append("</soap:Envelope>");
//发送请求
OutputStreamWriter out = new OutputStreamWriter(uc.getOutputStream(), "8859_1");
out.write(buf.toString());
out.flush();
out.close();
//获得数据结果存到StringBuffer
SAXReader saxReader = new SAXReader();
InputStreamReader in=new InputStreamReader(uc.getInputStream(),"UTF-8");
Document document = saxReader.read(in);
List list = document.selectNodes("/soap:Envelope/soap:Body");
Iterator iter = list.iterator();
StringBuffer line=new StringBuffer();
if(iter.hasNext()){
Element ownerElement = (Element)iter.next();
line.append(ownerElement.getStringValue());
}
in.close();
if(line.toString().equalsIgnoreCase("1"))return true;
else return false;
}
catch (Exception e) {
e.printStackTrace();
}
return false;
}
/**
*
* 读取指定XML节点下的指定节点的值
*
* @param el
* <i>XML节点</i>
* @param path
* <i>待取节点</i>
* @return path下的vaule
*/
private String getElementVaule(Element el,String path){
List t_list=el.selectNodes(path);
Element t_ownerElement = (Element)t_list.get(0);
return t_ownerElement.getStringValue();
}
/**
*
* 读取配置文件
*
* @return 值
*/
private String getPath(String path)
{
String result="";
ConfigManager cm;
try {
cm = (ConfigManager)ServiceManager.getInstance().getService(ConfigManager.class);
result = cm.getPath("jlcmcc-serviceinf.properties",path);
} catch (NotFoundModuleException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExpiryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (LicenseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -