Tot0_liteon.java 21.3 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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579
package com.csc.library.databean;

import java.rmi.RemoteException;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.Vector;

import com.csc.library.database.ChildManager;
import com.csc.library.database.MyHashMap;
import com.csc.library.session.DbInquiry;
import com.csc.library.session.DbRecord;
import com.csc.library.session.DbTable;
import com.csc.library.session.InitialInquiry;
import com.csc.library.session.InitialRecord;
import com.csc.library.session.InitialTable;
import com.csc.library.session.RecordCmp;
import com.csc.library.timeattendance.AdjustResult;
import com.csc.library.timeattendance.DayShift;
import com.csc.library.timeattendance.Shift;
import com.csc.library.timeattendance.TimeZone;
import com.csc.library.timeattendance.WorkingShift;
import com.csc.library.utilities.CscCalendar;
import com.csc.library.utilities.MyLog;
import com.csc.library.utilities.MyTreeMap;

public class Tot0_liteon extends RecordCmp {

	private MyTreeMap hmResult = new MyTreeMap();	
	private DbInquiry inqEmp = null;
	private DbInquiry inqTot1_liteon = null;	
	private DbTable dbTot1_liteon = null; 
	private DbTable dbChild=null;
	private String errorMsg = "";
	
	public Tot0_liteon() {
		super("Tot0_liteon", "Tot0_liteon Table");
	}
	
	private void chkEmpInq() {
		try {
			if (this.inqEmp ==null) {
				this.inqEmp = new InitialInquiry(this.userPro).getDbInquiry();
				this.inqEmp.setParam(this.param);
				this.inqEmp.setSchemaName(this.userPro.getSchemaName());
				this.inqEmp.initMyTable("Memployee", "", "");
				this.inqEmp.setColumn("employeeid, time0, companyid, status, startdate, resigndate, emp_level, maternity, maternity_start, maternity_end");
			}
		} catch (Exception e) {
			MyLog.debug(this, e);
		}
	}
	
	private void chkTot1Db() {
		try {
			if (this.dbTot1_liteon == null) {
				this.dbTot1_liteon = new InitialTable(this.userPro).getDbTable("Tot1_liteon");
				this.dbTot1_liteon.setColumn("*");
			}
		} catch (Exception e) {
			MyLog.debug(this, e);
		}	
	}
	
	private void chkTot1Inq() {
		try {
			if (this.inqTot1_liteon ==null) {
				this.inqTot1_liteon = new InitialInquiry(this.userPro).getDbInquiry();
				this.inqTot1_liteon.setParam(this.param);
				this.inqTot1_liteon.setSchemaName(this.userPro.getSchemaName());
				this.inqTot1_liteon.initMyTable("Tot1_liteon", "", "");
			}
		} catch (Exception e) {
			MyLog.debug(this, e);
		}
	}
	
	public MyTreeMap getDocAllTimeZone(){
		MyTreeMap hm = new MyTreeMap();
		CscCalendar begDate = new CscCalendar(this.getString("start_date"));
		CscCalendar endDate = new CscCalendar(this.getString("end_date"));
		while (begDate.beforeEqualsDate(endDate)) {	
			CscCalendar cs1 = new CscCalendar(begDate.getYYYYMMDD());
			CscCalendar cs2 = new CscCalendar(begDate.getYYYYMMDD());			
			try {
				cs1.setCSCTime(this.getFloat("start_time"));
				cs2.setCSCTime(this.getFloat("end_time"));
			} catch (Exception e) {
				MyLog.error(this, e);			
			}
			TimeZone tz = new TimeZone();
			tz.setBeginZone(new CscCalendar(cs1.getTimestamp()));
			tz.setEndZone(new CscCalendar(cs2.getTimestamp()));
			hm.put(begDate.getYYYYMMDD(), tz);
			begDate.incDate();			
		}
		return hm;
	}
	
