public List <WorkerStatic> StaticByWorker(StsticQuery taskEntity) { var mResult = new List <WorkerStatic>(); using (IDbConnection conn = new SqlConnection(GetConnstr)) { StringBuilder strSql = new StringBuilder(@"SELECT w.WNo,w.WName,r.BillNO TaskCode,t.TName TaskName,t.StartDateTime,COUNT(distinct r.BillNO)TaskCount, SUM(case CountType when '好件' then r.Count else 0 end) GoodCount, SUM(case CountType when '坏件' then r.Count else 0 end) BadCount FROM [dbo].[tRecordDetail] r inner join [dbo].[tLine] l on l.LCode = r.LineCode inner join [dbo].[tTask] t on t.LineCode = r.LineCode inner join [dbo].[tWorker] w on w.WId=r.WId where r.Status = 1 and r.BillNO!='' "); if (!string.IsNullOrWhiteSpace(taskEntity.BillNO)) { strSql.Append(" and r.BillNO>=@BillNO "); } if (!string.IsNullOrWhiteSpace(taskEntity.LineCode)) { strSql.Append(" and r.LineCode>=@LineCode "); } if (!string.IsNullOrWhiteSpace(taskEntity.StationCode)) { strSql.Append(" and r.StationCode>=@StationCode "); } if (taskEntity.WId > 0) { strSql.Append(" and r.WId>=@WId "); } if (taskEntity.startTime != null && taskEntity.startTime != DateTime.MinValue) { strSql.Append(" and t.StartDateTime>=@startTime "); } if (taskEntity.endTime != null && taskEntity.endTime != DateTime.MinValue) { strSql.Append(" and t.EndDateTime<=@endTime "); } strSql.Append(" group by w.WNo,w.WName,r.BillNO,t.TName,t.StartDateTime"); var param = new { taskEntity.BillNO, taskEntity.LineCode, taskEntity.StationCode, taskEntity.WId, taskEntity.startTime, taskEntity.endTime }; mResult = conn.Query <WorkerStatic>(strSql.ToString(), param).ToList(); } return(mResult); }
public void Export(int StaticType, StsticQuery recordDetailEntity) { if (StaticType == 0) { var result = ststicRepository.StaticByTask(recordDetailEntity); ExportTask(result); } if (StaticType == 1) { var result = ststicRepository.StaticByWorker(recordDetailEntity); ExportWorker(result); } if (StaticType == 2) { var result = ststicRepository.StaticByLine(recordDetailEntity); ExportLine(result); } }
public ActionResult StaticResult(int StaticType, StsticQuery recordDetailEntity) { if (StaticType == 0) { var result = ststicRepository.StaticByTask(recordDetailEntity); return(View("TaskResult", result)); } if (StaticType == 1) { var result = ststicRepository.StaticByWorker(recordDetailEntity); return(View("WorkerResult", result)); } if (StaticType == 2) { var result = ststicRepository.StaticByLine(recordDetailEntity); return(View("LineResult", result)); } return(View()); }