package com.engine.kq.wfset.attendance.dao;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import weaver.common.StringUtil;
import com.engine.kq.wfset.attendance.framework.BaseConnection;
import com.engine.kq.wfset.attendance.framework.BaseDao;
import com.engine.kq.wfset.attendance.domain.HrmAttFlowVersion;
import weaver.conn.RecordSet;

/**
 * HrmAttFlowVersionDao
 * <p>Generated from 长东设计1.0.9 http://www.mfstyle.cn</p> 
 * 
 * @author wcd
 * @version 1.0 2016-05-31
 */
public class HrmAttFlowVersionDao extends BaseConnection implements BaseDao<HrmAttFlowVersion> {

	public Comparable insert(HrmAttFlowVersion bean) {
		return -1;
	}

	public void insert(List<HrmAttFlowVersion> list) {
		
	}

	public void update(HrmAttFlowVersion bean) {
		return;
	}
	
	public boolean allowedToCopy(HrmAttFlowVersion bean) {
    RecordSet rs = new RecordSet();
		if(bean.isError()) return false;
		
		StringBuffer sql = new StringBuffer("select sum(case when field001 = ")
		.append(bean.getField001()).append(" then 1 else 0 end) as oldWfIdCount, sum(case when field001 = ")
		.append(bean.getField002()).append(" then 1 else 0 end) as newWfIdCount from");
		switch (bean.getType()) {
		case ATT_PROC:
			sql.append(" kq_ATT_PROC_SET");
			break;
		case STATE_PROC:
			sql.append(" hrm_state_proc_set");
			break;
		}
		rs.executeSql(sql.toString());
		int oldWfIdCount = 0, newWfIdCount = 0;
		if(rs.next()) {
			oldWfIdCount = StringUtil.parseToInt(rs.getString("oldWfIdCount"));
			newWfIdCount = StringUtil.parseToInt(rs.getString("newWfIdCount"));
		}
		return oldWfIdCount > 0 && newWfIdCount == 0;
	}

	public List<HrmAttFlowVersion> find(Map<String, Comparable> map) {
		return new ArrayList<HrmAttFlowVersion>();
	}

	public HrmAttFlowVersion get(Comparable id) {
		return null;
	}

	public int count(Map<String, Comparable> map) {
		return -1;
	}

	public void delete(Comparable id) {
		
	}

	public void delete(Map<String, Comparable> map) {
		
	}

}