	public TimeZone getDocTimeZone(){
		CscCalendar cs1 = new CscCalendar(this.getString("start_date"));
		CscCalendar cs2 = new CscCalendar(this.getString("end_date"));		
		try {
			cs1.setCSCTime(this.getFloat("start_time"));
			cs2.setCSCTime(this.getFloat("end_time"));
		} catch (Exception e) {
			MyLog.error(this, e);			
		}
		TimeZone tz = new TimeZone();
		tz.setBeginZone(new CscCalendar(cs1.getTimestamp()));
		tz.setEndZone(new CscCalendar(cs2.getTimestamp()));		
		return tz;
	}
	
	private MyTreeMap genRecord(boolean isSave) {
		MyTreeMap hm = new MyTreeMap();
		try {
			DbTable dt;			
			int count=1;
			WorkingShift wsNormal = null ;
			
			DbRecord rec = new InitialRecord(this.userPro).getDbRecord("TadjTime0");
			rec.setColumn("*");
			
			if (this.getChild("Tot1_liteon")!=null) {
				dt = (DbTable) this.getChild("Tot1_liteon");			
			} else {
				this.chkTot1Db();
				this.putChild(this.dbTot1_liteon);
				this.refreshChild("Tot1_liteon");
				dt = (DbTable) this.getChild("Tot1_liteon");
			}			
			dt.first();
			while (!dt.eof()) {
				Tot1_liteon db = (Tot1_liteon) dt.getCurrentRecordManager();
				
				MyHashMap hmShiftTemp = new MyHashMap();
				this.chkEmpInq();
				this.inqEmp.setFilter("employeeid='" + db.getString("employeeid") + "'");				
				this.inqEmp.refresh();
				if (this.inqEmp.next()) {

					Mtime0 recTime = (Mtime0) new InitialRecord(this.userPro).getDbRecord("Mtime0");
					recTime.set("time0id", this.inqEmp.getString("time0"));
					recTime.set("companyid", this.userPro.get("companyid"));
					recTime.search();

					CscCalendar cs1 = new CscCalendar(this.getString("start_date"));
					cs1.decDate(3);
					CscCalendar cs2 = new CscCalendar(this.getString("end_date"));
					cs2.incDate(3);
					
					recTime.setEmpRec(this.inqEmp.getCurrentDbRecord().cloneRecord(false));
										
					WorkingShift ws = recTime.genWorkingShift(new CscCalendar(cs1.getYYYYMMDD()), 
							new CscCalendar(cs2.getYYYYMMDD()));
					if (!ws.isEmpty()) {						
						ws.setUProfile(this.userPro);
						ws.setEmployeeid(this.inqEmp.getString("employeeid"));
						//ws.adjust(db.getString("doctype"), db.getString("otid"), db.getString("employeeid"));
						ws.adjust();
						ws.overlapChecking();
						ws.createLink();
						
						//ӡźѹش͡ͷ
						ws.removeStopShift();
						
						Iterator itTime = this.getDocAllTimeZone().keySet().iterator();
						while (itTime.hasNext()) {
							String key = (String) itTime.next();
										
							Vector vAdjust = new Vector();
							if (this.param.containsKey("__otfix") && ((String) this.param.get("__otfix")).equals("true")) {
								CscCalendar d1 = new CscCalendar(this.getString("start_date"));								
								CscCalendar d2 = new CscCalendar(this.getString("end_date"));
								while (d1.beforeEqualsDate(d2)) {
									CscCalendar t1 = new CscCalendar(d1.getDDMMYYYY());	
									t1.setCSCTime(this.getFloat("start_time"));
									CscCalendar t2 = new CscCalendar(d1.getDDMMYYYY());	
									t2.setCSCTime(this.getFloat("end_time"));
									if (t2.before(t1)) { //͡¡ ǡѹա 1 ѹ
										t2.incDate();
									}									
									TimeZone tz = new TimeZone();
									tz.setBeginZone(new CscCalendar(t1.getTimestamp()));
									tz.setEndZone(new CscCalendar(t2.getTimestamp()));		
									Vector v = ws.genAddShiftTrans(tz);
									for (int i=0;i<v.size();i++) {
										vAdjust.add(v.elementAt(i));
									}
									d1.incDate();
								}		
								MyLog.debug("OT FOR OTFIX : \n"+vAdjust);
							} else {
								if (ws.chkAddShiftTrans(this.getDocTimeZone())) {
									MyLog.debug(this, "TIME NOT MATCH IN SHIFT !!!");
								} else {
									vAdjust = ws.genAddShiftTrans(this.getDocTimeZone());
								}
							}
							
							MyLog.debug(this, "\n\n<<<<<<<<<<<< Display Data To Save >>>>>>>>>>>>>");
							Iterator it = vAdjust.iterator();
							MyLog.debug(this, "ADD Transaction");
							while (it.hasNext()) {
								AdjustResult result = (AdjustResult) it.next();
								MyLog.debug(this, result.toString());																
								
								String timeCode = result.getTimeCode();
								
								//if (timeCode.equals("")) {
									wsNormal = recTime.genWorkingShift(new CscCalendar(cs1.getYYYYMMDD()), 
											new CscCalendar(cs2.getYYYYMMDD()),"true");
									if (wsNormal!=null && !wsNormal.isEmpty()) {
										for (Iterator itNormal = wsNormal.keySet().iterator(); itNormal.hasNext();) {
											String keyNormal = (String) itNormal.next();
											DayShift dsNormal = (DayShift) wsNormal.get(keyNormal);
											for (Iterator it2 = dsNormal.keySet().iterator(); it2.hasNext();) {
												String key2 = (String) it2.next();
												Shift sh = (Shift) dsNormal.get(key2);
												hmShiftTemp.put(sh.getShiftDate().getYYYYMMDD(), sh.getTimeCode());
											}
										}
									}
									wsNormal.setUProfile(this.userPro);
									wsNormal.setEmployeeid(this.inqEmp.getString("employeeid"));
									//wsNormal.adjust(db.getString("doctype"), db.getString("otid"), db.getString("employeeid"));
									wsNormal.adjust();
									MyLog.debug(this, " ====== WorkingShitf Normal ====== ");
									MyLog.debug(this, this.getUProfile(), wsNormal.toString());
								//}
								
								if (wsNormal!=null) {
									if (wsNormal.containsKey(result.get_DT_BG().getYYYYMMDD())) {
										DayShift d = (DayShift) wsNormal.get(result.get_DT_BG().getYYYYMMDD());
										Iterator i = d.keySet().iterator();
										while (i.hasNext()) {
											String dKey = (String) i.next();
											Shift s = (Shift) d.get(dKey);
											if (!s.getTimeCode().equals(result.getTimeCode())) {
												timeCode = s.getTimeCode();
												MyLog.debug(this, ">>>timeCode Change === "+timeCode);
											}
										}
									}
								}
								
								if (isSave) {
									rec.clearField();
									rec.set("COMPANYID", this.getString("companyid"));
									rec.set("DOCID", this.getString("otid"));
									rec.set("DOCTYPE", "O");
									rec.set("DT_BG", result.get_DT_BG().getYYYYMMDD());
									rec.set("TM_BG", result.get_DT_BG().getCSCTime());
									rec.set("DT_EN", result.get_DT_EN().getYYYYMMDD());
									rec.set("TM_EN", result.get_DT_EN().getCSCTime());
									rec.set("UPDTYPE", result.getType());
									rec.set("DOCDATE", result.getAdjDate().getYYYYMMDD());
									rec.set("EMPLOYEEID", db.getString("employeeid"));
									if (timeCode.equals("")) {
										if (hmShiftTemp.containsKey(result.getAdjDate().getYYYYMMDD())) {
											rec.set("TIME0ID", hmShiftTemp.getString(result.getAdjDate().getYYYYMMDD()));
										}
									} else rec.set("TIME0ID", timeCode);
									rec.set("EVENTGRP", "O");
									rec.set("OLDTIME0ID", "");
									rec.set("OLDEVENTGRP", "");
									rec.set("LV_TY", "");
									rec.set("LV", result.get_LV());
									rec.set("TR_TYPE", result.getEventGroup());
									rec.set("ADJUSTTEMP", "");
									rec.set("STATUS", dt.getString("status"));
									rec.set("PRIORITY", "2");	
									rec.set("OT_WORKAREA", db.getString("ot_workarea"));
									rec.set("OT_SALATYPE", db.getString("ot_salatype"));
									rec.set("OT_TYPE", db.getString("ot_type"));
									rec.set("OT_TIME0", this.getString("shift"));
									rec.set("HOUR_S", result.getHour_s());
									rec.set("WF_STATUS", db.getString("wf_status"));
									rec.save();
								} else {
									MyHashMap hmData = new MyHashMap();
									hmData.put("COMPANYID", this.getString("companyid"));
									hmData.put("DOCID", this.getString("otid"));
									hmData.put("DOCTYPE", "O");
									hmData.put("DT_BG", result.get_DT_BG().getYYYYMMDD());
									hmData.put("TM_BG", result.get_DT_BG().getCSCTime());
									hmData.put("DT_EN", result.get_DT_EN().getYYYYMMDD());
									hmData.put("TM_EN", result.get_DT_EN().getCSCTime());
									hmData.put("UPDTYPE", result.getType());
									hmData.put("DOCDATE", result.getAdjDate().getYYYYMMDD());
									hmData.put("EMPLOYEEID", db.getString("employeeid"));
									if (timeCode.equals("")) {
										if (hmShiftTemp.containsKey(result.getAdjDate().getYYYYMMDD())) {
											hmData.put("TIME0ID", hmShiftTemp.getString(result.getAdjDate().getYYYYMMDD()));
										}
									} else hmData.put("TIME0ID", timeCode);
									hmData.put("EVENTGRP", "O");
									hmData.put("OLDTIME0ID", "");
									hmData.put("OLDEVENTGRP", "");
									hmData.put("LV_TY", "");
									hmData.put("LV", result.get_LV());
									hmData.put("TR_TYPE", result.getEventGroup());
									hmData.put("ADJUSTTEMP", "");
									hmData.put("STATUS", dt.getString("status"));
									hmData.put("PRIORITY", "2");	
									hmData.put("OT_WORKAREA", db.getString("ot_workarea"));
									hmData.put("OT_SALATYPE", db.getString("ot_salatype"));
									hmData.put("OT_TYPE", db.getString("ot_type"));
									hmData.put("OT_TIME0", this.getString("shift"));
									hmData.put("HOUR_S", result.getHour_s());
	                				hmData.put("WF_STATUS", db.getString("wf_status"));
									hm.put(String.valueOf(count),hmData);
									this.hmResult.put(String.valueOf(count),hmData);
									count++;
								}
							}
						}
					} else {
						this.errorMsg = "Not Working Plan";
						return hm;
					}
				} else {
					this.errorMsg = "EmployeeID : "+db.getString("employeeid")+" is wrong";
					return hm;
				}
				dt.next();
			}
		} catch (Exception e) {
			MyLog.error(this, e);			
		}
		if (hm.isEmpty()) {
			this.errorMsg = "No data in this request OT";
		}
		return hm;
	}
	
