public bool ProcessOTItemNoDB(OTItem item) { OT_WORK otwork = new OT_WORK(); otwork.WORK_ID = Guid.NewGuid().ToString(); otwork.VERSION_NUM = 0; otwork.HOURS_UPDATE = 0; otwork.CREATE_DATE = DateTime.Parse(item.Create_Ed); otwork.CREATE_BY = "System"; SysSeqServiceImpl SYS = new SysSeqServiceImpl(); if (string.IsNullOrEmpty(item.OT_ApplyNumber)||item.OT_ApplyNumber=="") { //旧系统没有此单号则新系统导入时根据申请的批次或申报周期自动生成 OT_APP1 app1 = CreateAPP1NoDB(item); otwork.APP1_ID = app1.APP1_ID; OT_APP2 app2 = CreateAPP2NoDB(item, app1.CYCLE_ID); otwork.APP2_ID = app2.APP2_ID; } else { var q = from p in context.OT_APP1 where p.APP1_NO == item.OT_ApplyNumber select p; OT_APP1 existApp1 = q.FirstOrDefault(); if (existApp1 == null) { Comm.Logger.Warn(string.Format("No exist app1_no in database with value {0}", item.OT_ApplyNumber)); OT_APP1 app1 = CreateAPP1NoDB(item); otwork.APP1_ID = app1.APP1_ID; OT_APP2 app2 = CreateAPP2NoDB(item, app1.CYCLE_ID); otwork.APP2_ID = app2.APP2_ID; } else { otwork.APP1_ID = existApp1.APP1_ID; } } DateTime dt_app1app2 = DateTime.Now; //一二级审批人, october vesrtion no need // CreateAudit(item, otwork.APP1_ID); if (!string.IsNullOrEmpty(item.OT_Number)) otwork.WORK_NO = item.OT_Number; else otwork.WORK_NO = SYS.getNumberByCode(ISysSeqService.SEQ_CODE_WORK, (DateTime)otwork.CREATE_DATE); otwork.ACHIVE_DATE = DateTime.Now; //store current date as achive date otwork.DEL_STATUS = "0"; otwork.HOURS = decimal.Parse(item.OT_Hours); otwork.TIMES = decimal.Parse(item.Compensate_Rate); string strDate = item.OT_StartTime; if (item.OT_StartTime.Length < DATEFORMAT.Length) strDate = item.OT_StartEd.ToString().Substring(0, NOTIMEFORMAT.Length + 1).Trim() + " " + item.OT_StartTime; otwork.START_DATE = DateTime.ParseExact(strDate, DATEFORMAT, ZH); strDate = item.OT_EndTime; if (strDate.Length < DATEFORMAT.Length) strDate = item.OT_EndEd.Substring(0, NOTIMEFORMAT.Length + 1).Trim() + " " + item.OT_EndTime; otwork.END_DATE = DateTime.ParseExact(strDate, DATEFORMAT, ZH); otwork.OT_TYPE = "-1"; //-1=从旧系统导入 otwork.PAY_TYPE = "0"; // 0 or 1? decimal pay_hours=string.IsNullOrEmpty(item.Pay_Hours)?0:item.Pay_Hours==""?0:decimal.Parse(item.Pay_Hours); decimal offset_hours = string.IsNullOrEmpty(item.Offset_Hours) ? 0 : item.Offset_Hours == "" ? 0 : decimal.Parse(item.Offset_Hours); if (!offset_hours.Equals(otwork.HOURS - pay_hours)) { Comm.Logger.Error("补休!=加班-支付"); ExcelTool.WriteErrorOLEDB(item, "补休!=加班-支付"); } if(pay_hours==0) otwork.PAY_TYPE = "1"; var q2 = from p in context.OT_SHIFT where p.SHIFT_NAME == item.Shift_Id select p; if (q2.FirstOrDefault() == null) { Comm.Logger.Warn(string.Format("没发现班次{0}存在,新建了班次", item.Shift_Id)); otwork.SHIFT_ID = CreateNewShift(item.Shift_Id, item.Compensate_Rate).SHIFT_ID; } else otwork.SHIFT_ID = q2.FirstOrDefault().SHIFT_ID; otwork.ORG_ID = this.GroupId; otwork.EMP_ID = this.EmpId; otwork.VERSION_NUM = 0; otwork.CREATE_TYPE = "0"; otwork.REASON = item.Reason; otwork.REMARK = item.Comment + "-从旧系统导入"; listOTWork.Add(otwork); return true; }
OT_APP1 CreateAPP1(OTItem item) { //数据导入需要根据时间新建申报周期,导入时会根据时间创建或选择合适的申报周期 string cycleId = NewOrSelectCycle(item); OT_APP1 app1 = new OT_APP1(); app1.CREATE_DATE = DateTime.Parse(item.Create_Ed); app1.CREATE_BY = "System"; SysSeqServiceImpl sys=new SysSeqServiceImpl(); //?? prefix "OB" app1.APP1_ID = Guid.NewGuid().ToString(); app1.APP1_NO = sys.getSeqNumByCode(SysSeqServiceImpl.SEQ_CODE_APP1_PERSON); app1.APP_TYPE = "-1"; // 从旧系统导入 app1.CYCLE_ID = cycleId; app1.ORG_ID = this.GroupId; app1.STATUS = "3"; //审批状态:0,草稿;1,一级审批;2,二级审批;3,审批完成 app1.STATUS_FROM = "0";//,状态来源:0,下级上报(新建);1,撤回;2,驳回; app1.VERSION_NUM = 0;// context.OT_APP1.Add(app1); return app1; }
OT_APP2 CreateAPP2NoDB(OTItem item, string cycleId) { OT_APP2 app2 = new OT_APP2(); app2.CYCLE_ID = cycleId; app2.ORG_ID = this.DeptId; app2.STATUS = "3"; //审批状态:0,组别经理审批完成(新建);1,部门经理审批;2,hr审核;3,审批完成 //状态来源:0,下级上报(新建);1,撤回;2,驳回; SysSeqServiceImpl sys = new SysSeqServiceImpl(); app2.STATUS_FROM = "0"; app2.CREATE_BY = "System"; app2.CREATE_DATE = DateTime.Parse(item.Create_Ed); app2.APP2_NO = sys.getSeqNumByCode(SysSeqServiceImpl.SEQ_CODE_APP2); app2.APP2_ID = Guid.NewGuid().ToString(); app2.APP_TYPE = "-1"; // 从旧系统导入 app2.VERSION_NUM = 0; listApp2.Add(app2); return app2; }