81,091
社区成员
发帖
与我相关
我的任务
分享
package com.ser;
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import com.hr.service.impl.HrServiceImpl;
public class syncEmpPromotion {
/**
*
* @param args
*/
public static void main(String[] args) {
try {
//String endpoint = "http://XXX:8084/HrSyncService/services/HrService";
String endpoint = "http://XXXX:8080/HrSyncService/services/HrService";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName(endpoint, "syncEmpPromotion"));
Object ret = call
.invoke(new Object[] {"" +
"<Hireds><Hired>"+
"<gh>JMSH1162</gh>"+
"<zt></zt>"+
"<ygjs2jpsxrq>2013-02-25</ygjs2jpsxrq>"+
"<ygjs2jshzj>0302</ygjs2jshzj>"+
"<ygjs2jshbm>010907</ygjs2jshbm>"+
"<ygjs2jshgw>010907020E01</ygjs2jshgw>"+
"<ygjs2jshbmsj>JMWJ0196</ygjs2jshbmsj>"+
"<ygjs2zkpjf>0</ygjs2zkpjf>"+
"<ygjs2bkpjf></ygjs2bkpjf>"+
"<syqksrq></syqksrq>"+
"<syqjsrq></syqjsrq>"+
"<ygjs2smpf>8</ygjs2smpf>"+
"<ygjs2bsdf></ygjs2bsdf>"+
"<ygjs2bsbkdf></ygjs2bsbkdf>"+
"<ygjs2pptdf></ygjs2pptdf>"+
"<ygjs2pptbkdf></ygjs2pptbkdf>"+
"<ygjs2qtxm></ygjs2qtxm>"+
"<ygjs2qtxmdf></ygjs2qtxmdf>"+
"<ygjs2qtxmbkdf></ygjs2qtxmbkdf>"+
"<ygjs2ydjxxztz>0</ygjs2ydjxxztz>"+
"<ygjs2jdjxxztz>0</ygjs2jdjxxztz>"+
"<ygjs2ndjxxztz>0</ygjs2ndjxxztz>"+
"<jslx></jslx>"+
"<jbgz>0</jbgz>"+
"<gwjt>0</gwjt>"+
"<jsjp></jsjp>"+
"<zwjt>50</zwjt>"+
"<procId>82261</procId>"+
"<procNo></procNo>"+
"</Hired></Hireds>" });
System.out.println("Sent '" + ret + "', got '" + ret + "'");
System.out.println("Sent---------------------- '"+call);
} catch (Exception e) {
e.printStackTrace();
System.err.println(e.toString());
}
}
}
这个是测试类,通过测试类去走,本机可以,服务器不可以package com.hr.service.impl;
import com.hjsoft.SynClient;
import com.hr.service.util.DBUtil;
import com.hr.service.util.StringHandle;
import java.io.PrintStream;
import java.io.StringReader;
import java.sql.Connection;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
public class HrEmpPromotion extends SqlServerImpl {
SqlServerImpl sqlserver = new SqlServerImpl();
public String procPromotion(String resultXml) {
resultXml = resultXml.replace(" ", "");
resultXml = resultXml.replace("<br>", "");
String resultId = "1";
// --1、jdom把resultXml(String)转换成XML,并解析
Document document = null;
Connection dbcon = null;
SAXBuilder builder = new SAXBuilder();
try {
dbcon = DBUtil.getInstance().getConnect();
document = builder.build(new StringReader(resultXml));
// --1.21、获取根节点
Element root = document.getRootElement();
// --1.22获取根节点下的所有子元素
List childList = root.getChildren();
// --1.23遍历子元素里的信息,并存储到数据库中
for (int i = 0; i < childList.size(); i++) {
Element childInfo = (Element) childList.get(i);
String gh = childInfo.getChild("gh").getText();
Date ygjs2jpsxrq = this.sqlserver.getStringToDate(childInfo
.getChild("ygjs2jpsxrq").getText());
String jslx = childInfo.getChild("jslx").getText();
String ygjs2jshbm = childInfo.getChild("ygjs2jshbm").getText();
// 截取前四位代码
String preNo = "";
if ((ygjs2jshbm != null) && (!"".equals(ygjs2jshbm.trim()))) {
char[] nos = ygjs2jshbm.trim().toCharArray();
for (int j = 0; (j < 4) && (nos.length > 4); j++) {
preNo = preNo + nos[j];
}
}
System.out.println("截取前四位代码___________________" + preNo);
String jsjp = childInfo.getChild("jsjp").getText();
String ygjs2jshgw = childInfo.getChild("ygjs2jshgw").getText();
String ygjs2jshzj = childInfo.getChild("ygjs2jshzj").getText();
String ygjs2jshbmsj = childInfo.getChild("ygjs2jshbmsj")
.getText();
String ygjs2smpf = childInfo.getChild("ygjs2smpf").getText();
String ygjs2zkpjf = childInfo.getChild("ygjs2zkpjf").getText();
String ygjs2bkpjf = childInfo.getChild("ygjs2bkpjf").getText();
Date syqjsrq = this.sqlserver.getStringToDate(childInfo
.getChild("syqjsrq").getText());
Date syqksrq = this.sqlserver.getStringToDate(childInfo
.getChild("syqksrq").getText());
double jbgz = Double.parseDouble(childInfo.getChild("jbgz")
.getText());
double gwjt = Double.parseDouble(childInfo.getChild("gwjt")
.getText());
double zwjt = Double.parseDouble(childInfo.getChild("zwjt")
.getText());
double ygjs2ydjxxztz = Double.parseDouble(childInfo.getChild(
"ygjs2ydjxxztz").getText());
double ygjs2jdjxxztz = Double.parseDouble(childInfo.getChild(
"ygjs2jdjxxztz").getText());
double ygjs2ndjxxztz = Double.parseDouble(childInfo.getChild(
"ygjs2ndjxxztz").getText());
String C558H = "02";
String procId = childInfo.getChild("procId").getText();
String procNo = childInfo.getChild("procNo").getText();
// 获取主键信息
String A0100 = getUserId(gh);
int I9999 = getSeriaNo("UsrA55", A0100, "A0100");
dbcon.setAutoCommit(false);
// 判断流程ID是否已经存在
boolean isHas = procIsHas(procId, "usrA01", "E0127");
System.out.println(isHas);
if (!isHas) {
if (!StringHandle.isEmpty(A0100)) {
String sqlStr = "select top 1 * from usrA55 where A0100='"
+ A0100 + "' order by I9999 desc";
System.out.println("sqlStr-----------------------"
+ sqlStr);
dbcon = DBUtil.getInstance().getConnect();
ResultSet rst = dbcon.createStatement().executeQuery(
sqlStr);
if (rst.next()) {
System.out.println("11");
jbgz += rst.getDouble("C558E");
gwjt += rst.getDouble("C558F");
zwjt += rst.getDouble("C558G");
ygjs2ydjxxztz += rst.getDouble("C558B");
ygjs2jdjxxztz += rst.getDouble("C558C");
ygjs2ndjxxztz += rst.getDouble("C558D");
}
String insertA55 = "insert into usrA55(A0100,I9999,C558E,C558F,C558G,C558B,C558C,C558D,C558H,A5545) values('"
+ A0100
+ "','"
+ I9999
+ "','"
+ jbgz
+ "','"
+ gwjt
+ "','"
+ zwjt
+ "','"
+ ygjs2ydjxxztz
+ "','"
+ ygjs2jdjxxztz
+ "','"
+ ygjs2ndjxxztz
+ "','" + C558H + "','" + ygjs2jpsxrq + "')";
// C220T
String insertSQL = "insert into UsrA22(A0100,I9999,C2202,C2205,C2203,C2204,C220F,C220N,C220M,C2207,C220K,C220L,C220U,C2206) values('"
+ A0100
+ "','"
+ I9999
+ "','"
+ ygjs2jpsxrq
+ "','"
+ ygjs2jshbm
+ "','"
+ ygjs2jshgw
+ "','"
+ ygjs2jshzj
+ "','"
+ ygjs2jshbmsj
+ "','"
+ syqksrq
+ "','"
+ syqjsrq
+ "','"
+ ygjs2smpf
+ "','"
+ ygjs2zkpjf
+ "','"
+ ygjs2bkpjf
+ "','"
+ jsjp
+ "','"
+ getZGSJ2(ygjs2jshbmsj) + "')";
System.out
.println("insertA55**************************"
+ insertA55);
System.out
.println("insertSQL**************************"
+ insertSQL);
dbcon.createStatement().execute(insertA55);
dbcon.createStatement().execute(insertSQL);
String updateA01 = "update usrA01 set E0122='"
+ ygjs2jshbm + "',E01A1='" + ygjs2jshgw
+ "', C01UT='" + ygjs2jshzj + "',C01UZ='"
+ ygjs2jshbmsj + "',C01V6='" + preNo
+ "' where E0127='" + gh + "'";
System.out.println("updateA01*************************"
+ updateA01);
dbcon.createStatement().execute(updateA01);
String tempSql = "select top 1 I9999 from usrA55 where I9999 not in (select top 1 I9999 from usrA55 where A0100='"
+ A0100
+ "' order by I9999 desc) and A0100='"
+ A0100 + "' order by I9999 desc";
System.out.println(tempSql);
ResultSet r = dbcon.createStatement().executeQuery(
tempSql);
String id = null;
String upsdateA55 = null;
if (r.next()) {
id = r.getString("I9999");
}
if ((id != null) && (ygjs2jpsxrq != null)) {
upsdateA55 = "update usrA55 set C5557=DATEADD(day,-1,'"
+ ygjs2jpsxrq
+ "') where I9999='"
+ id
+ "' and A0100 = '" + A0100 + "' ";
System.out.println(upsdateA55);
int count = dbcon.createStatement().executeUpdate(
upsdateA55);
if (count > 0)
System.out.println("更新成功");
else {
System.out.println("更新失败");
}
}
resultId = "0";
} else {
System.out.println("在职人员库找不到该员工信息!");
}
}
}
dbcon.commit();
} catch (Exception ex) {
ex.printStackTrace();
//this.rollback(dbcon);
} finally {
this.setAutoCommit(dbcon, true);
SynClient.closeDb(dbcon, null);
}
return resultId;
}
}