	private void updateWFChild(String wf) {
		try {
			if (this.dbChild != null) {
				this.putChild(this.dbChild);
			}
			
			if (this.getChild("Tot1_liteon")!=null) {
				DbTable db = (DbTable) this.getChild("Tot1_liteon");
				db.first();
				do{				
					DbRecord rec = (DbRecord) db.getCurrentRecordManager();				
					rec.set("WF_STATUS",wf);
					db.next();				
				} while (!db.eof());		
				//db.save();
			} else {			
				this.chkTot1Inq();
				this.inqTot1_liteon.setColumn("OTID, COMPANYID, LINE_ON, EMPLOYEEID, WF_STATUS");			
				this.putChild(this.inqTot1_liteon);
				this.refreshChild("Tot1_liteon");
				DbInquiry inqChild = (DbInquiry) this.getChild("Tot1_liteon");				
				do{	
					DbRecord rec = inqChild.getCurrentDbRecord().cloneRecord(true);
					rec.set("wf_status",wf);
					rec.save();
				} while (inqChild.next());	
				this.removeChild("Tot1_liteon");
			}
		} catch (Exception e) {
			MyLog.error(this, e);			
		}
	}
	
	private void delDataAdjTime0() {		
		try {
			DbInquiry inq = new InitialInquiry(this.userPro).getDbInquiry();
			inq.setParam(this.param);
			inq.setSchemaName(this.userPro.getSchemaName());
			inq.initMyTable("Tadjtime0", "docid='"+this.getString("otid")+"' and doctype='O'", "");
			inq.setColumn("*");
			inq.refresh();
			while (inq.next()) {
				DbRecord recChild = inq.getCurrentDbRecord().cloneRecord(true);
				recChild.delete();
			}
		} catch (Exception e) {
			MyLog.error(this, e);			
		}
	}
	
