public List <LogTownStatisItem> getCountyList(System.Data.IDbConnection db, GetLogStatisList request, List <LogStatisItem> loglist, List <ADCDInfo> townList, List <LogStatisItem> loglistCounty, string _adcd, List <LogTownStatisItem> _list) { LogTownStatisItem ns = null; var countlist = db.Select <ADCDInfo>(w => w.adcd.EndsWith("000000000") && w.adcd.StartsWith(_adcd.Substring(0, 4)) && w.adcd != _adcd).OrderBy(o => o.adcd).ToList(); _list = new List <LogTownStatisItem>(); countlist.ForEach(w => { ns = new LogTownStatisItem(); var fcitycount = loglist.Where(x => x.adcd.StartsWith(w.adcd.Substring(0, 6))).ToList(); ns.townUpdateNum = fcitycount == null ? 0 : fcitycount.Count; ns.ADNM = w.adnm; ns.ADCD = w.adcd; var ftown = townList.Where(x => x.adcd.StartsWith(w.adcd.Substring(0, 6))).ToList(); ns.townAllNum = ftown == null ? 0 : ftown.Count; ns.countyIfUpdate = loglistCounty.Count == 0 ? 0 : loglistCounty.Find(x => x.adcd == w.adcd) != null ? 1 : 0; _list.Add(ns); }); return(_list); }
public List <LogTownStatisItem> getTownList(System.Data.IDbConnection db, GetLogStatisList request, List <LogStatisItem> loglist, List <ADCDInfo> townList, List <LogStatisItem> loglistCounty, string _adcd, string stime, string etime, List <LogTownStatisItem> _list) { LogTownStatisItem ns = null; //330102000000000 var towlist = db.Select <ADCDInfo>(w => w.adcd.StartsWith(_adcd.Substring(0, 6)) && w.grade == 3 && w.adcd != _adcd).OrderBy(o => o.adcd).ToList(); _list = new List <LogTownStatisItem>(); towlist.ForEach(w => { ns = new LogTownStatisItem(); ns.ADCD = w.adcd; ns.ADNM = w.adnm; var r = getTownPersonNum(db, w.adcd, stime, etime); if (r != null) { ns.townPersonNum = r.townPersonNum; ns.workgroupPersonNum = r.workgroupPersonNum; ns.gridPersonNum = r.gridPersonNum; ns.transferPersonNum = r.transferPersonNum; ns.picPersonNum = r.picPersonNum; } //var a = db.SqlList<LogTownStatisItem>("EXEC LogTownPStatics @stime,@etime,@townadcd,@adcd", new { stime = stime, etime = etime, townadcd = adcd.Substring(0, 9), adcd = adcd }).ToList().FirstOrDefault(); //ns.townPersonNum = a != null ? a.townPersonNum : 0; //var b = db.SqlList<LogTownStatisItem>("EXEC LogWorkingGroupPStatics @stime,@etime,@townadcd,@adcd", new { stime = stime, etime = etime, townadcd = adcd.Substring(0, 9), adcd = adcd }).ToList().FirstOrDefault(); //ns.workgroupPersonNum = b != null ? b.workgroupPersonNum:0; //var c = db.SqlList<LogTownStatisItem>("EXEC LogGridPStatics @stime,@etime,@townadcd,@adcd", new { stime = stime, etime = etime, townadcd = adcd.Substring(0, 9), adcd = adcd }).ToList().FirstOrDefault(); //ns.gridPersonNum = c != null ? c.gridPersonNum : 0; //var d = db.SqlList<LogTownStatisItem>("EXEC LogTransferPStatics @stime,@etime,@townadcd,@adcd", new { stime = stime, etime = etime, townadcd = adcd.Substring(0, 9), adcd = adcd }).ToList().FirstOrDefault(); //ns.transferPersonNum =d != null ? d.transferPersonNum:0; //var e = db.SqlList<LogTownStatisItem>("EXEC LogPicPStatics @stime,@etime,@townadcd,@adcd", new { stime = stime, etime = etime, townadcd = adcd.Substring(0, 9), adcd = adcd }).ToList().FirstOrDefault(); //ns.picPersonNum = e != null ? e.picPersonNum : 0; _list.Add(ns); }); return(_list); }
public SuperviseModel GetLogStatisList(GetLogStatisList request) { using (var db = DbFactory.Open()) { var stime = ""; var etime = ""; if (string.IsNullOrEmpty(request.starttime) && string.IsNullOrEmpty(request.endtime)) { stime = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd 00:00:00"); etime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59"); } else { stime = request.starttime + " 00:00:00"; etime = request.endtime + " 23:59:59"; } var _adcd = string.IsNullOrEmpty(request.adcd) ? adcd : request.adcd; SuperviseModel sm = new SuperviseModel(); var loglist = db.Select <LogStatisItem>("select adcd,COUNT(adcd) adcdount from LogInfo where (OperationType='新增' or OperationType='更新') and SUBSTRING(adcd,7,3) > 0 and adcd like '%000000' and tm >= '" + stime + "' and tm <= '" + etime + "' group by adcd order by adcd asc"); var townList = db.Select <ADCDInfo>(w => w.adcd.EndsWith("000000") && w.adcd.Substring(6, 3) != "000"); List <LogTownStatisItem> _list = null; List <LogStatisItem> loglistCounty = new List <LogStatisItem>(); List <ADCDInfo> adcdlist = null; var parentid = ""; switch (RowID) { case 5: LogTownStatisItem ns = null; if (_adcd == adcd) { var citylist = db.Select <ADCDInfo>(w => w.adcd.EndsWith("00000000000") && w.adcd != "330000000000000").OrderBy(o => o.adcd).ToList(); _list = new List <LogTownStatisItem>(); citylist.ForEach(w => { ns = new LogTownStatisItem(); var fcity = loglist.Where(x => x.adcd.StartsWith(w.adcd.Substring(0, 4))).ToList(); ns.townUpdateNum = fcity == null ? 0 : fcity.Count; ns.ADNM = w.adnm; ns.ADCD = w.adcd; var ftown = townList.Where(x => x.adcd.StartsWith(w.adcd.Substring(0, 4))).ToList(); ns.townAllNum = ftown == null ? 0 : ftown.Count; _list.Add(ns); }); } else if (_adcd.Contains("00000000000")) { loglistCounty = db.Select <LogStatisItem>("select adcd,COUNT(adcd) adcdount from LogInfo where (OperationType='新增' or OperationType='更新') and Operation not like '%审核%' and SUBSTRING(adcd,5,2) > 0 and adcd like '%000000000' and tm >= '" + stime + "' and tm <= '" + etime + "' group by adcd order by adcd asc"); sm.adnm = db.Single <ADCDInfo>(w => w.adcd == _adcd).adnm; _list = getCountyList(db, request, loglist, townList, loglistCounty, _adcd, _list); } else if (_adcd.Contains("000000")) { parentid = _adcd.Substring(0, 4) + "00000000000"; adcdlist = db.Select <ADCDInfo>(w => w.adcd == _adcd || w.adcd == parentid); //县名 sm.GradeNameCounty = adcdlist.Single(w => w.adcd == _adcd).adnm; //市名 sm.GradeName = adcdlist.Single(w => w.adcd == parentid).adnm; //镇列表 _list = getTownList(db, request, loglist, townList, loglistCounty, _adcd, stime, etime, _list); } else { } sm.LSTownStatics = _list; break; case 2: //loglistCounty = db.Select<LogStatisItem>("select adcd,COUNT(adcd) adcdount from LogInfo where (OperationType='新增' or OperationType='更新') and SUBSTRING(adcd,5,2) > 0 and adcd like '%000000000' and tm > '" + stime + "' and tm < '" + etime + "' group by adcd order by adcd asc"); //_list = getCountyList(db, request, loglist, townList, loglistCounty, _adcd, _list); //sm.LSTownStatics = _list; if (_adcd.Contains("00000000000")) { loglistCounty = db.Select <LogStatisItem>("select adcd,COUNT(adcd) adcdount from LogInfo where (OperationType='新增' or OperationType='更新') and Operation not like '%审核%' and SUBSTRING(adcd,5,2) > 0 and adcd like '%000000000' and tm >= '" + stime + "' and tm <= '" + etime + "' group by adcd order by adcd asc"); sm.adnm = db.Single <ADCDInfo>(w => w.adcd == _adcd).adnm; _list = getCountyList(db, request, loglist, townList, loglistCounty, _adcd, _list); } else if (_adcd.Contains("000000")) { parentid = _adcd.Substring(0, 4) + "00000000000"; adcdlist = db.Select <ADCDInfo>(w => w.adcd == _adcd || w.adcd == parentid); //县名 sm.GradeNameCounty = adcdlist.Single(w => w.adcd == _adcd).adnm; //市名 sm.GradeName = adcdlist.Single(w => w.adcd == parentid).adnm; //镇列表 _list = getTownList(db, request, loglist, townList, loglistCounty, _adcd, stime, etime, _list); } else { } sm.LSTownStatics = _list; break; case 3: var pid = _adcd.Substring(0, 4) + "00000000000"; var f = db.Select <ADCDInfo>(w => w.adcd == _adcd || w.adcd == pid); //县名 sm.GradeNameCounty = f.Single(w => w.adcd == _adcd).adnm; //市名 sm.GradeName = f.Single(w => w.adcd == pid).adnm; //镇列表 _list = getTownList(db, request, loglist, townList, loglistCounty, _adcd, stime, etime, _list); sm.LSTownStatics = _list; break; } return(sm); } }