You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
haojing/classbean/DzbzDBWbsImpl.java

118 lines
4.0 KiB
Java

import com.caucho.xml.SAXBuilder;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.tisco.dzbz.DzbzUtil;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
*/
public class DzbzDBWbsImpl extends BaseBean implements DzbzDBWbs {
public String PROCESSDBSYReturn = "SUCCESS";
/**
*
* @param DBSYINFO
* @return
*/
public String PROCESSDBSY(String DBSYINFO){
System.out.println("dbxml======="+DBSYINFO);
int modeid = Util.getIntValue(getPropValue("dzbz","dzbzmodeid"));
SAXBuilder sb = new SAXBuilder();
try {
Map map = new HashMap();
String loginid = "";
Document doc = DocumentHelper.parseText(DBSYINFO); //将字符串转为XML
// 取的根元素
Element rootElt = doc.getRootElement();
// 得到根元素所有子元素的集合
List<Element> sons = rootElt.elements();//获取当前节点的子节点
if(0 != sons.size()) {
for (Element el : sons) {
String key = el.getName().trim();
String value = el.getText().trim();
System.out.println(key+"============"+value);
if("todouserid".equals(key)){
loginid=value;
}
// setFieldValueByName(key,dzbzBean,value);
map.put(key,value);
}
}
RecordSet rs = new RecordSet();
rs.execute("select id from hrmresource where loginid='"+loginid+"'");
rs.next();
int userid = Util.getIntValue(rs.getString("id"),0);
DzbzUtil.createmodedata(modeid,userid,map);
}catch (Exception e) {
e.printStackTrace();
}
return PROCESSDBSYReturn;
}
// private void setFieldValueByName(String fieldName, Object o,Object value) {
// try {
// String firstLetter = fieldName.substring(0, 1).toUpperCase();
// String getter = "set" + firstLetter + fieldName.substring(1);
// Method method = o.getClass().getMethod(getter, new Class[] {o.getClass().getDeclaredField(fieldName).getType()});
// method.invoke(o, new Object[] {getClassTypeValue(o.getClass().getDeclaredField(fieldName).getType(),value)});
// } catch (Exception e) {
// }
// }
//
//
// private static Object getClassTypeValue(Class<?> typeClass, Object value){
// if(typeClass == int.class || value instanceof Integer){
// if(null == value){
// return 0;
// }
// return value;
// }else if(typeClass == short.class){
// if(null == value){
// return 0;
// }
// return value;
// }else if(typeClass == byte.class){
// if(null == value){
// return 0;
// }
// return value;
// }else if(typeClass == double.class){
// if(null == value){
// return 0;
// }
// return value;
// }else if(typeClass == long.class){
// if(null == value){
// return 0;
// }
// return value;
// }else if(typeClass == String.class){
// if(null == value){
// return "";
// }
// return value;
// }else if(typeClass == boolean.class){
// if(null == value){
// return true;
// }
// return value;
// }else if(typeClass == BigDecimal.class){
// if(null == value){
// return new BigDecimal(0);
// }
// return new BigDecimal(value+"");
// }else {
// return typeClass.cast(value);
// }
// }
}