	protected boolean preInsertTrigger() throws Exception {
		boolean result = super.preInsertTrigger();	
		this.hmResult.clear();
				
		if (this.getString("wf_status").equalsIgnoreCase("4") || this.getString("wf_status").equalsIgnoreCase("6")
				|| this.getString("wf_status").equalsIgnoreCase("8") || this.getString("wf_status").equalsIgnoreCase("9")) {
            this.setWFOff();
        }
		
		if (!this.getString("wf_status").equalsIgnoreCase("9")) {
            this.preProcessWf();
        }		
		
		if (this.getString("wf_status").equalsIgnoreCase("4") || this.getString("wf_status").equalsIgnoreCase("6")) {
			String empMaternity = this.chkShiftMaternity();
			if (!empMaternity.equals("")) {
				this.param.put("error_msg",	"Error Because This Day, Employee is Maternity : "+empMaternity);
				MyLog.debug(this, "NOT REQUEST OT !!!");
				this.saveStatus = 99;
				return false;
			} else this.genRecord(false);
		} 
		/*if (this.hmResult.isEmpty()) {
			this.param.put("error_msg",	"No Data For This Request OT");
			MyLog.error(this, "No Data For This Request OT");
			return false; //ӡâͷբ㹡÷ͷ
		}*/
		if (!this.errorMsg.equals("")) {
			this.param.put("error_msg", this.errorMsg);
			MyLog.error(this, this.errorMsg);
		}
		
		this.updateWFChild(this.getString("wf_status"));
		return result;
	}
	
