MoveTimeTempToHistory.java 3.13 KB
Newer Older
TongZuu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
/*
 * Created on 10 .. 2549
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.csc.library.process;

import com.csc.library.utilities.MyLog;
import java.util.Vector;

import com.csc.library.databean.Ttimetemp;
import com.csc.library.session.DbInquiry;
import com.csc.library.session.DbRecord;
import com.csc.library.session.InitialInquiry;
import com.csc.library.session.InitialRecord;
import com.csc.library.utilities.CscCalendar;

/**
 * @author SassyBoy100
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
/*
 * class 㹡 move šŧ ŧ ѵԡŧ
 * TTIMETEMP --> TTIMETEMP_HISTORY
 */
public class MoveTimeTempToHistory extends ProcessTimeBase {
	
	private DbInquiry inq = null;
	
	public Vector getProcessList() {
		Vector v = new Vector();
		try {
			this.setParamData();
			if (!this.getParamValue("filterProcess").equals("")) {
				DbInquiry inq = new InitialInquiry(this.upf).getDbInquiry();
				inq.setParam(this.data);
				inq.setSchemaName(this.upf.getSchemaName());
				inq.initMyTable("Memployee", this.getParamValue("filterProcess"), "employeeid");
				inq.setColumn("employeeid, time0, runno, bossid, bu1, bu2, bu3, bu4, bu5, companyid, startdate, resigndate, status");
				inq.setFatchAll(true);
				inq.refresh();
				while (inq.next()) {
					v.addElement(inq.getCurrentDbRecord().getString("employeeid"));
				}
			}
		} catch (Exception e) {
			MyLog.error(this, e);			
		}
		return v;
	}
	
	public void process() throws Exception {		
		this.setParamData();
		CscCalendar cs1 = new CscCalendar(this.getParamValue("startDate"));
		//cs1.decDate();
		CscCalendar cs2 = new CscCalendar(this.getParamValue("endDate"));
		//cs2.incDate();
				
		String filter="";
		Vector vt = this.processList;
		for (int i=0;i<vt.size() && !this.isCancle();i++) {
			String id = (String) vt.elementAt(i);
			filter = "employeeid='" + (String) vt.elementAt(i) + "' and (swipedate between '"+cs1.getYYYYMMDD()+"' and '"+cs2.getYYYYMMDD()+"') ";
			this.moveHistory(filter); //ӡ move data
			this.alive("Process EmployeeID : "+id+" ["+i+" of "+vt.size()+"]");
		}
		this.setMessage("Successful of MoveTimeTempToHistory : "+vt.size());
		this.setFullMessage("Successful of MoveTimeTempToHistory : "+vt.size()+"\n");	
	}
	
	/*
	 * ӡ¢šŧҨҡ
	 * TTIMETEMP --> TTIMETEMP_HISTORY
	 */
	private void moveHistory(String filter) {
		try {
			if (this.inq == null) {
				this.inq = new InitialInquiry(this.upf).getDbInquiry();
				this.inq.setParam(this.data);
				this.inq.setSchemaName(this.upf.getSchemaName());
				this.inq.initMyTable("Ttimetemp", "", "");
				this.inq.setColumn("*");
			}
			this.inq.setFilter(filter);
			this.inq.refresh();
			while (this.inq.next()) {
				Ttimetemp rec = (Ttimetemp) this.inq.getCurrentDbRecord().cloneRecord(true);
			 	rec.setReferOn(true);
			 	rec.moveTimeHistory();
			}
		} catch (Exception e) {
			MyLog.error(this, e);			
		}
	}
}