package cn.ksource.web.service.flow; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Resource; import org.springframework.stereotype.Service; import cn.ksource.beans.FlowRecord; import cn.ksource.core.dao.BaseDao; import cn.ksource.core.util.DateUtil; import cn.ksource.core.util.StringUtil; import cn.ksource.web.service.flow.FlowRecordService; @Service @SuppressWarnings({"unchecked","rawtypes"}) public class FlowRecordServiceImpl implements FlowRecordService{ @Resource private BaseDao baseDao; @Override public boolean addRecord(FlowRecord flowRecord) { flowRecord.setId(StringUtil.getUUID()); StringBuilder sql = new StringBuilder(); sql.append(" insert into flow_record "); sql.append(" (id,bus_id,template_key,flag,deal_id,deal_name,deal_time,note,extend_text,state,result_key,result_val) "); sql.append(" values "); sql.append(" (:id,:busId,:templateKey,:flag,:dealId,:dealName,:dealTime,:note,:extendText,1,:resultKey,:resultVal) "); Map map = new HashMap(); map.put("id", flowRecord.getId()); map.put("busId", flowRecord.getBusId()); map.put("templateKey", flowRecord.getTemplateKey()); map.put("flag", flowRecord.getResult()); map.put("dealId", flowRecord.getDealId()); map.put("dealName", flowRecord.getDealName()); map.put("dealTime", DateUtil.getCurrentDate14()); map.put("note", flowRecord.getNote()); map.put("extendText", flowRecord.getExtendText()); map.put("resultKey", flowRecord.getResKey()); map.put("resultVal", flowRecord.getResVal()); Integer num = baseDao.execute(sql.toString(), map); if(num!=null&&num>0){ return true; } return false; } @Override public List getRecordListByBusId(String busId, String extend){ StringBuilder sql = new StringBuilder(); Map map = new HashMap(); sql.append(" select * from flow_record where bus_id =:busId and state=1 "); if(StringUtil.isNotBlank(extend)){ sql.append(" and extend_text=:extend"); } sql.append(" order by deal_time desc "); map.put("busId", busId); map.put("extend", extend); return baseDao.queryForList(sql.toString(), map); } }