	protected boolean preUpdateTrigger() throws Exception {
		boolean result = super.preUpdateTrigger();	
		this.hmResult.clear();
		if (this.getString("wf_status").equalsIgnoreCase("4") || this.getString("wf_status").equalsIgnoreCase("6")
				|| this.getString("wf_status").equalsIgnoreCase("8") || this.getString("wf_status").equalsIgnoreCase("9")) {
            this.setWFOff();
        }
		
		if (!this.getString("wf_status").equalsIgnoreCase("9")) {
            this.preProcessWf();
        }
		
		if (this.getString("wf_status").equalsIgnoreCase("4") || this.getString("wf_status").equalsIgnoreCase("6")) {
			String empMaternity = this.chkShiftMaternity();
			if (!empMaternity.equals("")) {
				this.param.put("error_msg",	"Error Because This Day, Employee is Maternity : "+empMaternity);
				MyLog.debug(this, "NOT REQUEST OT !!!");
				this.saveStatus = 99;
				return false;
			} 
		}
		
		if (this.getString("wf_status").equalsIgnoreCase("8") || 
				this.getString("wf_status").equalsIgnoreCase("7") || 
				this.getString("wf_status").equalsIgnoreCase("B")) {		
			this.setColumn(this.getListKey()+",wf_status");
			dbChild = (DbTable) this.getChild("inqTot1_liteon");
			this.removeChild("inqTot1_liteon");
		}
		
		this.updateWFChild(this.getString("wf_status"));
				
		/*this.genRecord(false);
		if (this.hmResult.isEmpty()) {
			MyLog.error(this, "No Data For This Request OT");
			return false; //ӡâͷբ㹡÷ͷ
		}*/
		return result;
	}

	protected void postInsertTrigger() throws Exception {		
		if (this.param.containsKey("__wfcmd")) {
			if (this.param.get("__wfcmd").equals("true")) {
				this.setWFOn();			
			} else this.setWFOff();
		}
		super.postInsertTrigger();
		if (this.getString("wf_status").equalsIgnoreCase("4") || this.getString("wf_status").equalsIgnoreCase("6")) {
			this.delDataAdjTime0();
			this.saveHashMapData("TADJTIME0", this.hmResult);
			//this.genRecord();
		} else if (this.getString("wf_status").equalsIgnoreCase("8") || this.getString("wf_status").equalsIgnoreCase("9")) {
			this.delDataAdjTime0();
		}		
	}

