| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823 |
- using CallCenter.Utility;
- using CallCenter.Utility.Linq;
- using CallCenter.Utility.Time;
- using CallCenterApi.Common;
- using CallCenterApi.DB;
- using CallCenterApi.Interface.Controllers.Base;
- using CallCenterApi.Interface.Models.Dto;
- using CallCenterApi.Model;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Web;
- using System.Web.Mvc;
- using static CallCenter.Utility.NPOIHelper;
- namespace CallCenterApi.Interface.Controllers.report
- {
- // [Authority]
- public class WorkOrderReportController : BaseController
- {
- private readonly BLL.T_Sys_Department departmentBLL = new BLL.T_Sys_Department();
- private readonly BLL.T_Bus_WorkOrder workOrderBLL = new BLL.T_Bus_WorkOrder();
- private readonly BLL.T_Bus_AssignedInfo assignedInfoBLL = new BLL.T_Bus_AssignedInfo();
- private readonly BLL.T_Bus_Feedback feedbackBLL = new BLL.T_Bus_Feedback();
- private readonly BLL.T_Sys_DictionaryValue dictValueBLL = new BLL.T_Sys_DictionaryValue();
- private readonly BLL.T_Sys_Area areaBLL = new BLL.T_Sys_Area();
- private readonly BLL.T_Bus_VisitResult visitResultBLL = new BLL.T_Bus_VisitResult();
- private readonly BLL.T_Bus_DelayTime delayTimeBLL = new BLL.T_Bus_DelayTime();
- private readonly BLL.T_Sys_UserAccount userAccount = new BLL.T_Sys_UserAccount();
- private readonly BLL.T_Bus_SubmitSuper submitsuperBLL = new BLL.T_Bus_SubmitSuper();
- /// <summary>
- /// 处理数量统计
- /// </summary>
- /// <returns></returns>
- public ActionResult GetDeptCount(DateTime? start, DateTime? end, bool isExport = false)
- {
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
-
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
- paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
- var obj = DbHelperSQL.RunProcedure("P_DeptDealReport", paras, "DeptDealReport");
- if (isExport)
- {
- var cols = new string[] { "单位名称", "数量" };
- new NPOIHelper().ExportToExcel($"处理数量统计报表{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
- return Success("导出excel");
- }
- return Success("成功", obj);
- }
- /// <summary>
- /// 处理效率统计
- /// </summary>
- /// <returns></returns>
- public ActionResult GetDeptEfficiency1(DateTime? start, DateTime? end, bool isExport = false)
- {
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
- paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
- var obj = DbHelperSQL.RunProcedure("P_DeptEfficiencyReport", paras, "DeptEfficiencyReport");
- if (isExport)
- {
- string[] cols = new string[] { "单位名称", "处理总量", "及时量", "超时量", "处理及时率" };
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("处理效率统计报表", obj.Tables[0], cols) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- return Success("成功", obj);
- }
- public ActionResult GetDeptEfficiency(DateTime? start, DateTime? end, bool isExport = false,string source="")
- {
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
- paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
- paras.Add("@source", source);
- var obj = DbHelperSQL.RunProcedure("P_DeptEfficiencyReport_1", paras, "DeptEfficiencyReport");
- var newSet = new DataSet();
- if (obj != null && obj.Tables[0] != null && obj.Tables[0].Rows.Count > 0)
- {
- obj.Tables[0].Columns.Add("rate", typeof(decimal));
- for (int i = 0; i < obj.Tables[0].Rows.Count; i++)
- {
- int completedcount = 0, timelycount = 0, timeoutcount = 0; double timelyrate = 0;
- int.TryParse(obj.Tables[0].Rows[i]["completedcount"].ToString(), out completedcount);
- int.TryParse(obj.Tables[0].Rows[i]["timelycount"].ToString(), out timelycount);
- int.TryParse(obj.Tables[0].Rows[i]["timeoutcount"].ToString(), out timeoutcount);
- timeoutcount = completedcount - timelycount;
- obj.Tables[0].Rows[i]["timeoutcount"] = timeoutcount;
-
- if (completedcount > 0)
- {
- timelyrate = double.Parse((timelycount * 100).ToString()) / completedcount;
- obj.Tables[0].Rows[i]["timelyrate"] = timelyrate.ToString("f") + "%";
- obj.Tables[0].Rows[i]["rate"] = timelyrate;
- }
- }
- obj.Tables[0].DefaultView.Sort = "rate desc";
- newSet.Tables.Add(obj.Tables[0].DefaultView.ToTable());
- newSet.Tables[0].Columns.Remove("rate");
- //obj.Tables[0] = obj.Tables[0].DefaultView.ToTable();
- }
- if (isExport)
- {
- string[] cols = new string[] { "单位名称", "处理总量", "及时量", "超时量", "处理及时率" };
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("处理效率统计报表", newSet.Tables[0], cols) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- return Success("成功", newSet);
- }
-
- /// <summary>
- /// 市民满意度评价
- /// </summary>
- /// <returns></returns>
- public ActionResult GetDeptSatisfied(DateTime? start, DateTime? end,int source=0, bool isExport = false)
- {
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
- paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
- paras.Add("@source", source.ToString());
- var obj = DbHelperSQL.RunProcedure("P_DeptSatisfied", paras, "DeptSatisfied");
- if (isExport)
- {
- string[] cols = new string[] { "单位名称", "受理总量", "处理总量", "满意总量", "基本满意总量", "不满意总量", "满意度" };
- new NPOIHelper().ExportToExcel($"满意度统计报表{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
- return Success("导出excel");
- }
- var ob = new
- {
- state = "success",
- message = "成功",
- DeptSatisfiedReport = obj ,
- };
- return Success("成功", ob );
-
- }
- /// <summary>
- /// 市民满意度评价台账
- /// </summary>
- /// <returns></returns>
- public ActionResult GetDeptSatisfiedList(string start, string end,int deptId=0,int myd=-1, int page = 1, int pagesize = 10, bool isExport = false)
- {
- string sql = " and F_IsDelete=0 and F_WorkState=9 and F_MainDeptId is not null and F_MainDeptId !='' and F_DealDeptId is not null and F_DealDeptId !=''";
- if (!string.IsNullOrEmpty(start)&&start.Trim() != "" && start != "undefined")
- {
- sql += " and F_CreateTime>='" + start + "' ";
- }
- if (!string.IsNullOrEmpty(end) && end.Trim() != "" && end != "undefined")
- {
- sql += " and F_CreateTime<='" + end + "' ";
- }
- if (deptId > 0)
- {
- sql += " and F_MainDeptId= " + deptId;
- }
- if (myd > -1)
- {
- sql += " and MYD= " + myd;
- }
- if (isExport)
- {
- var dtdc = DbHelperSQL.Query("select F_WorkOrderId,F_ComTitle,F_ComContent,dbo.GetDeptNames(F_MainDeptId) as DeptName,dbo.GetUserName(F_CreateUser) as UserName,F_LimitTime,F_Result,MYD from (select *,(select top 1 (case F_IsSatisfie when 1 then '满意' when 0 then '不满意' else '基本满意' end) F_Satisfie from T_Bus_VisitResult WITH(NOLOCK) where F_IsDelete = 0 and F_WorkOrderId = a.F_WorkOrderId order by F_Id desc) MYD from T_Bus_WorkOrder a WITH(NOLOCK)) b where 1=1 " + sql ).Tables[0];
- string[] dccols = new string[] { "工单编号", "述求标题", "工单内容", "承办单位", "受理人", "时限", "办理结果", "满意度" };
- new NPOIHelper().ExportToExcel($"满意度台账报表{DateTime.Now.ToString("yyyyMMddHHmmssfff")}", dtdc, dccols);
- return Success("导出excel");
- }
- string cols = " F_WorkOrderId,F_ComTitle,F_ComContent,dbo.GetDeptNames(F_MainDeptId) as DeptName,dbo.GetUserName(F_CreateUser) as UserName,F_WorkState,F_LimitTime,F_Result,MYD";
- int recordCount = 0;
- DataTable dt = BLL.PagerBLL.GetListPager(
- "(select *,(select top 1 F_IsSatisfie from T_Bus_VisitResult WITH(NOLOCK) where F_IsDelete = 0 and F_WorkOrderId = a.F_WorkOrderId order by F_Id desc) MYD from T_Bus_WorkOrder a WITH(NOLOCK)) b",
- "F_Id",
- cols,
- sql,
- "ORDER BY F_CreateTime DESC",
- pagesize,
- page,
- true,
- out recordCount);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 县区满意度评价
- /// </summary>
- /// <returns></returns>
- #region 20191022 调整多主办单位需调整
- public ActionResult GetAreaSatisfied(DateTime? start, DateTime? end, bool isExport = false)
- {
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- //var sql = "F_IsDelete=0 and F_IsSure=1 and F_State=1 and isnull(F_FeedbackTime,'')<>'' "
- // + "and datediff(day, F_FeedbackTime, @sdate) <= 0 and datediff(day, F_FeedbackTime, @edate) >= 0"
- // + "and F_WorkOrderId in (select F_WorkOrderId from T_Bus_WorkOrder where F_WorkState = 9)";
- //var assignedInfoList = assignedInfoBLL.GetModelList(sql);
- //var workorderList = workOrderBLL.GetModelList("");
- //var deptList = departmentBLL.GetModelList(" F_State=0 AND F_PartentId=0 ");
- //foreach (var item in deptList)
- //{
- // var deptlist2 = departmentBLL.GetModelList(" F_State=0 AND F_PartentId in (select F_DeptId FROM T_Sys_Department where F_State=0 AND F_PartentId=" + item.F_DeptId + ") ");
- //}
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
- paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
- var obj = DbHelperSQL.RunProcedure("P_AreaSatisfiedReport", paras, "AreaSatisfiedReport");
- if (isExport)
- {
- string[] cols = new string[] { "县/区", "处理总量", "满意总量", "不满意总量", "满意度" };
- new NPOIHelper().ExportToExcel($"满意度统计报表{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
- return Success("导出excel");
- }
- return Success("成功", obj);
- }
- //public ActionResult GetAreaSatisfied(DateTime? start, DateTime? end, bool isExport = false)
- //{
- // if (start == null)
- // {
- // start = DateTime.Now;
- // start = new DateTime(start.Value.Year, start.Value.Month, 1);
- // }
- // if (end == null)
- // {
- // end = DateTime.Now;
- // }
- // //string sql = $"select * from dbo.GetDeptSatisfied('{start.Value.ToString("yyyy-MM-dd")}','{end.Value.ToString("yyyy-MM-dd")}') ORDER BY rate DESC";
- // //var dtall = DbHelperSQL.Query(sql).Tables[0];
- // Dictionary<string, string> paras = new Dictionary<string, string>();
- // paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
- // paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
- // var obj = DbHelperSQL.RunProcedure("P_AreaSatisfiedReport", paras, "AreaSatisfiedReport");
- // if (isExport)
- // {
- // string[] cols = new string[] { "县/区", "处理总量", "满意总量", "不满意总量", "满意度" };
- // new NPOIHelper().ExportToExcel($"满意度统计报表{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
- // return Success("导出excel");
- // }
- // return Success("成功", obj);
- // //int recordCount = 0;
- // //var dt = BLL.PagerBLL.GetListPager(
- // // "("+sql+") as v",
- // // "deptname",
- // // "*",
- // // "",
- // // "ORDER BY rate DESC",
- // // pageSize,
- // // pageIndex,
- // // true,
- // // out recordCount);
- // //var obj = new
- // //{
- // // state = "success",
- // // message = "成功",
- // // rows = dt,
- // // total = recordCount
- // //};
- // //return Content(obj.ToJson());
- //}
- #endregion
-
- /// <summary>
- /// 单位绩效考核
- /// </summary>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <returns></returns>
- public ActionResult GetDeptAssessment(DateTime? start, DateTime? end, bool isExport = false,string source="")
- {
- StringBuilder sb1 = new StringBuilder();
- StringBuilder sb2 = new StringBuilder();
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
- paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
- paras.Add("@source", source);
- var obj = DbHelperSQL.RunProcedure("P_DeptAssessmentReport", paras, "DeptAssessmentReport");
- if (isExport)
- {
- string[] cols = new string[] { "单位名称", "已办总量", "及时量", "超时量", "超时时长(小时)", "延时量", "处理时长(小时)", "平均处理时长(小时)", "最大处理时长(小时)", "回访量", "市民满意", "市民不满意" };
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("单位绩效考核报表", obj.Tables[0], cols) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- return Success("成功", obj);
- }
-
- /// <summary>
- /// 坐席工作统计
- /// </summary>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <returns></returns>
- public ActionResult GetUserAccountAssessment1(DateTime? start, DateTime? end, bool isExport = false)
- {
- StringBuilder sb1 = new StringBuilder();
- StringBuilder sb2 = new StringBuilder();
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- paras.Add("@edate", end.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- var obj = DbHelperSQL.RunProcedure("P_UserAssessmentReport", paras, "UserAssessmentReport");
- if (isExport)
- {
- string[] cols = new string[] { "姓名", "接听量", "通话成单量", "手动录单量", "当即办理量", "网络转办量", "回访量"};
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("坐席工作统计报表", obj.Tables[0], cols) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- return Success("成功", obj);
- }
- public ActionResult GetUserAccountAssessment(DateTime? start, DateTime? end, bool isExport = false,string source="",string name="")
- {
- StringBuilder sb1 = new StringBuilder();
- StringBuilder sb2 = new StringBuilder();
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- paras.Add("@edate", end.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- paras.Add("@source", source);
- paras.Add("@name", name);
-
- var obj = DbHelperSQL.RunProcedure("P_UserAssessmentReport_1", paras, "UserAssessmentReport");
- if (isExport)
- {
- string[] cols = new string[] { "姓名", "接听量", "通话成单量", "手动录单量", "当即办理量", "网络转办量", "回访量","呼出量" ,"回拨量"};
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("坐席工作统计报表", obj.Tables[0], cols) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- return Success("成功", obj);
- }
- public ActionResult GetUserReturn(DateTime? start, DateTime? end, bool isExport = false)
- {
- StringBuilder sb1 = new StringBuilder();
- StringBuilder sb2 = new StringBuilder();
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- paras.Add("@edate", end.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- var obj = DbHelperSQL.RunProcedure("P_UserReturn", paras, "UserReturn");
- if (isExport)
- {
- string[] cols = new string[] { "姓名", "工单量", "回访量", "未回访量", "回访率" };
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("坐席回访统计报表", obj.Tables[0], cols) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- return Success("成功", obj);
- }
-
- public ActionResult WorkOrdrList(int isdc=0)
- {
- DataTable dt = new DataTable();
- string sql = " and F_IsDelete=0 ";
-
- int sourceArea = RequestString.GetInt("sourceArea", 0);
- int keyid = RequestString.GetInt("keyid", 0);
- int deptid = RequestString.GetInt("deptid", 0);
- int key = RequestString.GetInt("key", 0);
- int timetype = RequestString.GetInt("timetype", 0);
- int ishf = RequestString.GetInt("ishf", 0);
- int area = RequestString.GetInt("area", 0);
- int state = RequestString.GetInt("state", -1);
- int type = RequestString.GetInt("type", 0);
- int source = RequestString.GetInt("source", 0);
- string mobile = RequestString.GetQueryString("mobile");
- int dbdb = RequestString.GetInt("dbdb", 0);
- int db = RequestString.GetInt("db", 0);
- string dbusercode = RequestString.GetQueryString("dbusercode");
- string strpageindex = RequestString.GetQueryString("page");
- string strpagesize = RequestString.GetQueryString("pagesize");
- string usercode = RequestString.GetQueryString("usercode");
- string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- int isRelease = RequestString.GetInt("isRelease", 0);
- int name= RequestString.GetInt("name", 0);
- int handling = RequestString.GetInt("handling", 0);
- int pageindex = 1;
- int pagesize = 10;
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- if (!string .IsNullOrEmpty (usercode))
- {
- sql += " and F_CreateUser='"+ usercode + "' ";
- }
- string value = "";
- if (string .IsNullOrEmpty (strstarttime)&& string.IsNullOrEmpty(strendtime))
- {
-
- if (db > 0 || dbdb>0)
- {
-
- DateTime start;
- start = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
- if (dbdb==5)
- {
- value += "and datediff(SS ,F_CreateTime,'" + start.ToString("yyyy-MM-dd HH:mm:ss") + "')<=0 ";
- value += " and datediff(SS ,F_CreateTime,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')>=0";
- }
- else
- {
- value += "and datediff(SS ,SupervisorTime,'" + start.ToString("yyyy-MM-dd HH:mm:ss") + "')<=0 ";
- value += " and datediff(SS ,SupervisorTime,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')>=0";
- }
-
- }
- else
- {
- if (timetype == 1)
- {
- sql += "and datediff(DAY ,a.F_CreateTime ,getdate())=0 ";
- }
- else if (timetype == 2)
- {
- sql += "and datediff(WEEK ,a.F_CreateTime ,getdate())=0 ";
- }
- else if (timetype == 4)
- {
- }
- else
- {
- sql += " and datediff(MONTH ,a.F_CreateTime ,getdate())=0 ";
- }
- }
- }
- else
- {
- if (db>0 || dbdb > 0)
- {
-
-
- if (dbdb == 5)
- {
- if (!string.IsNullOrEmpty(strstarttime))
- {
- value += "and datediff(SS ,F_CreateTime,'" + strstarttime + "')<=0 ";
- }
- if (!string.IsNullOrEmpty(strendtime))
- {
- value += " and datediff(SS ,F_CreateTime,'" + strendtime + "')>=0";
- }
- }
- else
- {
- if (!string.IsNullOrEmpty(strstarttime))
- {
- value += "and datediff(SS ,SupervisorTime,'" + strstarttime + "')<=0 ";
- }
- if (!string.IsNullOrEmpty(strendtime))
- {
- value += " and datediff(SS ,SupervisorTime,'" + strendtime + "')>=0";
- }
- }
- }
- else
- {
- if (!string.IsNullOrEmpty(strstarttime))
- {
- sql += "and datediff(SS ,F_CreateTime,'" + strstarttime + "')<=0 ";
- }
- if (!string.IsNullOrEmpty(strendtime))
- {
- sql += " and datediff(SS ,F_CreateTime,'" + strendtime + "')>=0";
- }
- }
-
- }
- if (dbdb>0)
- {
- sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_RemindRecord WITH(NOLOCK) where F_Type= 1 and F_IsDelete = 0 and F_State = 0 and (Supervisor ='' or Supervisor is null )"+ value + ") and F_WorkState != '9'";
- }
- if(db>0)
- {
-
- if (!string .IsNullOrEmpty (dbusercode))
- {
- value += "and Supervisor='" + dbusercode + "'";
- }
- if (db==1)
- {
- sql += " and a.F_WorkOrderID in(select F_WorkOrderID from T_Bus_RemindRecord WITH(NOLOCK) where F_Type= 1 and F_IsDelete = 0 " + value + " and Supervisor !='' and Supervisor is not null )";
- }
- else if (db == 2)
- {
- sql += " and a.F_WorkOrderID in(select F_WorkOrderID from T_Bus_RemindRecord WITH(NOLOCK) where F_Type= 1 and F_State = 1 " + value + " )";
- }
- else if (db == 3)
- {
- sql += " and a.F_WorkOrderID in(select F_WorkOrderID from T_Bus_RemindRecord WITH(NOLOCK) where F_Type= 1 and F_State = 2 " + value + " ) ";
- }
- else if (db == 4)
- {
- sql += " and a.F_WorkOrderID in(select F_WorkOrderID from T_Bus_RemindRecord WITH(NOLOCK) where F_Type= 1 " + value + " ) and F_WorkState = '9'";
- }
- }
- if (!string .IsNullOrEmpty (mobile ))
- {
- sql += "and a.F_CusPhone = '" + mobile + "'";
- }
- if (area > 0)
- {
- sql += "and a.F_SourceArea='" + area + "'";
- }
- if (state>-1)
- {
- sql += "and a.F_WorkState='" + state + "'";
- }
- if (type > 0)
- {
- sql += "and a.F_InfoType='" + type + "'";
- }
- if (source > 0)
- {
- sql += "and a.F_InfoSource='" + source + "'";
- }
- if (isRelease>0)
- {
- if (isRelease==2)
- sql += " and (F_IsRelease =2 or F_IsRelease is null or F_IsRelease ='')";
- else
- sql += "and F_IsRelease ='"+ isRelease + "'";
- }
- if (ishf>0)
- {
-
- if (string.IsNullOrEmpty(strstarttime) && string.IsNullOrEmpty(strendtime))
- {
- value += " and datediff(MONTH ,a.F_CreateTime ,getdate())=0 ";
- }
- else
- {
- if (!string.IsNullOrEmpty(strstarttime))
- {
- value += "and datediff(SS ,F_CreateTime,'" + strstarttime + "')<=0 ";
- }
- }
- if (ishf==1)
- {
- sql += "and F_WorkOrderId in (select F_WorkOrderId from T_Bus_VisitResult WITH(NOLOCK) " +
- " where F_IsDelete =0 "+ value + " ) ";
-
- }
- else
- {
- sql += "and F_WorkOrderId not in (select F_WorkOrderId from T_Bus_VisitResult WITH(NOLOCK) " +
- "where F_IsDelete =0 " + value + " and F_IsSms !=1 ) ";
- }
- }
- if (handling>0)
- {
- if (deptid <= 0)
- return Error("请选择部门");
- if (string.IsNullOrEmpty(strstarttime) && string.IsNullOrEmpty(strendtime))
- {
- sql += " and datediff(MONTH ,a.F_CreateTime ,getdate())=0 ";
- }
- sql += "F_MainDeptId='" + deptid + "' and F_IsResult=0";
- switch (handling)
- {
- case 2:
- break;
- }
-
- }
- string cols = "";
- string order = "ORDER BY a.F_CreateTime DESC";
- if (name >0)
- {
- cols = "distinct F_CusName";
- order = "";
- }
- else if (db>0)
- {
- cols = " a.F_WorkOrderId,F_ComTitle,F_WorkState,F_MainDeptId,F_IsResult,a.F_CreateTime,dbo.GetUserName(a.F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName,dbo.GetDictionaryName(F_Key) KeyName,dbo.GetDeptNames(F_MainDeptId) as DeptName,F_CloseTime,F_LimitTime as LimitTime,F_ComContent,dbo.GetUserName((select top 1 Supervisor from T_Bus_RemindRecord where F_WorkOrderId=a.F_WorkOrderId order by F_Id desc)) as Supervisor";
- }
- else
- {
- cols = " a.F_WorkOrderId,F_ComTitle,F_WorkState,F_MainDeptId,F_IsResult,a.F_CreateTime,dbo.GetUserName(a.F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName,dbo.GetDictionaryName(F_Key) KeyName,dbo.GetDeptNames(F_MainDeptId) as DeptName,F_CloseTime,F_LimitTime as LimitTime,F_ComContent";
- }
- if (isdc > 0)
- {
- var top = " "; var orderby = " order by F_CreateTime desc";
- if (sql == " and F_IsDelete=0 ")
- {
- top = " top 1000 "; orderby += " desc ";
- }
- if (db == 1)
- {
- var dtdc = DbHelperSQL.Query(" select ROW_NUMBER() OVER(ORDER BY F_CreateTime desc) 编号, F_WorkOrderId 事项单号, dbo.GetDeptNames(F_MainDeptId ) 承办单位, "
- + "(case F_WorkState when 0 then '新工单' when 1 then '待交办' when 2 then '待查收' when 3 then '退回审核中' when 4 then '办理中' when 5 then '延时审核中' when 6 then '已办理' when 7 then '已审核' when 8 then '重办中' when 9 then '已完结' when 11 then '重办待交办' when 12 then '重办驳回' else '办理中' end) 督办情况,(case (select top 1 F_Mode from T_Bus_RemindRecord where F_WorkOrderId = a.F_WorkOrderId order by F_Id desc) when 0 then '现场' when 1 then '电话'else '未知' end ) 督办方式"
- + " from T_Bus_WorkOrder a WITH(NOLOCK) where 1=1 " + sql + order).Tables[0];
- var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
- if (msg == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- else
- {
- var dtdc = DbHelperSQL.Query(" select ROW_NUMBER() OVER(ORDER BY F_CreateTime desc) 序号,F_CreateTime 日期, F_WorkOrderId 工单号,F_ComTitle 诉求标题,F_ComContent 诉求内容,dbo.GetDictionaryName(F_Key) 反映类别, "
- + " dbo.GetDeptNames(F_MainDeptId ) 主办单位, "
- + " (select top 1 F_Result from T_Bus_Feedback WITH(NOLOCK) where F_State=1 and F_Type!=3 and F_IsDelete=0 and F_WorkOrderId =a.F_WorkOrderId order by F_Id desc) 办理结果, "
- + " F_CusName 来电人姓名 ,F_CusPhone 来电人手机号 "
- + " from T_Bus_WorkOrder a WITH(NOLOCK) where 1=1 " + sql + orderby).Tables[0];
- var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
- if (msg == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
-
- }
- else
- {
- int recordCount = 0;
- dt = BLL.PagerBLL.GetListPager(
- "T_Bus_WorkOrder a WITH(NOLOCK)",
- "a.F_WorkOrderId",
- cols,
- sql,
- order,
- pagesize,
- pageindex,
- true,
- out recordCount);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
-
- }
-
- public ActionResult IncomingCalls (string date,int isdc=0)
- {
- if (string.IsNullOrEmpty(date))
- date = DateTime.Now.ToString("yyyy-MM-dd");
- var modelcalllist = new BLL
- .T_Call_CallRecords().GetModelList(" CallType =0 and DATEDIFF(DAY, BeginTime, '"+ date + "') = 0");
- var userlist = new BLL.T_Sys_UserAccount().GetModelList(" F_SeatFlag =1");
- int ldcount = 0;int jtcount = 0; int newldcount = 0; int newjtcount = 0;
- List<Incoming> incomings = new List<Incoming>();
-
- //incoming.time = "00:00-08:00";
- //incoming.IncomingCount = modelcalllist.Where(x => x.BeginTime.Value.Hour >= 0 && x.BeginTime.Value.Hour <= 8
- //).Count();
- //ldcount += incoming.IncomingCount;
- //incoming.Oncapacity = modelcalllist.Where(x => x.BeginTime.Value.Hour >= 0 && x.BeginTime.Value.Hour <= 8
- //&&x.CallState ==1 ).Count();
- //jtcount += incoming.Oncapacity;
- //var modelcalllists = modelcalllist.Where(x => x.UserCode != null && x.UserCode != "" && x.BeginTime.Value.Hour >= 0 && x.BeginTime.Value.Hour <=8).Select(x => x.UserCode).Distinct
- // ();
-
- //if (modelcalllists!=null&& modelcalllists.Count() >0)
- //{
- // incoming.seatsCount = modelcalllists.Count();
- // foreach (var it in modelcalllists)
- // {
- // var user = userlist.Where(x => x.F_UserCode == it);
- // if (user != null && user.Count() > 0)
- // incoming.seats += "," + user.FirstOrDefault().F_UserName;
- // else
- // incoming.seats += "," + it;
- // }
- // if (!string .IsNullOrEmpty(incoming.seats))
- // incoming.seats = incoming.seats.TrimStart(',');
- //}
- //else
- //{
- // incoming.seatsCount =0;
- // incoming.seats = "";
- //}
- //incomings.Add(incoming);
- int v = 24;
- if (DateTime .Parse (date ).Year ==DateTime .Now .Year &&
- DateTime.Parse(date).Month == DateTime.Now.Month && DateTime.Parse(date).Day == DateTime.Now.Day)
- {
- v = DateTime.Now.Hour;
- }
- for (int i=0;i < v; i ++)
- {
- Incoming incomin = new Incoming();
- int t = i + 1;
- string iss=i.ToString () ,tss=t .ToString ();
- if (i < 10)
- iss = "0" + i;
- if (t < 10)
- tss = "0" + t;
- incomin.time = iss + ":00" + "-" + tss + ":00";
- incomin.IncomingCount = modelcalllist.Where(x => x.BeginTime.Value.Hour ==i &&x.PhoneType =="12345"
- ).Count();
- ldcount += incomin.IncomingCount;
- incomin.Oncapacity = modelcalllist.Where(x => x.BeginTime.Value.Hour ==i
- && x.CallState == 1 && x.PhoneType == "12345").Count();
- jtcount += incomin.Oncapacity;
- incomin.newIncomingCount = modelcalllist.Where(x => x.BeginTime.Value.Hour == i && x.PhoneType == "12345"
- ).Count();
- newldcount += incomin.newIncomingCount;
- incomin.newOncapacity = modelcalllist.Where(x => x.BeginTime.Value.Hour == i
- && x.CallState == 1 && x.PhoneType == "12345").Count();
- newjtcount += incomin.newOncapacity;
- var modelcalllistss = modelcalllist.Where(x => x.UserCode != null&& x.UserCode != "" && x.BeginTime.Value.Hour==i&&x.PhoneType =="12345").Select(x => x.UserCode).Distinct
- ();
- if (modelcalllistss != null && modelcalllistss.Count() > 0)
- {
- incomin.seatsCount = modelcalllistss.Count();
- foreach (var it in modelcalllistss)
- {
- var user = userlist.Where(x => x.F_UserCode == it);
- if (user != null && user.Count() > 0)
- incomin.seats += "," + user.FirstOrDefault().F_UserName;
- else
- incomin.seats += "," + it;
- }
- if (!string.IsNullOrEmpty(incomin.seats))
- incomin.seats= incomin.seats.TrimStart(',');
- }
- else
- {
- incomin.seatsCount = 0;
- incomin.seats = "";
- }
- var modelcalllists = modelcalllist.Where(x => x.UserCode != null && x.UserCode != "" && x.BeginTime.Value.Hour == i && x.PhoneType != "12345").Select(x => x.UserCode).Distinct
- ();
- if (modelcalllists != null && modelcalllists.Count() > 0)
- {
- incomin.newseatsCount = modelcalllists.Count();
- foreach (var it in modelcalllists)
- {
- var user = userlist.Where(x => x.F_UserCode == it);
- if (user != null && user.Count() > 0)
- incomin.newseats += "," + user.FirstOrDefault().F_UserName;
- else
- incomin.newseats += "," + it;
- }
- if (!string.IsNullOrEmpty(incomin.newseats))
- incomin.newseats = incomin.newseats.TrimStart(',');
- }
- else
- {
- incomin.newseatsCount = 0;
- incomin.newseats = "";
- }
- incomings.Add(incomin);
- }
- Incoming incomint = new Incoming();
-
- incomint.time = "共计";
- incomint.IncomingCount = ldcount;
- incomint.Oncapacity = jtcount;
- incomint.newIncomingCount = newldcount;
- incomint.newOncapacity = newjtcount;
- incomings.Add(incomint);
- if (isdc >0)
- {
- new NPOIHelper().IncomingCalls(incomings);
- return Success("导出excel");
- }
- return Success("获取成功", incomings);
- }
- /// <summary>
- /// 逾期未回复统计
- /// </summary>
- /// <param name="date"></param>
- /// <param name="deptId"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public ActionResult GetOutTimeNotApply(DateTime? start, DateTime? end, int deptId = -1, int pageIndex = 1, int pageSize = 10, bool isExport = false)
- {
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- var where = "";
- if (deptId > 0)
- {
- where = " AND F_MainDeptId=" + deptId;
- }
- string sql = $" and datediff(day,F_CreateTime,'{start.Value.ToString("yyyy-MM-dd")}')<=0 and datediff(day,F_CreateTime,'{end.Value.ToString("yyyy-MM-dd")}')>=0 "+ where;
-
- if (isExport)
- {
- string[] cols = new string[] { "工单编号", "承办单位", "工单内容", "转派时间", "回复时限", "超时时间" };
- var dtall = DbHelperSQL.Query("select * from V_Bus_OverNoBack where 1=1 "+sql).Tables[0];
- dtall.Columns.Remove("F_MainDeptId");
- dtall.Columns.Remove("F_CreateTime");
- new NPOIHelper().ExportToExcel($"逾期未回复统计报表{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", dtall, cols);
- return Success("导出excel");
- }
- int recordCount = 0;
- var dt = BLL.PagerBLL.GetListPager(
- "V_Bus_OverNoBack",
- "F_WorkOrderId",
- "*",
- sql,
- "ORDER BY F_CreateTime DESC",
- pageSize,
- pageIndex,
- true,
- out recordCount);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
-
- /// <summary>
- /// 重办不满意统计
- /// </summary>
- /// <param name="date"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public ActionResult GetNotSatisfied(DateTime? start, DateTime? end, int pageIndex = 1, int pageSize = 10, bool isExport = false)
- {
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- string sql = $" and datediff(day,cjTime,'{start.Value.ToString("yyyy-MM-dd")}')<=0 and datediff(day,cjTime,'{end.Value.ToString("yyyy-MM-dd")}')>=0 ";
- if (isExport)
- {
- string[] cols = new string[] { "工单编号", "承办单位", "工单内容", "创建时间", "处理结果", "处理时间", "回访结果", "回访时间" };
- var dtall = DbHelperSQL.Query("select * from V_Bus_ReloadNoSatisfie where 1=1 " + sql + " order by cjTime DESC ").Tables[0];
- dtall.Columns.Remove("F_Id");
- new NPOIHelper().ExportToExcel($"重办不满意统计报表{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", dtall, cols);
- return Success("导出excel");
- }
- int recordCount = 0;
- var dt = BLL.PagerBLL.GetListPager(
- "V_Bus_ReloadNoSatisfie",
- "F_Id",
- "*",
- sql,
- "ORDER BY cjTime DESC",
- pageSize,
- pageIndex,
- true,
- out recordCount);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
-
- /// <summary>
- /// 延期统计
- /// </summary>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <param name="isExport"></param>
- /// <returns></returns>
- public ActionResult GetDelay(DateTime? start, DateTime? end, bool isExport = false)
- {
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
- paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
- var obj = DbHelperSQL.RunProcedure("P_DeptDelayReport", paras, "DeptDelayReport");
- if (isExport)
- {
- string[] cols = new string[] { "单位名称", "办理数量", "延时数量", "延时率" };
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("延时分析统计报表", obj.Tables[0], cols) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- return Success("成功", obj);
- }
- /// <summary>
- /// 通报批评
- /// </summary>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <param name="isExport"></param>
- /// <returns></returns>
- public ActionResult GetNotice(DateTime? start, DateTime? end, bool isExport = false)
- {
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- //string sql = "select * from dbo.GetNoticeReport('"+ start.Value.ToString("yyyy-MM-dd") + "','" + end.Value.ToString("yyyy-MM-dd") + "') ORDER BY zbcount+xbcount DESC";
- //var dt = DbHelperSQL.Query(sql).Tables[0];
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
- paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
- var obj = DbHelperSQL.RunProcedure("P_DeptNoticeReport", paras, "DeptNoticeReport");
- if (isExport)
- {
- var cols = new string[] { "承办单位", "主办受理数量", "主办通报批评数量", "主办通报批评率", "协办受理数量", "协办通报批评数量", "协办通报批评率" };
- new NPOIHelper().ExportToExcel($"通报批评{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
- return Success("导出excel");
- }
- return Success("成功", obj);
- }
-
- /// <summary>
- /// 诉求受理对比
- /// </summary>
- /// <returns></returns>
- public ActionResult GetAppeal1(DateTime? start, DateTime? end, bool isExport = false)
- {
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
- paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
- var obj = DbHelperSQL.RunProcedure("P_UserAppealReport", paras, "UserAppealReport");
- if (isExport)
- {
- var cols = new string[] { "坐席名称", "受理数量", "上月同期受理数量", "上月同期环比", "去年同期受理数量", "去年同期同比" };
- new NPOIHelper().ExportToExcel($"诉求受理对比{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
- return Success("导出excel");
- }
- return Success("成功", obj);
- }
- public ActionResult GetAppeal(DateTime? start, DateTime? end, bool isExport = false
- , string source = "")
- {
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
- paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
- paras.Add("@source", source);
- var obj = DbHelperSQL.RunProcedure("P_UserAppealReport_1", paras, "UserAppealReport");
- var newSet = new DataSet();var newtable = new DataTable("UserAppealReport");
- #region
- newtable.Columns.Add(new DataColumn("username"));
- newtable.Columns.Add(new DataColumn("count", typeof(int)));
- newtable.Columns.Add(new DataColumn("mcount", typeof(int)));
- newtable.Columns.Add(new DataColumn("mom"));
- newtable.Columns.Add(new DataColumn("ycount", typeof(int)));
- newtable.Columns.Add(new DataColumn("yoy"));
- #endregion
- if (obj != null && obj.Tables[0] != null && obj.Tables[0].Rows.Count > 0)
- {
-
- for (int i = 0; i < obj.Tables[0].Rows.Count; i++)
- {
- int count = 0, mcount = 0, ycount = 0; double mom = 0, yoy = 0;
- int.TryParse(obj.Tables[0].Rows[i]["count"].ToString(), out count);
- int.TryParse(obj.Tables[0].Rows[i]["mcount"].ToString(), out mcount);
- int.TryParse(obj.Tables[0].Rows[i]["ycount"].ToString(), out ycount);
-
- if(mcount>0)
- mom = double.Parse((count * 100).ToString()) / mcount;
- if (ycount > 0)
- yoy = double.Parse((count * 100).ToString()) / ycount;
- #region
- DataRow drNew = newtable.NewRow();
- drNew["username"] = obj.Tables[0].Rows[i]["username"];
- drNew["count"] = count;
- drNew["mcount"] = mcount;
- drNew["mom"] = mom > 0 ? mom.ToString("f") + "%" : "0";
- drNew["ycount"] = ycount;
- drNew["yoy"] = yoy > 0 ? yoy.ToString("f") + "%" : "0";
- newtable.Rows.Add(drNew);
- #endregion
- }
- newtable.DefaultView.Sort = "count desc";
- newSet.Tables.Add(newtable.DefaultView.ToTable());
- }
- if (isExport)
- {
- var cols = new string[] { "坐席名称", "受理数量", "上月同期受理数量", "上月同期环比", "去年同期受理数量", "去年同期同比" };
- new NPOIHelper().ExportToExcel($"诉求受理对比{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", newSet.Tables[0], cols);
- return Success("导出excel");
- }
- return Success("成功", newSet);
- }
- /// <summary>
- /// 获取督办报表
- /// </summary>
- /// <returns></returns>
- public ActionResult GetDBReportform(string starttime,string endtime)
- {
-
- if (string .IsNullOrEmpty (starttime))
- {
- starttime = DateTime.Now.ToString("yyyy-MM") + "-01 00:00:00";
- endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- }
- else
- {
- if (string.IsNullOrEmpty(endtime))
- {
- endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- }
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", starttime);
- paras.Add("@edate", endtime);
- var obj1 = DbHelperSQL.RunProcedure("P_DBReportform_1", paras, "DBReportform").Tables[0];
- string sqlarea = " select COUNT(1) from T_Bus_WorkOrder where F_WorkOrderID in(select F_WorkOrderID from T_Bus_RemindRecord WITH(NOLOCK) where F_Type=1 and F_IsDelete=0 and F_State =0 and (Supervisor ='' or Supervisor is null and F_CreateTime between '" + starttime +
- "' AND '" + endtime + "')) and F_WorkState !='9'and F_IsDelete =0 ";
- DataTable dttype = DbHelperSQL.Query(sqlarea).Tables[0];
- var obj = new
- {
- obj1,
- total = dttype
- };
-
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 坐席状态统计
- /// </summary>
- /// <param name="starttime"></param>
- /// <param name="endtime"></param>
- /// <returns></returns>
- public ActionResult GetZuoXiState(string starttime, string endtime)
- {
- if (string.IsNullOrEmpty(starttime))
- {
- starttime = DateTime.Now.ToString("yyyy-MM") + "-01 00:00:00";
- endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- }
- else
- {
- if (string.IsNullOrEmpty(endtime))
- {
- endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- }
- }
- string sql = " a.OccurTime between '" + starttime + "' AND '" + endtime + "'";
- string value = " TimeLogin between '" + starttime + "' AND '" + endtime + "'";
- string value1 = " TimeLogout between '" + starttime + "' AND '" + endtime + "'";
- string sqlarea = " select a.AgentId ,dbo.GetUserName(a.AgentId) as UserName,(select COUNT(1) from rep_agent_detail where "+ value + " and AgentId = a.AgentId and 1" +
- " is not null ) as 签入 ,(select COUNT(1) from rep_agent_detail where "+ value1 + " and AgentId = a.AgentId and TimeLogout is not null ) as 签出,SUM(case State when 5 then 1 else 0 end) as 置忙 ,SUM(case State when 2 then 1 else 0 end) as 置闲 from dbo.rep_agent_state a where "+ sql + " group by AgentId ";
- DataTable obj = DbHelperSQL.Query(sqlarea).Tables[0];
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 坐席时间
- /// </summary>
- /// <param name="starttime"></param>
- /// <param name="endtime"></param>
- /// <returns></returns>
- public ActionResult GetZuoXiTime (string starttime, string endtime,string usercode,int state=0)
- {
- if (string.IsNullOrEmpty(starttime))
- {
- starttime = DateTime.Now.ToString("yyyy-MM") + "-01 00:00:00";
- endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- }
- else
- {
- if (string.IsNullOrEmpty(endtime))
- {
- endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- }
- }
- if (string.IsNullOrEmpty(usercode))
- return Error("请选择坐席");
- string sqlzuoxi = "";
- if (state==0)
- {
- sqlzuoxi = "select TimeLogin from rep_agent_detail where TimeLogin between '" + starttime + "' AND '" + endtime + "' and AgentId ='" + usercode + "'and TimeLogin is not null ";
- }
- else if (state == 1)
- {
- sqlzuoxi = "select TimeLogout from rep_agent_detail where TimeLogout between '" + starttime + "' AND '" + endtime + "' and AgentId ='" + usercode + "' and TimeLogout is not null ";
- }
- else if (state == 2)
- {
- sqlzuoxi = "select OccurTime from rep_agent_state where OccurTime between '" + starttime + "' AND '" + endtime + "' and AgentId ='" + usercode + "' and State = 2 ";
- }
- else if (state == 3)
- {
- sqlzuoxi = "select OccurTime from rep_agent_state where OccurTime between '" + starttime + "' AND '" + endtime + "' and AgentId ='" + usercode + "' and State = 5 ";
- }
- DataTable obj = DbHelperSQL.Query(sqlzuoxi).Tables[0];
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 获取绩效
- /// </summary>
- /// <param name="date"></param>
- /// <param name="isdc"></param>
- /// <returns></returns>
- public ActionResult GetEvaluation(string date, int deptid = 0,int isdc=0)
- {
- string sql = "F_IsDelete=0";
- string message = "";string datemessage = "";
- if (!string.IsNullOrEmpty(date))
- {
- message = "统计周期:" + DateTime.Parse(date).AddMonths(-1).ToString("yyyy年MM月") + "-25日--" + DateTime.Parse(date).ToString("yyyy年MM月") + "-24日";
- datemessage = MonthtoUpper(DateTime.Parse(date).Month );
- date = DateTime.Parse(date).ToString("yyyyMM");
-
- }
- else
- {
- message = "统计周期:" + DateTime.Now.AddMonths(-1).ToString("yyyy年MM月") + "-25日--" + DateTime.Now.ToString("yyyy年MM月") + "-24日";
- date = DateTime .Now.AddMonths (-1).ToString("yyyyMM");
- datemessage = MonthtoUpper(DateTime.Now .Month);
- }
-
- sql += "and F_Date='" + date + "'";
- if (deptid>0)
- {
- sql += "and F_Deptid='" + deptid + "'";
- }
- if (isdc>0)
- {
-
- var dtdc = DbHelperSQL.Query(" select * from T_Sys_Evaluation a WITH(NOLOCK) where " + sql+ " " +
- " and F_Undertake>0 and F_Deptid in (select F_DeptId from T_Sys_Department " +
- "where F_DeptId in (SELECT F_DeptId FROM dbo.[GetDaptiD](155) where F_IsDept = 1) " +
- "and F_PartentId =155 and F_IsDealDept = 1 and F_DeptName not like '%测试%') order by F_Total desc").Tables[0];
- var dtdc1 = DbHelperSQL.Query(" select * from T_Sys_Evaluation a WITH(NOLOCK) where " + sql + " " +
- "and F_Undertake>0 and F_Deptid in (select F_DeptId from T_Sys_Department " +
- "where F_DeptId in (SELECT F_DeptId FROM dbo.[GetDaptiD](155) where F_IsDept = 1) " +
- "and F_PartentId in(167, 169,170) and F_IsDealDept = 1 and F_DeptName not like '%测试%') order by F_Total desc").Tables[0];
- var dtdc2 = DbHelperSQL.Query(" select * from T_Sys_Evaluation a WITH(NOLOCK) where " + sql + " " +
- " and F_Undertake>0 and F_Deptid in (select F_DeptId from T_Sys_Department " +
- "where F_DeptId in (SELECT F_DeptId FROM dbo.[GetDaptiD](155) where F_IsDept = 1) " +
- "and F_PartentId in(171, 172) and F_IsDealDept = 1 and F_DeptName not like '%测试%') order by F_Total desc").Tables[0];
- var dtdc3 = DbHelperSQL.Query(" select * from T_Sys_Evaluation a WITH(NOLOCK) where " + sql + " " +
- " and F_Undertake=0 order by F_Total desc").Tables[0];
- var msg = new NPOIHelper().ExportEvaluation ( dtdc, dtdc1, dtdc2, dtdc3, message, datemessage);
- if (msg == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- else
- {
- string Evaluation = "select * from T_Sys_Evaluation where " + sql + "order by F_Total desc ";
- DataTable obj = DbHelperSQL.Query(Evaluation).Tables[0];
- return Content(obj.ToJson());
- }
-
- }
- private static string MonthtoUpper(int month)
- {
- if (month < 10)
- {
- return NumtoUpper(month) ;
- }
- else
- if (month == 10) { return "十" ; }
- else
- {
- return "十" + NumtoUpper(month - 10) ;
- }
- }
- private static string NumtoUpper(int num)
- {
- String str = num.ToString();
- string rstr = "";
- int n;
- for (int i = 0; i < str.Length; i++)
- {
- n = Convert.ToInt16(str[i].ToString());//char转数字,转换为字符串,再转数字
- switch (n)
- {
- case 0: rstr = rstr + "〇"; break;
- case 1: rstr = rstr + "一"; break;
- case 2: rstr = rstr + "二"; break;
- case 3: rstr = rstr + "三"; break;
- case 4: rstr = rstr + "四"; break;
- case 5: rstr = rstr + "五"; break;
- case 6: rstr = rstr + "六"; break;
- case 7: rstr = rstr + "七"; break;
- case 8: rstr = rstr + "八"; break;
- default: rstr = rstr + "九"; break;
- }
- }
- return rstr;
- }
- /// <summary>
- /// 获取绩效
- /// </summary>
- /// <param name="date"></param>
- /// <param name="isdc"></param>
- /// <returns></returns>
- public ActionResult GetDeptDeptAchievements(string starttime, string endtime
- , int type=0,int deptid=0)
- {
- if (string.IsNullOrEmpty(starttime))
- {
- starttime = DateTime.Now.AddMonths (-1).ToString("yyyy-MM") + "-21 00:00:00";
- endtime = DateTime.Now.ToString("yyyy-MM") + "-20 00:00:00";
- }
- else
- {
- if (string.IsNullOrEmpty(endtime))
- {
- endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- }
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", starttime);
- paras.Add("@edate", endtime);
- paras.Add("@type", type.ToString ());
- if (deptid>0)
- paras.Add("@deptid", deptid.ToString ());
- else
- paras.Add("@deptid","");
- var obj = DbHelperSQL.RunProcedure("P_DeptAchievements_1", paras, "DeptAchievements").Tables[0]; ;
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 工单周报
- /// 暂时无用,多主办单位不处理
- /// </summary>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <param name="type"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public ActionResult GetWeaklyReport(DateTime? start, DateTime? end, int type = 0, int dateType = 0, int pageIndex = 1, int pageSize = 10, bool isExport = false)
- {
- StringBuilder sb1 = new StringBuilder();
- StringBuilder sb2 = new StringBuilder();
- StringBuilder sb3 = new StringBuilder();
- var startDate = new DateTime();
- var endDate = new DateTime();
- var lastStartDate = new DateTime();
- var lastEndDate = new DateTime();
- var differ = 0;
- var str = "";
- switch (dateType)
- {
- //日
- case 1:
- if (start == null)
- {
- start = DateTime.Now.Date;
- }
- if (end == null)
- {
- end = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
- }
- startDate = Convert.ToDateTime(start);
- endDate = Convert.ToDateTime(end).AddDays(1).AddSeconds(-1);
- differ = (endDate - startDate).Days + 1;
- lastStartDate = startDate.AddDays(-differ);
- lastEndDate = endDate.AddDays(-differ);
- str = "日";
- break;
- //周
- case 2:
- if (start == null)
- {
- start = DateTime.Now.Date;
- }
- if (end == null)
- {
- end = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
- }
- startDate = Convert.ToDateTime(start);
- endDate = Convert.ToDateTime(end);
- differ = 7 - (int)startDate.DayOfWeek;
- startDate = DateTools.GetWeekFirstDayMon((DateTime)start);
- endDate = DateTools.GetWeekLastDaySun((DateTime)end).AddDays(1).AddSeconds(-1);
- differ = (endDate - startDate).Days + 1;
- lastStartDate = DateTools.GetWeekFirstDayMon(startDate.AddDays(-1));
- lastEndDate = DateTools.GetWeekLastDaySun(lastStartDate).AddDays(1).AddSeconds(-1);
- str = "周";
- break;
- //月
- case 3:
- if (start == null)
- {
- start = DateTime.Now.Date;
- }
- if (end == null)
- {
- end = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
- }
- startDate = Convert.ToDateTime(start);
- endDate = Convert.ToDateTime(end);
- differ = startDate.Day;
- startDate = startDate.AddDays(-differ + 1);
- endDate = endDate.AddDays(DateTime.DaysInMonth(startDate.Year, startDate.Month) - differ).AddDays(1).AddSeconds(-1);
- //differ = (endDate - startDate). + 1;
- lastStartDate = startDate.AddMonths(-1);
- lastEndDate = lastStartDate.AddDays(DateTime.DaysInMonth(lastStartDate.Year, lastStartDate.Month) - 1).AddDays(1).AddSeconds(-1);
- str = "月";
- break;
- default:
- break;
- }
- //type 查询类型 type=1 按区域;type=2 按部门; type=3 按工单类型
- switch (type)
- {
- case 1:
- var areaList = areaBLL.DataTableToList(areaBLL.GetList(" F_State=0 ").Tables[0]);
- var areaList1 = new BLL.T_Bus_WorkOrderReport().DataTableToAreaList(DbHelperSQL.Query($"SELECT A.F_WorkOrderId,A.F_WorkState,A.F_SourceArea,B.F_AreaName, row_number() over(partition by B.F_AreaId order by A.F_Id desc) FROM T_Bus_WorkOrder A LEFT JOIN T_Sys_Area B ON A.F_SourceArea = B.F_AreaId WHERE datediff(s, '{startDate}', A.F_CreateTime) > 0 and datediff(s, '{endDate}', A.F_CreateTime) < 0 and A.F_IsDelete = 0 AND A.F_WorkOrderId IS NOT NULL AND A.F_SourceArea > 0").Tables[0]);
- var areaList2 = new BLL.T_Bus_WorkOrderReport().DataTableToAreaList(DbHelperSQL.Query($"SELECT A.F_WorkOrderId,A.F_WorkState,A.F_SourceArea,B.F_AreaName, row_number() over(partition by B.F_AreaId order by A.F_Id desc) FROM T_Bus_WorkOrder A LEFT JOIN T_Sys_Area B ON A.F_SourceArea = B.F_AreaId WHERE datediff(s, '{lastStartDate}', A.F_CreateTime) > 0 and datediff(s, '{lastEndDate}', A.F_CreateTime) < 0 and A.F_IsDelete = 0 AND A.F_WorkOrderId IS NOT NULL AND A.F_SourceArea > 0").Tables[0]);
- List<DeptWeaklyReportDto> areaWeaklyReportDtoList = new List<DeptWeaklyReportDto>();
- areaList.ForEach(x =>
- {
- var query = areaList1.Where(y => x.F_AreaId == y.FieldId).ToList();
- var assignedCount = query.Count();
- var lastAssignedcount = areaList2.Where(y => x.F_AreaId == y.FieldId).Count();
- var countRate = lastAssignedcount == 0 ? "0%" : assignedCount == 0 ? "0%" : ((double)assignedCount / lastAssignedcount * 100).ToString("f2") + "%";
- var completedCount = query.Where(y => y.WorkOrderState == 9).Count();
- var completedRate = assignedCount == 0 ? "0%" : completedCount == 0 ? "0%" : ((double)completedCount / assignedCount * 100).ToString("f2") + "%";
- areaWeaklyReportDtoList.Add(new DeptWeaklyReportDto
- {
- name = x.F_AreaName,
- assignedcount = assignedCount,
- countrate = countRate,
- completedcount = completedCount,
- completedrate = completedRate
- });
- });
- if (isExport)
- {
- var dt = areaWeaklyReportDtoList.ToDataTable(new string[] { "name", "assignedcount", "countrate", "completedcount", "completedrate" });
- new NPOIHelper().ExportToExcel($"按区域{str}报表{Convert.ToDateTime(startDate).ToString("yyyyMMdd")}-{Convert.ToDateTime(endDate).ToString("yyyyMMdd")}", dt, new string[] { "区域", "受理数量", "数量同比", "办结数量", "办结率" });
- return Success("导出excel");
- }
- return Content(new
- {
- rows = areaWeaklyReportDtoList.Skip((pageIndex - 1) * pageSize).Take(pageSize),
- total = areaWeaklyReportDtoList.Count
- }.ToJson());
- case 2:
- var deptList = departmentBLL.DataTableToList(departmentBLL.GetList(" F_State=0 AND F_DeptNameSpell=3 ").Tables[0]);
- var deptList1 = new BLL.T_Bus_WorkOrderReport().DataTableToDeptList1(DbHelperSQL.Query($"SELECT A.F_WorkOrderId,A.F_WorkState,B.F_MainDeptId,C.F_DeptName , row_number() over(partition by B.F_MainDeptId order by A.F_Id desc)FROM T_Bus_WorkOrder A LEFT JOIN T_Bus_AssignedInfo B ON A.F_WorkOrderId=B.F_WorkOrderId LEFT JOIN T_Sys_Department C ON B.F_MainDeptId=C.F_DeptId AND C.F_DeptNameSpell=3 WHERE datediff(s,'{startDate}',A.F_CreateTime)>0 and datediff(s,'{endDate}',A.F_CreateTime)<0 and A.F_IsDelete=0 AND A.F_WorkOrderId IS NOT NULL AND B.F_IsDelete=0 and B.F_IsSure in (0,1,2) and B.F_State in (0,1)").Tables[0]).DistinctBy(x => x.WorkOrderId).ToList();//DataTableToDeptList
- var deptList2 = new BLL.T_Bus_WorkOrderReport().DataTableToDeptList1(DbHelperSQL.Query($"SELECT A.F_WorkOrderId,A.F_WorkState,B.F_MainDeptId,C.F_DeptName , row_number() over(partition by B.F_MainDeptId order by A.F_Id desc)FROM T_Bus_WorkOrder A LEFT JOIN T_Bus_AssignedInfo B ON A.F_WorkOrderId=B.F_WorkOrderId LEFT JOIN T_Sys_Department C ON B.F_MainDeptId=C.F_DeptId AND C.F_DeptNameSpell=3 WHERE datediff(s,'{lastStartDate}',A.F_CreateTime)>0 and datediff(s,'{lastEndDate}',A.F_CreateTime)<0 and A.F_IsDelete=0 AND A.F_WorkOrderId IS NOT NULL AND B.F_IsDelete=0 and B.F_IsSure in (0,1,2) and B.F_State in (0,1)").Tables[0]).DistinctBy(x => x.WorkOrderId).ToList();//DataTableToDeptList
- List<DeptWeaklyReportDto> deptWeaklyReportDtoList = new List<DeptWeaklyReportDto>();
- deptList.ForEach(x =>
- {
- var query = deptList1.Where(y => y.FieldId!=null && y.FieldId.Split(',').Contains(x.F_DeptId.ToString())).ToList();
- //var query = deptList1.Where(y => y.FieldId == x.F_DeptId).ToList();
- var assignedCount = query.Count();
- var lastAssignedcount = deptList2.Where(y => y.FieldId != null && y.FieldId.Split(',').Contains(x.F_DeptId.ToString())).Count();
- //var lastAssignedcount = deptList2.Where(y => y.FieldId == x.F_DeptId).Count();
- var countRate = lastAssignedcount == 0 ? "0%" : assignedCount == 0 ? "0%" : ((double)assignedCount / lastAssignedcount * 100).ToString("f2") + "%";
- var completedCount = query.Where(y => y.WorkOrderState == 9).Count();
- var completedRate = assignedCount == 0 ? "0%" : completedCount == 0 ? "0%" : ((double)completedCount / assignedCount * 100).ToString("f2") + "%";
- deptWeaklyReportDtoList.Add(new DeptWeaklyReportDto
- {
- name = x.F_DeptName,
- assignedcount = assignedCount,
- countrate = countRate,
- completedcount = completedCount,
- completedrate = completedRate
- });
- });
- if (isExport)
- {
- var dt = deptWeaklyReportDtoList.ToDataTable(new string[] { "name", "assignedcount", "countrate", "completedcount", "completedrate" });
- new NPOIHelper().ExportToExcel($"按单位{str}报表{Convert.ToDateTime(startDate).ToString("yyyyMMdd")}-{Convert.ToDateTime(endDate).ToString("yyyyMMdd")}", dt, new string[] { "单位", "受理数量", "数量同比", "办结数量", "办结率" });
- return Success("导出excel");
- }
- return Content(new
- {
- rows = deptWeaklyReportDtoList.Skip((pageIndex - 1) * pageSize).Take(pageSize),
- total = deptWeaklyReportDtoList.Count
- }.ToJson());
- case 3:
- var typeList = dictValueBLL.DataTableToList(dictValueBLL.GetList(" F_State=0 and F_ItemId=2 ").Tables[0]);
- var typeList1 = new BLL.T_Bus_WorkOrderReport().DataTableToTypeList(DbHelperSQL.Query($"SELECT A.F_WorkOrderId,A.F_WorkState,A.F_InfoType,B.F_Value , row_number() over(partition by A.F_InfoType order by A.F_Id desc) FROM T_Bus_WorkOrder A LEFT JOIN T_Sys_DictionaryValue B ON A.F_InfoType=B.F_ValueId WHERE datediff(s,'{startDate}',A.F_CreateTime)>0 and datediff(s,'{endDate}',A.F_CreateTime)<0 and A.F_IsDelete=0 AND A.F_WorkOrderId IS NOT NULL AND B.F_State=0 and B.F_ItemId=2 ").Tables[0]);
- var typeList2 = new BLL.T_Bus_WorkOrderReport().DataTableToTypeList(DbHelperSQL.Query($"SELECT A.F_WorkOrderId,A.F_WorkState,A.F_InfoType,B.F_Value , row_number() over(partition by A.F_InfoType order by A.F_Id desc) FROM T_Bus_WorkOrder A LEFT JOIN T_Sys_DictionaryValue B ON A.F_InfoType=B.F_ValueId WHERE datediff(s,'{lastStartDate}',A.F_CreateTime)>0 and datediff(s,'{lastEndDate}',A.F_CreateTime)<0 and A.F_IsDelete=0 AND A.F_WorkOrderId IS NOT NULL AND B.F_State=0 and B.F_ItemId=2 ").Tables[0]);
- List<DeptWeaklyReportDto> typeWeaklyReportDtoList = new List<DeptWeaklyReportDto>();
- typeList.ForEach(x =>
- {
- var query = typeList1.Where(y => y.FieldId == x.F_ValueId);
- var assignedCount = query.Count();
- var lastAssignedcount = typeList2.Where(y => y.FieldId == x.F_ValueId).Count();
- var countRate = lastAssignedcount == 0 ? "0%" : assignedCount == 0 ? "0%" : ((double)assignedCount / lastAssignedcount * 100).ToString("f2") + "%";
- var completedCount = query.Where(y => y.WorkOrderState == 9).Count();
- var completedRate = assignedCount == 0 ? "0%" : completedCount == 0 ? "0%" : ((double)completedCount / assignedCount * 100).ToString("f2") + "%";
- typeWeaklyReportDtoList.Add(new DeptWeaklyReportDto
- {
- name = x.F_Value,
- assignedcount = assignedCount,
- countrate = countRate,
- completedcount = completedCount,
- completedrate = completedRate
- });
- });
- if (isExport)
- {
- var dt = typeWeaklyReportDtoList.ToDataTable(new string[] { "name", "assignedcount", "countrate", "completedcount", "completedrate" });
- new NPOIHelper().ExportToExcel($"按工单类型{str}报表{Convert.ToDateTime(startDate).ToString("yyyyMMdd")}-{Convert.ToDateTime(endDate).ToString("yyyyMMdd")}", dt, new string[] { "工单类型", "受理数量", "数量同比", "办结数量", "办结率" });
- return Success("导出excel");
- }
- return Content(new
- {
- rows = typeWeaklyReportDtoList.Skip((pageIndex - 1) * pageSize).Take(pageSize),
- total = typeWeaklyReportDtoList.Count
- }.ToJson());
- case 4:
- var sourceList = dictValueBLL.DataTableToList(dictValueBLL.GetList(" F_State = 0 and F_ItemId = 1").Tables[0]);
- var sourceList1 = new BLL.T_Bus_WorkOrderReport().DataTableToSourceList(DbHelperSQL.Query($"SELECT A.F_WorkOrderId,A.F_WorkState,A.F_InfoSource,B.F_Value , row_number() over(partition by A.F_InfoSource order by A.F_Id desc) FROM T_Bus_WorkOrder A LEFT JOIN T_Sys_DictionaryValue B ON A.F_InfoSource = B.F_ValueId WHERE datediff(s, '{startDate}', A.F_CreateTime) > 0 and datediff(s, '{endDate}', A.F_CreateTime) < 0 and A.F_IsDelete = 0 AND A.F_WorkOrderId IS NOT NULL AND B.F_State = 0 and B.F_ItemId = 1").Tables[0]);
- var sourceList2 = new BLL.T_Bus_WorkOrderReport().DataTableToSourceList(DbHelperSQL.Query($"SELECT A.F_WorkOrderId,A.F_WorkState,A.F_InfoSource,B.F_Value , row_number() over(partition by A.F_InfoSource order by A.F_Id desc) FROM T_Bus_WorkOrder A LEFT JOIN T_Sys_DictionaryValue B ON A.F_InfoSource = B.F_ValueId WHERE datediff(s, '{lastStartDate}', A.F_CreateTime) > 0 and datediff(s, '{lastEndDate}', A.F_CreateTime) < 0 and A.F_IsDelete = 0 AND A.F_WorkOrderId IS NOT NULL AND B.F_State = 0 and B.F_ItemId = 1").Tables[0]);
- List<DeptWeaklyReportDto> sourceWeaklyReportDtoList = new List<DeptWeaklyReportDto>();
- sourceList.ForEach(x =>
- {
- var query = sourceList1.Where(y => y.FieldId == x.F_ValueId).ToList();
- var assignedCount = query.Count();
- var lastAssignedcount = sourceList2.Where(y => y.FieldId == x.F_ValueId).Count();
- var countRate = lastAssignedcount == 0 ? "0%" : assignedCount == 0 ? "0%" : ((double)assignedCount / lastAssignedcount * 100).ToString("f2") + "%";
- var completedCount = query.Where(y => y.WorkOrderState == 9).Count();
- var completedRate = assignedCount == 0 ? "0%" : completedCount == 0 ? "0%" : ((double)completedCount / assignedCount * 100).ToString("f2") + "%";
- sourceWeaklyReportDtoList.Add(new DeptWeaklyReportDto
- {
- name = x.F_Value,
- assignedcount = assignedCount,
- countrate = countRate,
- completedcount = completedCount,
- completedrate = completedRate
- });
- });
- if (isExport)
- {
- var dt = sourceWeaklyReportDtoList.ToDataTable(new string[] { "name", "assignedcount", "countrate", "completedcount", "completedrate" });
- new NPOIHelper().ExportToExcel($"按工单来源{str}报表{Convert.ToDateTime(startDate).ToString("yyyyMMdd")}-{Convert.ToDateTime(endDate).ToString("yyyyMMdd")}", dt, new string[] { "工单来源", "受理数量", "数量同比", "办结数量", "办结率" });
- return Success("导出excel");
- }
- return Content(new
- {
- rows = sourceWeaklyReportDtoList.Skip((pageIndex - 1) * pageSize).Take(pageSize),
- total = sourceWeaklyReportDtoList.Count
- }.ToJson());
- default:
- return Error("参数错误");
- }
- }
- /// <summary>
- /// 工单日周月报
- /// </summary>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <param name="type"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public ActionResult GetDayWeekMonthReport(DateTime? date, int type = 0, int dateType = 0, bool isExport = false,string source="")
- {
- if (date == null)
- {
- date = DateTime.Now.Date;
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@date", date.Value.ToString("yyyy-MM-dd"));
- paras.Add("@datatype", type.ToString());
- paras.Add("@datetype", dateType.ToString());
- paras.Add("@source", source);
- var obj = DbHelperSQL.RunProcedure("P_DayWeekMonthReport", paras, "DayWeekMonthReport");
- if (isExport)
- {
- var cols = new string[] { "名称", "受理数量", "数量同比", "结案数量", "结案率" };
- var start = obj.Tables[1].Rows[0]["startdate"].ToString();
- var end = obj.Tables[1].Rows[0]["enddate"].ToString();
- new NPOIHelper().ExportToExcel($"工单报表{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
- return Success("导出excel");
- }
- return Success("成功", obj);
- }
- /// <summary>
- /// 电话中心受话情况统计表
- /// </summary>
- /// <param name="starttime/"></param>
- /// <param name="endtime"></param>
- /// <param name="usercode"></param>
- /// <param name="group"></param>
- /// <param name="isExport"></param>
- /// <returns></returns>
- public ActionResult CenterReception(DateTime? starttime, DateTime? endtime,string usercode="",string group="",
- bool isExport = false)
- {
- DateTime date = DateTime.Now;
- if (starttime == null)
- {
- starttime = new DateTime(date.Year, date.Month, 1);
- }
- if (endtime == null)
- {
- endtime = DateTime.Now;
- }
-
-
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", starttime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- paras.Add("@edate", endtime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- paras.Add("@usercode", usercode);
- paras.Add("@group", group);
- var obj = DbHelperSQL.RunProcedure("P_CenterReception", paras, "CenterReception");
- if (isExport)
- {
- string message = new NPOIHelper().CenterReception(obj);
- if (message == "")
- return Success("导出excel");
- else
- return Error(message);
- }
- return Success("成功", obj);
- }
- /// <summary>
- /// 局委办件统计
- /// </summary>
- /// <param name="starttime"></param>
- /// <param name="endtime"></param>
- /// <param name="deptid"></param>
- /// <param name="source"></param>
- /// <param name="isExport"></param>
- /// <returns></returns>
- public ActionResult BureauHandling(DateTime? starttime, DateTime? endtime,int deptid =0, int source=0, bool isExport = false)
- {
- DateTime date = DateTime.Now;
- if (starttime == null)
- {
- starttime = new DateTime(date.Year, date.Month, 1);
- }
- if (endtime == null)
- {
- endtime = DateTime.Now;
- }
- string dept = "";
- if (deptid>0)
- dept= deptid.ToString();
- string infosource = "";
- if (source > 0)
- infosource = source.ToString();
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", starttime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- paras.Add("@edate", endtime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- paras.Add("@deptid", dept);
- paras.Add("@source", infosource);
- var obj = DbHelperSQL.RunProcedure("P_DeptBureauHandling", paras, "DeptBureauHandling");
- if (isExport)
- {
- string message = new NPOIHelper().BureauHandling(obj);
- if (message == "")
- return Success("导出excel");
- else
- return Error(message);
- }
- return Success("成功", obj);
- }
- /// <summary>
- /// 局委评议统计
- /// </summary>
- /// <param name="starttime"></param>
- /// <param name="endtime"></param>
- /// <param name="deptid"></param>
- /// <param name="source"></param>
- /// <param name="isExport"></param>
- /// <returns></returns>
- public ActionResult DeptReview(DateTime? starttime, DateTime? endtime, int deptid = 0, int source = 0, bool isExport = false)
- {
- DateTime date = DateTime.Now;
- if (starttime == null)
- {
- starttime = new DateTime(date.Year, date.Month, 1);
- }
- if (endtime == null)
- {
- endtime = DateTime.Now;
- }
- string dept = "";
- if (deptid > 0)
- dept = deptid.ToString();
- string infosource = "";
- if (source > 0)
- infosource = source.ToString();
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", starttime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- paras.Add("@edate", endtime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- paras.Add("@deptid", dept);
- paras.Add("@source", infosource);
- var obj = DbHelperSQL.RunProcedure("P_DeptReview", paras, "DeptReview");
- if (isExport)
- {
- var cols = new string[] { "序号", "承办单位", "办件总数", "评议率", "评议总数", "一次评议满意", "一次评议不满意"
- , "一次评议满意率", "二次评议满意", "二次评议不满意", "二级评议满意率"};
- new NPOIHelper().ExportToExcel("局委评议统计", obj.Tables[0], cols);
- return Success("导出excel");
- }
- return Success("成功", obj);
- }
- /// <summary>
- /// 政民互动综合统计
- /// </summary>
- /// <param name="starttime"></param>
- /// <param name="endtime"></param>
- /// <param name="deptid"></param>
- /// <param name="source"></param>
- /// <param name="isExport"></param>
- /// <returns></returns>
- public ActionResult Government(DateTime? starttime, DateTime? endtime, int deptid = 0, int source = 0, bool isExport = false)
- {
- DateTime date = DateTime.Now;
- if (starttime == null)
- {
- starttime = new DateTime(date.Year, date.Month, 1);
- }
- if (endtime == null)
- {
- endtime = DateTime.Now;
- }
- string dept = "";
- if (deptid > 0)
- dept = deptid.ToString();
- string infosource = "";
- if (source > 0)
- infosource = source.ToString();
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", starttime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- paras.Add("@edate", endtime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- paras.Add("@deptid", dept);
- paras.Add("@source", infosource);
- var obj = DbHelperSQL.RunProcedure("P_Government", paras, "Government");
- if (isExport)
- {
- string message = new NPOIHelper().Government(obj);
- if (message == "")
- return Success("导出excel");
- else
- return Error(message);
- }
- return Success("成功", obj);
- }
- /// <summary>
- /// 归并热线每日数据统计
- /// </summary>
- /// <param name="starttime"></param>
- /// <param name="endtime"></param>
- /// <returns></returns>
- public ActionResult MergerHotline(DateTime? starttime , DateTime ? endtime,bool isExport = false )
- {
- DateTime date = DateTime.Now;
- if (starttime ==null )
- {
- starttime = new DateTime(date.Year, date.Month, 1);
- }
- if (endtime == null)
- {
- endtime = DateTime.Now;
- }
- List<MergerHot.MergerHotSource> MergerHotSource = new List<MergerHot.MergerHotSource>();
- var source = new BLL.T_Sys_DictionaryValue().GetModelList
- ("F_PrentId ='2498'");
- string key = "";
- foreach (var it in source)
- {
- key += ",'"+it.F_Value+"'" ;
- }
- var CallRecords = new BLL.T_Call_CallRecords().GetModelList("CallType=0 and BeginTime between '" + starttime.Value.ToString("yyyy-MM-dd HH:mm:ss") + "' and '" + endtime.Value.ToString("yyyy-MM-dd HH:mm:ss") + "' and PhoneType in ("+ key .TrimStart (',') + ")");
-
- if (source !=null && source .Count >0)
- {
- for (DateTime dt = starttime.Value; dt <= endtime.Value; dt = dt.AddDays(1))
- {
- MergerHot.MergerHotSource mergerHotSources = new MergerHot.MergerHotSource();
- mergerHotSources.Data = dt.ToString("MM月dd日");
- mergerHotSources.MergerHot = new List<MergerHot.MergerHots>();
- for (int i = 0; i < source.Count + 3; i++)
- {
- if (i < source.Count)
- {
-
- MergerHot.MergerHots mergerHot = new MergerHot.MergerHots();
- if (source[i].F_Value == "12345")
- {
- mergerHot.sort = source.Count;
- }
- else
- {
- mergerHot.sort = i-1;
- }
- mergerHot.Source = source[i ].F_Value ;
- mergerHot.Call = CallRecords.Where(x => x.BeginTime
- .Value.Day ==dt .Day && x.PhoneType == source[i].F_Value).Count();
- mergerHot.Connect = CallRecords.Where(x => x.BeginTime
- .Value.Day == dt.Day && x.CallState == 1 && x.PhoneType == source[i].F_Value).Count();
- mergerHot.Notconnected = CallRecords.Where(x => x.BeginTime
- .Value.Day == dt.Day && x.CallState == 0 && x.PhoneType == source[i].F_Value && x.UserCode != ""
- && x.UserCode != null).Count();
- mergerHot.voluntarily = CallRecords.Where(x => x.BeginTime
- .Value.Day == dt.Day && x.CallState == 0 && x.PhoneType == source[i].F_Value && (x.UserCode == ""
- || x.UserCode == null)).Count();
- if (mergerHot.Call > 0)
- {
- mergerHot.rate = string.Format("{0:f2}%", (float)mergerHot.Connect / (float)mergerHot.Call * 100);
- }
- else
- {
- mergerHot.rate = "100%";
- }
-
- mergerHotSources.MergerHot.Add(mergerHot);
-
- }
- else if (i == source.Count)
- {
- MergerHot.MergerHots mergerHot = new MergerHot.MergerHots();
- mergerHot.Source = "当日小计";
- mergerHot.sort = source.Count + 1;
- mergerHot.Call = CallRecords.Where(x => x.BeginTime
- .Value.Day == dt.Day).Count();
- mergerHot.Connect = CallRecords.Where(x => x.BeginTime
- .Value.Day == dt.Day && x.CallState == 1).Count();
- mergerHot.Notconnected = CallRecords.Where(x => x.BeginTime
- .Value.Day == dt.Day && x.CallState == 0 && x.UserCode != ""
- && x.UserCode != null).Count();
- mergerHot.voluntarily = CallRecords.Where(x => x.BeginTime
- .Value.Day == dt.Day && x.CallState == 0 && (x.UserCode == ""
- || x.UserCode == null)).Count();
- if (mergerHot.Call>0)
- {
- mergerHot.rate = string.Format("{0:f2}%", (float)mergerHot.Connect / (float)mergerHot.Call * 100);
- }
- else
- {
- mergerHot.rate = "100%";
- }
- mergerHotSources.MergerHot.Add(mergerHot);
- }
- else if (i == source.Count+1)
- {
- MergerHot.MergerHots mergerHot = new MergerHot.MergerHots();
- mergerHot.Source = "累计";
- mergerHot.sort = source.Count+2;
- mergerHot.Call = CallRecords.Where(x => x.BeginTime
- .Value.Date >=starttime .Value.Date && x.BeginTime
- .Value.Date <= dt.Date ).Count();
- mergerHot.Connect = CallRecords.Where(x => x.BeginTime
- .Value.Date >= starttime.Value.Date && x.BeginTime
- .Value.Date <= dt.Date && x.CallState == 1 ).Count();
- mergerHot.Notconnected = CallRecords.Where(x => x.BeginTime
- .Value.Date >= starttime.Value.Date && x.BeginTime
- .Value.Date <= dt.Date && x.CallState == 0 && x.UserCode != ""
- && x.UserCode != null).Count();
- mergerHot.voluntarily = CallRecords.Where(x => x.BeginTime
- .Value.Date >= starttime.Value.Date && x.BeginTime
- .Value.Date <= dt.Date && x.CallState == 0 && (x.UserCode == ""
- || x.UserCode == null)).Count();
- if (mergerHot.Call > 0)
- {
- mergerHot.rate = string.Format("{0:f2}%", (float)mergerHot.Connect / (float)mergerHot.Call * 100);
- }
- else
- {
- mergerHot.rate = "100%";
- }
- mergerHotSources.MergerHot.Add(mergerHot);
- }
- else if (i == source.Count+2)
- {
- MergerHot.MergerHots mergerHot = new MergerHot.MergerHots();
- mergerHot.Source = "归并热线小计";
- mergerHot.sort = source.Count-1;
- mergerHot.Call = CallRecords.Where(x => x.BeginTime
- .Value.Day == dt.Day&&x.PhoneType !="12345").Count();
- mergerHot.Connect = CallRecords.Where(x => x.BeginTime
- .Value.Day == dt.Day && x.CallState == 1 && x.PhoneType != "12345").Count();
- mergerHot.Notconnected = CallRecords.Where(x => x.BeginTime
- .Value.Day == dt.Day && x.CallState == 0 && x.UserCode != ""
- && x.UserCode != null && x.PhoneType != "12345").Count();
- mergerHot.voluntarily = CallRecords.Where(x => x.BeginTime
- .Value.Day == dt.Day && x.CallState == 0 && (x.UserCode == ""
- || x.UserCode == null) && x.PhoneType != "12345").Count();
- mergerHot.callback = CallRecords.Where(x => x.BeginTime
- .Value.Day == dt.Day &&x .PhoneType != "12345" && x.Callback == 1).Count();
-
- if (mergerHot.Call > 0)
- {
- mergerHot.rate = string.Format("{0:f2}%", (float)mergerHot.Connect / (float)mergerHot.Call * 100);
- }
- else
- {
- mergerHot.rate = "100%";
- }
- mergerHotSources.MergerHot.Add(mergerHot);
- }
- }
- mergerHotSources.MergerHot= mergerHotSources.MergerHot.OrderBy(x => x.sort).ToList ();
- MergerHotSource.Add(mergerHotSources);
- }
- }
- if (MergerHotSource!=null && MergerHotSource .Count >0)
- {
- MergerHot.MergerHotSource mergerHotSources = new MergerHot.MergerHotSource();
- mergerHotSources.Data = "合计";
- mergerHotSources.MergerHot = new List<MergerHot.MergerHots>();
- for (int i = 0; i < source.Count + 2; i++)
- {
- if (i < source.Count)
- {
- MergerHot.MergerHots mergerHot = new MergerHot.MergerHots();
- mergerHot.Source = source[i].F_Value;
- mergerHot.Call = CallRecords.Where(x=> x.PhoneType == source[i].F_Value).Count();
- mergerHot.Connect = CallRecords.Where(x => x.CallState == 1 && x.PhoneType == source[i].F_Value).Count();
- mergerHot.Notconnected = CallRecords.Where(x => x.CallState == 0 && x.PhoneType == source[i].F_Value && x.UserCode != ""
- && x.UserCode != null).Count();
- mergerHot.voluntarily = CallRecords.Where(x => x.CallState == 0 && x.PhoneType == source[i].F_Value && (x.UserCode == ""
- || x.UserCode == null)).Count();
- if (source[i].F_Value=="12345")
- {
- mergerHot.sort = source.Count ;
- }
- else
- {
- mergerHot.sort =i -1;
- }
- if (mergerHot.Call > 0)
- {
- mergerHot.rate = string.Format("{0:f2}%", (float)mergerHot.Connect / (float)mergerHot.Call * 100);
- }
- else
- {
- mergerHot.rate = "100%";
- }
- mergerHotSources.MergerHot.Add(mergerHot);
- }
- else if (i == source.Count)
- {
- MergerHot.MergerHots mergerHot = new MergerHot.MergerHots();
- mergerHot.Source ="当日小计";
- mergerHot.sort = source.Count + 1;
- mergerHot.Call = CallRecords.Count();
- mergerHot.Connect = CallRecords.Where(x =>x.CallState == 1).Count();
- mergerHot.Notconnected = CallRecords.Where(x => x.CallState == 0 && x.UserCode != ""
- && x.UserCode != null).Count();
- mergerHot.voluntarily = CallRecords.Where(x => x.CallState == 0 && (x.UserCode == ""
- || x.UserCode == null)).Count();
- if (mergerHot.Call > 0)
- {
- mergerHot.rate = string.Format("{0:f2}%", (float)mergerHot.Connect / (float)mergerHot.Call * 100);
- }
- else
- {
- mergerHot.rate = "100%";
- }
- mergerHotSources.MergerHot.Add(mergerHot);
- }
- else if (i == source.Count+1)
- {
- MergerHot.MergerHots mergerHot = new MergerHot.MergerHots();
- mergerHot.Source = "归并热线小计";
- mergerHot.sort = source.Count - 1;
- mergerHot.Call = CallRecords.Where(x => x.PhoneType != "12345").Count();
- mergerHot.Connect = CallRecords.Where(x => x.PhoneType != "12345").Count();
- mergerHot.Notconnected = CallRecords.Where(x =>x.CallState == 0 && x.UserCode != ""
- && x.UserCode != null && x.PhoneType != "12345").Count();
- mergerHot.voluntarily = CallRecords.Where(x => x.CallState == 0 && (x.UserCode == ""
- || x.UserCode == null && x.PhoneType != "12345")).Count();
- mergerHot.callback = CallRecords.Where(x => x.PhoneType != "12345" && x.Callback == 1).Count();
- if (mergerHot.Call > 0)
- {
- mergerHot.rate = string.Format("{0:f2}%", (float)mergerHot.Connect / (float)mergerHot.Call * 100);
- }
- else
- {
- mergerHot.rate = "100%";
- }
- mergerHotSources.MergerHot.Add(mergerHot);
- }
- }
- mergerHotSources.MergerHot = mergerHotSources.MergerHot.OrderBy(x => x.sort).ToList();
- MergerHotSource.Add(mergerHotSources);
- }
- if (isExport)
- {
-
- new NPOIHelper().ExportMergerToExcel(MergerHotSource);
- return Success("导出excel");
- }
- return Success("获取成功", MergerHotSource);
-
- }
-
- /// <summary>
- /// 调度工作量统计
- /// </summary>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <param name="isExport"></param>
- /// <returns></returns>
- public ActionResult GetWorkLoad1(DateTime? start, DateTime? end, bool isExport = false)
- {
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
- paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
- var obj = DbHelperSQL.RunProcedure("P_LeaderAssessmentReport", paras, "LeaderAssessmentReport");
- if (isExport)
- {
- var cols = new string[] { "姓名", "回退量", "交办量", "退回审核量", "延时审核量", "重办量", "结案量" };
- new NPOIHelper().ExportToExcel($"调度工作量统计{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
- return Success("导出excel");
- }
- return Success("成功", obj);
- }
- public ActionResult GetWorkLoad(DateTime? start, DateTime? end, bool isExport = false, string source = "")
- {
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
- paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
- paras.Add("@source", source);
- var obj = DbHelperSQL.RunProcedure("P_LeaderAssessmentReport_1", paras, "LeaderAssessmentReport");
- if (isExport)
- {
- var cols = new string[] { "姓名", "回退量", "交办量", "退回审核量", "延时审核量", "重办量", "结案量" };
- new NPOIHelper().ExportToExcel($"调度工作量统计{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
- return Success("导出excel");
- }
- return Success("成功", obj);
- }
- /// <summary>
- /// 获取未处理报表
- /// </summary>
- /// <param name="date"></param>
- /// <param name="isdc"></param>
- /// <returns></returns>
- public ActionResult GetNoDealReport(DateTime? start, DateTime? end, int deptid = 0, int pageIndex = 1, int pageSize = 10, int isdc = 0)
- {
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- var where = "";
- if (deptid > 0)
- {
- where = " AND F_MainDeptId=" + deptid;
- }
- string sql = $" and datediff(day,F_CreateTime,'{start.Value.ToString("yyyy-MM-dd")}')<=0 and datediff(day,F_CreateTime,'{end.Value.ToString("yyyy-MM-dd")}')>=0 " + where;
- if (isdc > 0)
- {
- string[] cols = new string[] { "工单编号", "承办单位", "工单内容", "转派时间", "回复时限", "超时/剩余", "工单状态" };
- var dtall = DbHelperSQL.Query("select * from V_Bus_NoDeal where 1=1 " + sql).Tables[0];
- dtall.Columns.Remove("F_MainDeptId");
- dtall.Columns.Remove("F_CreateTime");
- dtall.Columns.Remove("F_WorkState");
- new NPOIHelper().ExportToExcel($"单位未处理统计报表{start.Value.ToString("yyyyMMdd")}-{end.Value.ToString("yyyyMMdd")}", dtall, cols);
- return Success("导出excel");
- }
- int recordCount = 0;
- var dt = BLL.PagerBLL.GetListPager(
- "V_Bus_NoDeal",
- "F_WorkOrderId",
- "*",
- sql,
- "ORDER BY F_CreateTime DESC",
- pageSize,
- pageIndex,
- true,
- out recordCount);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
-
- #region 20190618 zhengbingbing 新增处理量统计按照时间筛选
- /// <summary>
- /// 处理量统计
- /// </summary>
- /// <param name="sdate"></param>
- /// <param name="edate"></param>
- /// <param name="isExport"></param>
- /// <returns></returns>
- public ActionResult GetDeptDayReport1(string sdate, string edate,int isdept=1, bool isExport = false)
- {
- if (string.IsNullOrEmpty(sdate))
- {
- sdate = DateTime.Now.Date.ToString("yyyy-MM-01");
- }
- if (string.IsNullOrEmpty(edate))
- {
- edate = DateTime.Now.Date.ToString("yyyy-MM-dd");
- }
-
- if (User.F_RoleCode == "GLY" || User.F_RoleCode == "SPZ" || User.F_RoleCode == "SPZJZ")
- {
- var maindeptid = 0;
- if (User.F_RoleCode == "WLDW")
- {
- maindeptid = User.F_DeptId;
- }
- else if (User.F_RoleCode == "EJWLDW")
- {
- maindeptid = User.F_DeptId;
- isdept = 2;
- }
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", sdate);
- paras.Add("@edate", edate);
- paras.Add("@isdept", isdept.ToString ());
- var obj = DbHelperSQL.RunProcedure("P_DeptDayReport", paras, "DeptDayReport");
- if (isExport)
- {
- var cols = new string[] { "名称", "受理数量", "处理量", "延期量", "重办量", "结案量", "办理率", "办结率" };
- new NPOIHelper().ExportToExcel($"工单报表{sdate}-{edate}", obj.Tables[0], cols);
- return Success("导出excel");
- }
- return Success("成功", obj);
- }
- public ActionResult GetDeptDayReport(string sdate, string edate, int isdept = 0, bool isExport = false,string source="",int deptid=0 )
- {
- if (string.IsNullOrEmpty(sdate))
- {
- sdate = DateTime.Now.Date.ToString("yyyy-MM-01");
- }
- if (string.IsNullOrEmpty(edate))
- {
- edate = DateTime.Now.Date.ToString("yyyy-MM-dd");
- }
-
- if (User.F_RoleCode != "GLY" && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ")
- {
- if (User.F_RoleCode == "WLDW")
- {
- isdept = User.F_DeptId;
- }
- else if (User.F_RoleCode == "EJWLDW")
- {
- isdept = User.F_DeptId;
- }
- }
- string dept = "";
- if (isdept > 0)
- dept = isdept.ToString();
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", sdate);
- paras.Add("@edate", edate);
- paras.Add("@isdept", dept);
- paras.Add("@source", source);
-
- var obj = DbHelperSQL.RunProcedure("P_DeptDayReport_1", paras, "DeptDayReport");
- if (obj!=null && obj.Tables[0]!=null && obj.Tables[0].Rows.Count > 0) {
- for (int i = 0; i < obj.Tables[0].Rows.Count; i++)
- {
- int acceptcount = 0, dealcount = 0, endcount = 0;double dealrate = 0, endrate = 0;
- int.TryParse(obj.Tables[0].Rows[i]["acceptcount"].ToString(),out acceptcount);
- int.TryParse(obj.Tables[0].Rows[i]["dealcount"].ToString(), out dealcount);
- int.TryParse(obj.Tables[0].Rows[i]["endcount"].ToString(), out endcount);
- if(acceptcount>0)
- {
- dealrate = double.Parse((dealcount * 100).ToString()) / acceptcount;
- endrate = double.Parse((endcount * 100).ToString()) / acceptcount;
- obj.Tables[0].Rows[i]["dealrate"] = dealrate.ToString("f") + "%";
- obj.Tables[0].Rows[i]["endrate"] = endrate.ToString("f") + "%";
- }
-
- }
- }
- if (isExport)
- {
- var cols = new string[] { "名称", "受理数量", "处理量", "延期量", "重办量", "结案量", "办理率", "办结率" };
- new NPOIHelper().ExportToExcel($"处理数量统计报表{sdate.Substring(0, 10)}-{edate.Substring(0, 10)}", obj.Tables[0], cols);
- return Success("导出excel");
- }
- return Success("成功", obj);
- }
-
- #endregion
- #region 20191104 zhengbingbing 增加三级单位统计项
- /// <summary>
- /// 三级单位处理量统计
- /// </summary>
- /// <param name="sdate"></param>
- /// <param name="edate"></param>
- /// <param name="isExport"></param>
- /// <returns></returns>
- public ActionResult GetDept3DayReport1(string sdate, string edate, bool isExport = false)
- {
- if (string.IsNullOrEmpty(sdate))
- {
- sdate = DateTime.Now.Date.ToString("yyyy-MM-01");
- }
- if (string.IsNullOrEmpty(edate))
- {
- edate = DateTime.Now.Date.ToString("yyyy-MM-dd");
- }
-
- int deptid = 0;
- if (User.F_RoleCode != "GLY" && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ")
- {
- if (User.F_RoleCode == "WLDW" || User.F_RoleCode == "EJWLDW")
- {
- deptid = User.F_DeptId;
- }
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", sdate);
- paras.Add("@edate", edate);
- paras.Add("@deptid", deptid.ToString());
- var obj = DbHelperSQL.RunProcedure("P_Dept3DayReport", paras, "Dept3DayReport");
- if (isExport)
- {
- var cols = new string[] { "单位名称", "受理数量", "处理量", "结案量", "办理率", "办结率" };
- new NPOIHelper().ExportToExcel($"工单报表{sdate}-{edate}", obj.Tables[0], cols);
- return Success("导出excel");
- }
- return Success("成功", obj);
- }
- public ActionResult GetDept3DayReport(string sdate, string edate, bool isExport = false,string source = "")
- {
- if (string.IsNullOrEmpty(sdate))
- {
- sdate = DateTime.Now.Date.ToString("yyyy-MM-01");
- }
- if (string.IsNullOrEmpty(edate))
- {
- edate = DateTime.Now.Date.ToString("yyyy-MM-dd");
- }
-
- int deptid = 0;
- if (User.F_RoleCode != "GLY" && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ")
- {
- if (User.F_RoleCode == "WLDW" || User.F_RoleCode == "EJWLDW")
- {
- deptid = User.F_DeptId;
- }
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", sdate);
- paras.Add("@edate", edate);
- paras.Add("@deptid", deptid.ToString());
- paras.Add("@source", source);
- var obj = DbHelperSQL.RunProcedure("P_Dept3DayReport_1", paras, "Dept3DayReport");
- if (obj != null && obj.Tables[0] != null && obj.Tables[0].Rows.Count > 0)
- {
- for (int i = 0; i < obj.Tables[0].Rows.Count; i++)
- {
- int acceptcount = 0, dealcount = 0, endcount = 0; double dealrate = 0, endrate = 0;
- int.TryParse(obj.Tables[0].Rows[i]["acceptcount"].ToString(), out acceptcount);
- int.TryParse(obj.Tables[0].Rows[i]["dealcount"].ToString(), out dealcount);
- int.TryParse(obj.Tables[0].Rows[i]["endcount"].ToString(), out endcount);
- if (acceptcount > 0)
- {
- dealrate = double.Parse((dealcount * 100).ToString()) / acceptcount;
- endrate = double.Parse((endcount * 100).ToString()) / acceptcount;
- obj.Tables[0].Rows[i]["dealrate"] = dealrate.ToString("f") + "%";
- obj.Tables[0].Rows[i]["endrate"] = endrate.ToString("f") + "%";
- }
- }
- }
- if (isExport)
- {
- var cols = new string[] { "单位名称", "受理数量", "处理量", "结案量", "办理率", "办结率" };
- new NPOIHelper().ExportToExcel($"工单报表{sdate}-{edate}", obj.Tables[0], cols);
- return Success("导出excel");
- }
- return Success("成功", obj);
- }
- /// <summary>
- /// 三级单位满意度统计
- /// </summary>
- /// <param name="sdate"></param>
- /// <param name="edate"></param>
- /// <param name="isExport"></param>
- /// <returns></returns>
- public ActionResult GetDept3SatisfiedReport(string sdate, string edate, bool isExport = false, string source = "")
- {
- if (string.IsNullOrEmpty(sdate))
- {
- sdate = DateTime.Now.Date.ToString("yyyy-MM-01");
- }
- if (string.IsNullOrEmpty(edate))
- {
- edate = DateTime.Now.Date.ToString("yyyy-MM-dd");
- }
-
- int deptid = 0;
- if (User.F_RoleCode != "GLY" && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ")
- {
- if (User.F_RoleCode == "WLDW" || User.F_RoleCode == "EJWLDW")
- {
- deptid = User.F_DeptId;
- }
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", sdate);
- paras.Add("@edate", edate);
- paras.Add("@deptid", deptid.ToString());
- paras.Add("@source", source);
- var obj = DbHelperSQL.RunProcedure("P_Dept3SatisfiedReport", paras, "Dept3SatisfiedReport");
- if (isExport)
- {
- string[] cols = new string[] { "单位名称", "处理总量", "满意总量", "不满意总量", "满意度" };
- new NPOIHelper().ExportToExcel($"满意度统计报表{Convert.ToDateTime(sdate).ToString("yyyyMMdd")}-{Convert.ToDateTime(edate).ToString("yyyyMMdd")}", obj.Tables[0], cols);
- return Success("导出excel");
- }
- return Success("成功", obj);
- }
- /// <summary>
- /// 三级单位处理效率统计
- /// </summary>
- /// <param name="sdate"></param>
- /// <param name="edate"></param>
- /// <param name="isExport"></param>
- /// <returns></returns>
- public ActionResult GetDept3EfficiencyReport(string sdate, string edate, bool isExport = false, string source = "")
- {
- if (string.IsNullOrEmpty(sdate))
- {
- sdate = DateTime.Now.Date.ToString("yyyy-MM-01");
- }
- if (string.IsNullOrEmpty(edate))
- {
- edate = DateTime.Now.Date.ToString("yyyy-MM-dd");
- }
-
- int deptid = 0;
- if (User.F_RoleCode != "GLY" && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ")
- {
- if (User.F_RoleCode == "WLDW" || User.F_RoleCode == "EJWLDW")
- {
- deptid = User.F_DeptId;
- }
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", sdate);
- paras.Add("@edate", edate);
- paras.Add("@deptid", deptid.ToString());
- paras.Add("@source", source);
- var obj = DbHelperSQL.RunProcedure("P_Dept3EfficiencyReport", paras, "Dept3EfficiencyReport");
- if (isExport)
- {
- string[] cols = new string[] { "单位名称", "处理总量", "及时量", "超时量", "处理及时率" };
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("处理效率统计报表", obj.Tables[0], cols) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- return Success("成功", obj);
- }
- public ActionResult GetDept3EfficiencyReport1(string sdate, string edate, bool isExport = false)
- {
- if (string.IsNullOrEmpty(sdate))
- {
- sdate = DateTime.Now.Date.ToString("yyyy-MM-01");
- }
- if (string.IsNullOrEmpty(edate))
- {
- edate = DateTime.Now.Date.ToString("yyyy-MM-dd");
- }
- int deptid = 0;
- if (User.F_RoleCode != "GLY" && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ")
- {
- if (User.F_RoleCode == "WLDW" || User.F_RoleCode == "EJWLDW")
- {
- deptid = User.F_DeptId;
- }
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", sdate);
- paras.Add("@edate", edate);
- paras.Add("@deptid", deptid.ToString());
- var obj = DbHelperSQL.RunProcedure("P_Dept3EfficiencyReport_1", paras, "Dept3EfficiencyReport");
- var newSet = new DataSet();
- if (obj != null && obj.Tables[0] != null && obj.Tables[0].Rows.Count > 0)
- {
- obj.Tables[0].Columns.Add("rate", typeof(decimal));
- for (int i = 0; i < obj.Tables[0].Rows.Count; i++)
- {
- int completedcount = 0, timelycount = 0, timeoutcount = 0; double timelyrate = 0;
- int.TryParse(obj.Tables[0].Rows[i]["completedcount"].ToString(), out completedcount);
- int.TryParse(obj.Tables[0].Rows[i]["timelycount"].ToString(), out timelycount);
- int.TryParse(obj.Tables[0].Rows[i]["timeoutcount"].ToString(), out timeoutcount);
- timeoutcount = completedcount - timelycount;
- obj.Tables[0].Rows[i]["timeoutcount"] = timeoutcount;
- if (completedcount > 0)
- {
- timelyrate = double.Parse((timelycount * 100).ToString()) / completedcount;
- obj.Tables[0].Rows[i]["timelyrate"] = timelyrate.ToString("f") + "%";
- obj.Tables[0].Rows[i]["rate"] = timelyrate;
- }
- }
- obj.Tables[0].DefaultView.Sort = "rate desc";
- newSet.Tables.Add(obj.Tables[0].DefaultView.ToTable());
- newSet.Tables[0].Columns.Remove("rate");
- }
- if (isExport)
- {
- string[] cols = new string[] { "单位名称", "处理总量", "及时量", "超时量", "处理及时率" };
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("处理效率统计报表", newSet.Tables[0], cols) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- return Success("成功", newSet);
- }
- #endregion
- /// <summary>
- /// 单位月统计
- /// </summary>
- /// <param name="date"></param>
- /// <param name="isExport"></param>
- /// <returns></returns>
- public ActionResult GetDeptMonthReport(string date, bool isExport = false)
- {
- if (string.IsNullOrEmpty(date))
- {
- date = DateTime.Now.Date.ToString("yyyy-MM");
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@date", date);
- var obj = DbHelperSQL.RunProcedure("P_DeptMonthReport", paras, "DeptMonthReport");
- if (isExport)
- {
- var cols = new string[] { "名称", "当月受理数量", "当月处理量", "往月处理量", "当月延期量", "往月延期量", "当月重办量", "往月重办量", "当月结案量", "当月办理率", "当月办结率" };
- new NPOIHelper().ExportToExcel($"工单报表{date}", obj.Tables[0], cols);
- return Success("导出excel");
- }
- return Success("成功", obj);
- }
-
- /// <summary>
- /// 单位办理率统计
- /// </summary>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <param name="isExport"></param>
- /// <returns></returns>
- public ActionResult GetDeptEndRate(string month, int type = 0, bool isExport = false)
- {
- string start = "", end = "";
- if (month != null)
- {
- var date = DateTime.Parse(month + "-01");
- start = date.ToString("yyyy-MM-dd"); ;
- end = date.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd");
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start);
- paras.Add("@edate", end);
- paras.Add("@type", type.ToString());
- var obj = DbHelperSQL.RunProcedure("P_DeptEndRateReport", paras, "DeptEndRateReport");
- if (isExport)
- {
- var cols = new string[] { "单位", "受理数量", "办理数量", "结案数量", "结案率" };
- new NPOIHelper().ExportToExcel($"单位办理率统计{month}", obj.Tables[0], cols, 1);
- return Success("导出excel");
- }
- return Success("成功", obj);
- }
- /// <summary>
- /// 工单热点分布
- /// </summary>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <param name="deptid"></param>
- /// <param name="keyid"></param>
- /// <param name="sourcearea"></param>
- /// <param name="source"></param>
- /// <returns></returns>
- public ActionResult GetHotspotMap(DateTime? start, DateTime? end, int deptid = 0, int keyid = 0,int sourcearea = 0, int source=0)
- {
- if (start == null)
- {
- start = DateTime.Now;
- //start = new DateTime(start.Value.Year, start.Value.Month, 1);
- start = DateTime.Now.AddDays(-3);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- var where = " and ISNUMERIC(F_Longitude)>0 and ISNUMERIC(F_Latitude)>0 ";
- if (deptid > 0)
- where += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_AssignedInfo where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 )";
- if (keyid > 0)
- where += " and ','+F_Key+',' like '%," + keyid + ",%' ";
- if (sourcearea > 0)
- where += " and F_SourceArea='" + sourcearea+"' ";
- if (source > 0)
- where += " and F_InfoSource = '" + source + "' ";
- string sql = $" and datediff(day,F_CreateTime,'{start.Value.ToString("yyyy-MM-dd")}')<=0 and datediff(day,F_CreateTime,'{end.Value.ToString("yyyy-MM-dd")}')>=0 " + where;
- var orderlist = workOrderBLL.GetList(" 1=1 "+sql).Tables[0];
- var list = new List<string[]>();
- foreach (DataRow dr in orderlist.Rows)
- {
- var longitude = dr["F_Longitude"].ToString();
- var latitude = dr["F_Latitude"].ToString();
- var title= dr["F_ComTitle"].ToString();
- var content= dr["F_ComContent"].ToString();
- var strobj = new string[] { longitude, latitude, title, content };
- list.Add(strobj);
- }
- return Success("",list);
- }
- #region 20191121 zhengbingbing 新增质检工作统计:工单回访量、回访量、结案量、工单重办量、重办量
- public ActionResult GetQualityAssessment(DateTime? start, DateTime? end, bool isExport = false)
- {
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
- paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
- var wherevi = " and F_CreateTime between '"+ start.Value.ToString("yyyy-MM-dd 00:00:00") + "' and '"+ end.Value.ToString("yyyy-MM-dd 23:59:59") + "'";
- var whereja = " and F_CloseTime between '" + start.Value.ToString("yyyy-MM-dd 00:00:00") + "' and '" + end.Value.ToString("yyyy-MM-dd 23:59:59") + "'";
- string sql = "select '('+F_UserCode+')'+F_UserName 姓名" +
- ",(select COUNT(1) from(select F_CreateUser, F_WorkOrderId from T_Bus_VisitResult where F_IsDelete = 0 "+ wherevi + " group by F_CreateUser, F_WorkOrderId) t where F_CreateUser = F_UserCode) 工单回访量" +
- ",(select COUNT(1) from T_Bus_VisitResult where F_IsDelete = 0 " + wherevi + " and F_CreateUser = F_UserCode and F_IsDelete = 0) 回访量" +
- ",(select COUNT(1) from T_Bus_WorkOrder where F_WorkState = 9 and F_IsDelete = 0 and F_CloseUser = F_UserCode "+ whereja + ") 结案量" +
- ",(select COUNT(1) from(select F_CreateUser, F_WorkOrderId from T_Bus_Operation where F_IsDelete = 0 "+ wherevi + " and F_State = 11 and F_WorkOrderId in (select F_WorkOrderId from T_Bus_Operation where F_IsDelete = 0 and F_State = 8) group by F_CreateUser,F_WorkOrderId) tt where F_CreateUser = F_UserCode) 工单重办量" +
- ",(select COUNT(1) from T_Bus_Operation where F_IsDelete = 0 and F_State = 11 and F_CreateUser = F_UserCode " + wherevi + ") 重办量" +
- " from T_Sys_UserAccount where F_RoleId = 18 and F_DeleteFlag = 0 order by F_UserCode";
- var obj = DbHelperSQL.Query(sql);
- if (isExport)
- {
- string[] cols = new string[] { "姓名", "工单回访量", "回访量", "结案量", "工单重办量", "重办量" };
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("质检工作统计报表", obj.Tables[0], cols) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- return Success("成功", obj);
- }
- #endregion
- /// <summary>
- ///
- /// </summary>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <param name="isExport"></param>
- /// <returns></returns>
- public ActionResult GetAudithandling(DateTime? start, DateTime? end, bool isExport = false)
- {
- if (start == null)
- {
- start = DateTime.Now;
- start = new DateTime(start.Value.Year, start.Value.Month, 1);
- }
- if (end == null)
- {
- end = DateTime.Now;
- }
- Dictionary<string, string> paras = new Dictionary<string, string>();
- paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
- paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
- var obj = DbHelperSQL.RunProcedure("P_Audithandling", paras, "Audithandling");
- if (isExport)
- {
- var cols = new string[] { "单位名称", "办理件数量", "退回件数量", "延时件数量","超期未果数量" };
- new NPOIHelper().ExportToExcel($"审核办理工单统计{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
- return Success("导出excel");
- }
- return Success("成功", obj);
- }
- }
- }
|