OA補打卡代碼

var dic = new Dictionary<string, object>();

dic.Add("USER_ID", ent.USER_ID);

dic.Add("WORK_CENTER", ent.WORK_CENTER);

dic.Add("WORK_DATE", ent.WORK_DATE);

dic.Add("CLASSES", ent.CLASSES);

dic.Add("ITREMARK", "OA補打卡");

string sqlString = "--看本班次是否已打卡\n" +

"select id /*,MASTER_ID, work_center, user_id, start_time, work_date, classes*/\n" +

"from class_record_line x\n" +

"where work_center = '" + ent.WORK_CENTER + "'\n" +

" and CLASSES='" + ent.CLASSES + "' and work_date = to_date('" + ent.WORK_DATE + "','yyyymmdd') \n" + //yyyy-mm-dd hh24:mi:ss

" and ENABLED=1 and user_id = '" + ent.USER_ID + "'\n" +

" and end_time is null\n" +

"/* and close_time is null*/";

 

int mid = imes.db.Ado.QuerySingle<int>(sqlString);

if (mid > 0)

{

//更新爲離崗卡

sqlString = "update CLASS_RECORD_LINE set ITREMARK='OA補打離崗卡'. SRC_TIME2 = 1, END_TIME =to_date('" + ent.CHECKTIME + "','yyyy-mm-dd hh24:mi:ss') where id =" + mid;

XLog.XTrace.WriteLine("OA補打離崗卡" + sqlString);

int row = imes.db.Ado.ExecuteNonQuery(sqlString);

XLog.XTrace.WriteLine(row + "OA補打離崗卡" + ent.USER_ID);

return "ok";

}

 

//獲取員工班次軌道

sqlString = "select classes, work_date, stand_start_time, stand_end_time, organization_team, organization_team_desc, user_id\n" +

"from checkinoutplan x\n" +

"where user_id = '" + ent.USER_ID + "'\n" +

" and CLASSES <> 'OFF' and to_date('" + ent.CHECKTIME + "','yyyy-mm-dd hh24:mi:ss') between stand_start_time - 4 / 24 and stand_end_time + 2 / 24";

XLog.XTrace.WriteLine("1.獲取員工班次軌道\r\n" + sqlString);

userplan 班次軌道 = imes.db.Ado.QuerySingle<userplan>(sqlString);

if (班次軌道 != null)

{

XLog.XTrace.WriteLine("抓到班次軌道");

dic.Add("STAND_START_TIME", 班次軌道.STAND_START_TIME);

dic.Add("STAND_END_TIME", 班次軌道.STAND_END_TIME);

dic.Add("WORK_DATE", 班次軌道.WORK_DATE);

dic.Add("CLASSES", 班次軌道.CLASSES);

}

else

{

dic.Add("REMARK", "無班次軌道 或者 排班錯誤");

}

 

//獲取頭表信息

sqlString = "select ID , STAND_START_TIME, STAND_END_TIME,WORK_DATE,CLASSES,start_time ,END_TIME \n" +

"from class_record_master x\n" +

"where work_center = '" + ent.WORK_CENTER + "'\n" +

" and work_date = to_date('" + ent.WORK_DATE + "','yyyy-mm-dd hh24:mi:ss')\n" +

" and classes = '" + ent.CLASSES + "'";

XLog.XTrace.WriteLine("3.首次打卡獲取是否已經開班\r\n" + sqlString);

masterInfo 頭表信息 = imes.db.Ado.QuerySingle<masterInfo>(sqlString);

if (頭表信息 == null)

{

cc.sendwx("20151763", "OA補打卡沒有找到開班頭表");

}

else

{

dic.Add("MASTER_ID", 頭表信息.ID);

XLog.XTrace.WriteLine("抓到頭表信息3.true " + ent.USER_ID + "繼承頭表ID");

}

獲取前次派崗信息(ent.USER_ID, ent.WORK_CENTER, dic);

dic.Add("ENABLED", 1);

int i = imes.db.InsertDict(dic).AsTable("CLASS_RECORD_LINE").ExecuteAffrows();

XLog.XTrace.WriteLine("上崗邏輯執行完成,插錶行數 " + i + Newtonsoft.Json.JsonConvert.SerializeObject(dic, Formatting.Indented));

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章