	protected void postUpdateTrigger() throws Exception {		
		if (this.param.containsKey("__wfcmd")) {
			if (this.param.get("__wfcmd").equals("true")) {
				this.setWFOn();			
			} else this.setWFOff();
		}
		super.postUpdateTrigger();
		if (this.getString("wf_status").equalsIgnoreCase("4") || this.getString("wf_status").equalsIgnoreCase("6")) {
			this.delDataAdjTime0();
			//this.saveHashMapData("TADJTIME0", this.hmResult);
			this.genRecord(true);
		} else if (this.getString("wf_status").equalsIgnoreCase("8") || this.getString("wf_status").equalsIgnoreCase("9")) {
			this.delDataAdjTime0();
		}	
	}
	
	protected void postDeleteTrigger() throws Exception {		
		super.postDeleteTrigger();
		this.delDataAdjTime0();
	}
	
	public MyTreeMap getDWRData() {
		return this.genRecord(false);
	}
	
	private String genCh() {
		String bossid = (String) this.param.get("__bossid");
		int lineno = 1;
		try {
			ChildManager oChild = this.getChild("TOT1_LITEON");
			if ((oChild != null) && (oChild instanceof DbTable)) {
				DbTable dbTable = (DbTable) oChild;
				dbTable.last();
				//dbTable.previous();
				lineno = dbTable.getInt(dbTable.getMinorKey());
				if (lineno==1) lineno=0;
				
                this.chkEmpInq();
                this.inqEmp.setFilter("bossid ='"+bossid+"'");
                this.inqEmp.setColumn("employeeid, bossid, time0, companyid, status, startdate, resigndate, emp_level, maternity, maternity_start, maternity_end");
                this.inqEmp.refresh();
                while (this.inqEmp.next()){
                    DbRecord rec = dbTable.getNewRecord();
                    if (!rec.getString("maternity").equals("1")) {
						rec.set("OTID", this.getString("otid"));
						rec.set("EMPLOYEEID", this.inqEmp.getString("employeeid"));
						rec.set("COMPANYID", this.getUProfile().get("companyid"));					
						rec.set(dbTable.getMinorKey(), ++lineno);
						dbTable.putNewRecord(rec);
                    }
                }
			}
		} catch (RemoteException e) {
			MyLog.error(this, e);		
		}
		return String.valueOf(lineno);
	}
	
	public String getString(String field) {
		if (field.equalsIgnoreCase("gen")) {
			return this.genCh();
		} else {
			return super.getString(field);
		}
	}
	
	/*
	 * Ǩͺ  ӡâͷͷյ駤
	 * ҡաõ駤öͷ
	 */
    private String chkShiftMaternity() {
    	String result = "";
    	try {
	    	if (this.getChild("Tot1_liteon")!=null) {
	    		DbTable dt = (DbTable) this.getChild("Tot1_liteon");			
				dt.first();
				while (!dt.eof()) {				
					this.chkEmpInq();
					this.inqEmp.setFilter("employeeid='"+dt.getString("employeeid")+"'");
					this.inqEmp.refresh();
					if (this.inqEmp.next()) {
						DbRecord rec = this.inqEmp.getCurrentDbRecord();
						if (rec.getString("maternity").equals("1")) { //駤
							CscCalendar c1 = new CscCalendar(this.getString("start_date"));
							CscCalendar c2 = new CscCalendar(this.getString("end_date"));									
							CscCalendar e1 = new CscCalendar(rec.getString("maternity_start"));
							CscCalendar e2 = new CscCalendar(rec.getString("maternity_end"));
							if (c1.after(e1) && c2.before(e2)) { //ͷͷ㹪ǧ駤
								result += rec.getString("employeeid")+",";
							}	
						}
					} //else return false; //Ҿѡҹ
					dt.next();
				} //End while (!dt.eof())
			} //End if (this.getChild("Tchshift1_liteon")!=null)   	
		} catch (Exception e) {
			MyLog.error(this ,e);
		}
    	return result;
    }
}