package cn.ksource.beans; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.apache.commons.lang.StringUtils; import cn.ksource.core.dao.BaseBean; import cn.ksource.core.util.ConvertUtil; import cn.ksource.core.util.StringUtil; /** * 问题诊断报告历史表 */ public class QUESTION_ZD_HISTORY extends BaseBean{ public final static Map KEYS = new HashMap(); private Map BEAN_VALUES = null; static { KEYS.put("id", "String"); KEYS.put("flowid", "String"); KEYS.put("reason", "String"); KEYS.put("resolve", "String"); KEYS.put("suggest", "String"); KEYS.put("istheend", "Integer"); KEYS.put("create_user_id", "String"); KEYS.put("create_user_name", "String"); KEYS.put("create_time", "Long"); } public Map getColumnMap(){ return KEYS; } private String id; private Boolean isSetted_id = false;; private String flowid; private Boolean isSetted_flowid = false; private String reason; private Boolean isSetted_reason = false; private String resolve; private Boolean isSetted_resolve = false; private String suggest; private Boolean isSetted_suggest = false; private Integer istheend; private Boolean isSetted_istheend = false; private String create_user_id; private Boolean isSetted_create_user_id = false; private String create_user_name; private Boolean isSetted_create_user_name = false; private Long create_time; private Boolean isSetted_create_time = false; private void initBeanValues(){ BEAN_VALUES = new HashMap(); BEAN_VALUES.put("id",id); BEAN_VALUES.put("flowid", null); BEAN_VALUES.put("reason", null); BEAN_VALUES.put("resolve", null); BEAN_VALUES.put("suggest", null); BEAN_VALUES.put("istheend", null); BEAN_VALUES.put("create_user_id", null); BEAN_VALUES.put("create_user_name", null); BEAN_VALUES.put("create_time", null); } public QUESTION_ZD_HISTORY() { initBeanValues(); } public QUESTION_ZD_HISTORY(String id) { super(); this.id = id; initBeanValues(); BEAN_VALUES.put("id",id); } /** * 获取ID */ public String getId() { return this.id; } /** * 设置ID */ public QUESTION_ZD_HISTORY setId(String id) { this.id = id; this.isSetted_id = true; BEAN_VALUES.put("id",id); return this; } @Override public String getUpdateSql() { StringBuffer sBuffer = new StringBuffer("update QUESTION_ZD_HISTORY set "); if (isSetted_flowid) { sBuffer.append("flowid=:flowid,"); } if (isSetted_reason) { sBuffer.append("reason=:reason,"); } if (isSetted_resolve) { sBuffer.append("resolve=:resolve,"); } if (isSetted_suggest) { sBuffer.append("suggest=:suggest,"); } if (isSetted_istheend) { sBuffer.append("istheend=:istheend,"); } if (isSetted_create_user_id) { sBuffer.append("create_user_id=:create_user_id,"); } if (isSetted_create_user_name) { sBuffer.append("create_user_name=:create_user_name,"); } if (isSetted_create_time) { sBuffer.append("create_time=:create_time,"); } String sql = sBuffer.toString(); return StringUtils.removeEnd(sql, ",") + " where id=:id"; } @Override public String getInsertSql() { StringBuffer sBuffer = new StringBuffer("insert into QUESTION_ZD_HISTORY("); StringBuffer fileds = new StringBuffer("id,"); StringBuffer values = new StringBuffer(":id,"); fileds.append("flowid,"); values.append(":flowid,"); fileds.append("reason,"); values.append(":reason,"); fileds.append("resolve,"); values.append(":resolve,"); fileds.append("suggest,"); values.append(":suggest,"); fileds.append("istheend,"); values.append(":istheend,"); fileds.append("create_user_id,"); values.append(":create_user_id,"); fileds.append("create_user_name,"); values.append(":create_user_name,"); fileds.append("create_time,"); values.append(":create_time,"); sBuffer.append(StringUtils.removeEnd(fileds.toString(), ",") + ") values("+StringUtils.removeEnd(values.toString(), ",")+")"); return sBuffer.toString(); } /** * 获取环节ID
* 䣺2016-56-08 hh:07 */ public String getFlowid() { return flowid; } /** * 设置环节ID
* 2016-56-08 hh:07 */ public QUESTION_ZD_HISTORY setFlowid(String flowid) { this.flowid = flowid; this.isSetted_flowid = true; BEAN_VALUES.put("flowid",flowid); return this; } /** * 获取根本原因
* 䣺2016-56-08 hh:07 */ public String getReason() { return reason; } /** * 设置根本原因
* 2016-56-08 hh:07 */ public QUESTION_ZD_HISTORY setReason(String reason) { this.reason = reason; this.isSetted_reason = true; BEAN_VALUES.put("reason",reason); return this; } /** * 获取解决方案
* 䣺2016-56-08 hh:07 */ public String getResolve() { return resolve; } /** * 设置解决方案
* 2016-56-08 hh:07 */ public QUESTION_ZD_HISTORY setResolve(String resolve) { this.resolve = resolve; this.isSetted_resolve = true; BEAN_VALUES.put("resolve",resolve); return this; } /** * 获取优化建议
* 䣺2016-56-08 hh:07 */ public String getSuggest() { return suggest; } /** * 设置优化建议
* 2016-56-08 hh:07 */ public QUESTION_ZD_HISTORY setSuggest(String suggest) { this.suggest = suggest; this.isSetted_suggest = true; BEAN_VALUES.put("suggest",suggest); return this; } /** * 获取是否为最终方案
* 䣺2016-56-08 hh:07 */ public Integer getIstheend() { return istheend; } /** * 设置是否为最终方案
* 2016-56-08 hh:07 */ public QUESTION_ZD_HISTORY setIstheend(Integer istheend) { this.istheend = istheend; this.isSetted_istheend = true; BEAN_VALUES.put("istheend",istheend); return this; } /** * 获取创建人编号
* 䣺2016-56-08 hh:07 */ public String getCreate_user_id() { return create_user_id; } /** * 设置创建人编号
* 2016-56-08 hh:07 */ public QUESTION_ZD_HISTORY setCreate_user_id(String create_user_id) { this.create_user_id = create_user_id; this.isSetted_create_user_id = true; BEAN_VALUES.put("create_user_id",create_user_id); return this; } /** * 获取创建人
* 䣺2016-56-08 hh:07 */ public String getCreate_user_name() { return create_user_name; } /** * 设置创建人
* 2016-56-08 hh:07 */ public QUESTION_ZD_HISTORY setCreate_user_name(String create_user_name) { this.create_user_name = create_user_name; this.isSetted_create_user_name = true; BEAN_VALUES.put("create_user_name",create_user_name); return this; } /** * 获取创建时间
* 䣺2016-56-08 hh:07 */ public Long getCreate_time() { return create_time; } /** * 设置创建时间
* 2016-56-08 hh:07 */ public QUESTION_ZD_HISTORY setCreate_time(Long create_time) { this.create_time = create_time; this.isSetted_create_time = true; BEAN_VALUES.put("create_time",create_time); return this; } /** * 使用ID删除Bean
*/ public void deleteById() { if (StringUtils.isBlank(id)) { throw new RuntimeException("删除bean时ID不能为空"); } dao.execute("delete from " + getTableName() + " where id = :id", BEAN_VALUES); } @Override public QUESTION_ZD_HISTORY getInstanceById() { if (StringUtils.isBlank(id)) { throw new RuntimeException("获取Bean时ID不能为空"); } return dao.queryForBean("select * from " + getTableName() + " where id=:id", BEAN_VALUES, this); } @Override public QUESTION_ZD_HISTORY queryForBean() { StringBuffer sBuffer = new StringBuffer("select * from QUESTION_ZD_HISTORY where "); if(isSetted_id){ sBuffer.append("id=:id and "); } if (isSetted_flowid) { sBuffer.append("flowid=:flowid and "); } if (isSetted_reason) { sBuffer.append("reason=:reason and "); } if (isSetted_resolve) { sBuffer.append("resolve=:resolve and "); } if (isSetted_suggest) { sBuffer.append("suggest=:suggest and "); } if (isSetted_istheend) { sBuffer.append("istheend=:istheend and "); } if (isSetted_create_user_id) { sBuffer.append("create_user_id=:create_user_id and "); } if (isSetted_create_user_name) { sBuffer.append("create_user_name=:create_user_name and "); } if (isSetted_create_time) { sBuffer.append("create_time=:create_time and "); } String sql = sBuffer.toString(); sql = StringUtils.removeEnd(sql, " and "); return dao.queryForBean(sql,this); } @Override public String getTableName() { return "QUESTION_ZD_HISTORY"; } public Map getBeanValues(){ return this.BEAN_VALUES; } @Override public QUESTION_ZD_HISTORY insert() { if (StringUtils.isBlank(id)) { this.setId(StringUtil.getUUID()); } dao.execute(getInsertSql(),BEAN_VALUES); return this; } @Override public QUESTION_ZD_HISTORY update() { if (StringUtils.isBlank(id)) { throw new RuntimeException("更新Bean时ID不能为空"); } dao.execute(getUpdateSql(),BEAN_VALUES); return this; } public QUESTION_ZD_HISTORY insertOrUpdate(){ if (StringUtils.isNotBlank(id)) { return update(); } else { return insert(); } } /** * 通过ID获取该条信息的Map结构 */ public Map getBeanMapById() { if (StringUtils.isBlank(id)) { throw new RuntimeException("ID不能为空!"); } return dao.queryForMap("select * from QUESTION_ZD_HISTORY where id=:id",BEAN_VALUES); } public Object mapRow(ResultSet rs, int rownum) throws SQLException { Object id = rs.getObject("ID"); this.setId(ConvertUtil.obj2Str(id)); BEAN_VALUES.put("id",id); Object obj = null; obj = rs.getObject("FLOWID"); BEAN_VALUES.put("flowid",obj); this.setFlowid(ConvertUtil.obj2Str(obj)); obj = rs.getObject("REASON"); BEAN_VALUES.put("reason",obj); this.setReason(ConvertUtil.obj2Str(obj)); obj = rs.getObject("RESOLVE"); BEAN_VALUES.put("resolve",obj); this.setResolve(ConvertUtil.obj2Str(obj)); obj = rs.getObject("SUGGEST"); BEAN_VALUES.put("suggest",obj); this.setSuggest(ConvertUtil.obj2Str(obj)); obj = rs.getObject("ISTHEEND"); BEAN_VALUES.put("istheend",obj); this.setIstheend(ConvertUtil.obj2Integer(obj)); obj = rs.getObject("CREATE_USER_ID"); BEAN_VALUES.put("create_user_id",obj); this.setCreate_user_id(ConvertUtil.obj2Str(obj)); obj = rs.getObject("CREATE_USER_NAME"); BEAN_VALUES.put("create_user_name",obj); this.setCreate_user_name(ConvertUtil.obj2Str(obj)); obj = rs.getObject("CREATE_TIME"); BEAN_VALUES.put("create_time",obj); this.setCreate_time(ConvertUtil.obj2Long(obj)); return this; } public String toString() { StringBuffer sb = new StringBuffer("["); for (Iterator iterator = KEYS.keySet().iterator(); iterator.hasNext();) { String key = (String) iterator.next(); sb.append(key+"=" + BEAN_VALUES.get(key)+","); } sb.append("]"); return sb.toString(); } public QUESTION_ZD_HISTORY newInstance(){ return new QUESTION_ZD_HISTORY(); } }