?? timesheetsrc.java.svn-base
字號:
Map<String,String> detailHashResult = detailResult.get(i);
detail.setTsdetailid(detailHashResult.get("tsdetailid"));
detail.setTimesheetid(detailHashResult.get("timesheetid"));
detail.setProjactid(detailHashResult.get("projactid"));
detail.setProjectid(detailHashResult.get("projectid"));
detail.setActivityid(detailHashResult.get("activityid"));
detail.setSun(detailHashResult.get("sun"));
detail.setMon(detailHashResult.get("mon"));
detail.setTue(detailHashResult.get("tue"));
detail.setWed(detailHashResult.get("wed"));
detail.setThu(detailHashResult.get("thu"));
detail.setFri(detailHashResult.get("fri"));
detail.setSat(detailHashResult.get("sat"));
detail.setSubtotal(detailHashResult.get("subtotal"));
info.getDetaillist().add(detail);
}
}
else
{
String thisWeekFirstDay = weekbegin;
SimpleDateFormat df = new SimpleDateFormat("MM-dd-yyyy");
Date date = df.parse( parseDate( thisWeekFirstDay ) );
Calendar cale = Calendar.getInstance();
cale.setTime(date);
cale.roll(Calendar.WEEK_OF_YEAR, -1);
String lastWeekFirstDay = df.format(cale.getTime());
log.debug("(lastWeekFirstDay) " + lastWeekFirstDay + " --> " + thisWeekFirstDay + "(thisWeekFirstDay)");
String sSqlDtlEmpty = "select distinct proj.projectid as projectid, tsd.projactid as projactid, proj_act.activityid as activityid, proj.shortname as shortname, act.activity as activity " +
"from t_ts_detail tsd,t_timesheet ts,t_project proj,t_proj_act proj_act,t_proj_assign proj_assign,ct_activity act " +
"where act.activityid = proj_act.activityid " +
"and ts.weekbegining = to_date('" + lastWeekFirstDay + "', 'MM-dd-yyyy') " +
"and ts.resourceid = " + resourceid + " " +
"and tsd.timesheetid = ts.timesheetid " +
"and tsd.projactid = proj_act.projactid " +
"and proj_act.projectid = proj.projectid " +
"and ( proj.globalind = '1' " +
"or (proj_assign.projectid = proj.projectid " +
"and proj_assign.resourceid = ts.resourceid " +
"and proj_assign.todate >= to_date('" + thisWeekFirstDay + "', 'MM-dd-yyyy') ) ) " +
"and ( proj.projstatusid = '1' " +
"and proj.enddate >= to_date('" + thisWeekFirstDay + "', 'MM-dd-yyyy') ) " +
"order by shortname, activity";
List<Map<String,String>> detailResultEmpty = sdrc.executeRetrieve(conn, sSqlDtlEmpty);
if(!detailResultEmpty.isEmpty())
{
int size = detailResultEmpty.size();
for (int i = 0; i < size; i++)
{
TsDetails detail = new TsDetails();
Map<String,String> detailHashResultEmpty = detailResultEmpty.get(i);
detail.setTsdetailid(AppConstants.EMPTY_STRING);
detail.setTimesheetid(timesheetid);
detail.setProjactid(detailHashResultEmpty.get("projactid"));
detail.setProjectid(detailHashResultEmpty.get("projectid"));
detail.setActivityid(detailHashResultEmpty.get("activityid"));
detail.setSun("0");
detail.setMon("0");
detail.setTue("0");
detail.setWed("0");
detail.setThu("0");
detail.setFri("0");
detail.setSat("0");
detail.setSubtotal("0");
info.getDetaillist().add(detail);
}
}
}
}
}
catch(SQLException se)
{
log.error("selectTimeSheet() -- caught SQLException : ", se);
throw new NsiEventException("selectTimeSheet() -- caught SQLException : ", se);
}
catch(Exception ex)
{
log.error("selectTimeSheet() -- caught Exception : ", ex);
throw new NsiEventException("selectTimeSheet() -- caught Exception : ", ex);
}
finally
{
closeConnection();
}
}
public String parseDate(String date){
String month = date.substring(0,3);
if( month.equals("JAN") ){
month = "01";
}
if( month.equals("FEB") ){
month = "02";
}
if( month.equals("MAR") ){
month = "03";
}
if( month.equals("APR") ){
month = "04";
}
if( month.equals("MAY") ){
month = "05";
}
if( month.equals("JUN") ){
month = "06";
}
if( month.equals("JUL") ){
month = "07";
}
if( month.equals("AUG") ){
month = "08";
}
if( month.equals("SEP") ){
month = "09";
}
if( month.equals("OCT") ){
month = "10";
}
if( month.equals("NOV") ){
month = "11";
}
if( month.equals("DEC") ){
month = "12";
}
return month + date.substring(3,date.length() - 1 );
}
private void updateTimeSheetDetails(boolean toFinalize) throws NsiEventException
{
List<TsDetails> tsDetailList = info.getDetaillist();
if( (tsDetailList != null) && !( tsDetailList.isEmpty()) )
{
try
{
int size = tsDetailList.size();
for (int i = 0; i < size; i++)
{
TsDetails detail = tsDetailList.get(i);
String sSql = prepareUptDetailStmnt( detail,toFinalize );
log.debug("updateTimeSheetDetails() -- sSql["+sSql + "]");
if( ValHelper.getInstance().isNotNullAndEmpty(sSql) )
try
{
getConnection();
Statement stmt = conn.createStatement();
if(sdrc.executeUpdate(stmt, sSql) <= 0) throw new SQLException("0 records updated");
}
catch(SQLException se)
{
log.error("updateTimeSheetDetails() -- caught SQLException : ", se);
throw new NsiEventException("updateTimeSheetDetails() -- caught SQLException : ", se);
}
catch(Exception ex)
{
log.error("updateTimeSheetDetails() -- caught Exception : ", ex);
throw new NsiEventException("updateTimeSheetDetails() -- caught Exception : ", ex);
}
finally
{
closeConnection();
}
}
}
catch(Exception ex)
{
log.error("updateTimeSheetDetails() -- caught Exception : ", ex);
throw new NsiEventException("updateTimeSheetDetails() -- caught Exception : ", ex);
}
}
}
private String prepareUptDetailStmnt( TsDetails detail, boolean toFinalize ) throws NsiEventException
{
String sSql = AppConstants.EMPTY_STRING;
try
{
String detailid = detail.getTsdetailid().trim();
String subtotal = detail.getSubtotal().trim();
if( ValHelper.getInstance().isNullOrEmpty(detailid))
{// new added
if(!(toFinalize && "0.0".equals(subtotal)))
{
boolean testTSExist = isExistTimeSheetbyTSIdandProjActId(detail.getTimesheetid(), detail.getProjactid());
if(!testTSExist)
{
sSql = "insert into t_ts_detail (tsdetailid,timesheetid,projactid,sun,mon,tue,wed,thu,fri,sat,subtotal,moduserid ) " +
"values (nextval('tsdetailid_seq')," + detail.getTimesheetid() + "," + detail.getProjactid() + "," + detail.getSun().trim() + ","
+ detail.getMon().trim() + "," + detail.getTue().trim() + "," + detail.getWed().trim() + ","
+ detail.getThu().trim() + "," + detail.getFri().trim() + "," + detail.getSat().trim() + ","
+ subtotal.trim() + "," + modifyuser.trim() + ")";
}
}
}
else
{// modified
if(toFinalize && "0.0".equals(subtotal))
{
sSql = "delete from t_ts_detail where tsdetailid = " + detailid;
}
else
{
sSql = "update t_ts_detail set " +
"projactid= " + detail.getProjactid().trim() + ", " +
"sun=" + detail.getSun().trim() + ", mon=" + detail.getMon().trim() + ", " +
"tue=" + detail.getTue().trim() + ", wed=" + detail.getWed().trim() + ", " +
"thu=" + detail.getThu().trim() + ", fri=" + detail.getFri().trim() + ", " +
"sat=" + detail.getSat().trim() + ", subtotal=" + subtotal.trim() + ", " +
"moduserid=" + modifyuser.trim() + " where tsdetailid=" + detailid + "";
}
}
}
catch(Exception ex)
{
log.error("prepareUptDetailStmnt() -- caught Exception : ", ex);
throw new NsiEventException("prepareUptDetailStmnt() -- caught Exception : ", ex);
}
return sSql;
}
private void updateTimeSheetHeader(boolean toFinalize) throws NsiEventException
{
String sSql = "update t_timesheet set bfinalized = '" + (toFinalize ? "T" : "F") + "', moduserid=" + modifyuser.trim() + " " +
"where timesheetid = " + timesheetid + "";
try
{
getConnection();
Statement stmt = conn.createStatement();
if(sdrc.executeUpdate(stmt, sSql) <= 0) throw new SQLException("0 records updated");
}
catch(SQLException se)
{
log.error("updateTimeSheetHeader() -- caught SQLException : ", se);
throw new NsiEventException("updateTimeSheetHeader() -- caught SQLException : ", se);
}
catch(Exception ex)
{
log.error("updateTimeSheetHeader() -- caught Exception : ", ex);
throw new NsiEventException("updateTimeSheetHeader() -- caught Exception : ", ex);
}
finally
{
closeConnection();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -