Нет описания

WorkOrderReportController.cs 134KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823
  1. using CallCenter.Utility;
  2. using CallCenter.Utility.Linq;
  3. using CallCenter.Utility.Time;
  4. using CallCenterApi.Common;
  5. using CallCenterApi.DB;
  6. using CallCenterApi.Interface.Controllers.Base;
  7. using CallCenterApi.Interface.Models.Dto;
  8. using CallCenterApi.Model;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Data;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Web;
  15. using System.Web.Mvc;
  16. using static CallCenter.Utility.NPOIHelper;
  17. namespace CallCenterApi.Interface.Controllers.report
  18. {
  19. // [Authority]
  20. public class WorkOrderReportController : BaseController
  21. {
  22. private readonly BLL.T_Sys_Department departmentBLL = new BLL.T_Sys_Department();
  23. private readonly BLL.T_Bus_WorkOrder workOrderBLL = new BLL.T_Bus_WorkOrder();
  24. private readonly BLL.T_Bus_AssignedInfo assignedInfoBLL = new BLL.T_Bus_AssignedInfo();
  25. private readonly BLL.T_Bus_Feedback feedbackBLL = new BLL.T_Bus_Feedback();
  26. private readonly BLL.T_Sys_DictionaryValue dictValueBLL = new BLL.T_Sys_DictionaryValue();
  27. private readonly BLL.T_Sys_Area areaBLL = new BLL.T_Sys_Area();
  28. private readonly BLL.T_Bus_VisitResult visitResultBLL = new BLL.T_Bus_VisitResult();
  29. private readonly BLL.T_Bus_DelayTime delayTimeBLL = new BLL.T_Bus_DelayTime();
  30. private readonly BLL.T_Sys_UserAccount userAccount = new BLL.T_Sys_UserAccount();
  31. private readonly BLL.T_Bus_SubmitSuper submitsuperBLL = new BLL.T_Bus_SubmitSuper();
  32. /// <summary>
  33. /// 处理数量统计
  34. /// </summary>
  35. /// <returns></returns>
  36. public ActionResult GetDeptCount(DateTime? start, DateTime? end, bool isExport = false)
  37. {
  38. if (start == null)
  39. {
  40. start = DateTime.Now;
  41. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  42. }
  43. if (end == null)
  44. {
  45. end = DateTime.Now;
  46. }
  47. Dictionary<string, string> paras = new Dictionary<string, string>();
  48. paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
  49. paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
  50. var obj = DbHelperSQL.RunProcedure("P_DeptDealReport", paras, "DeptDealReport");
  51. if (isExport)
  52. {
  53. var cols = new string[] { "单位名称", "数量" };
  54. new NPOIHelper().ExportToExcel($"处理数量统计报表{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
  55. return Success("导出excel");
  56. }
  57. return Success("成功", obj);
  58. }
  59. /// <summary>
  60. /// 处理效率统计
  61. /// </summary>
  62. /// <returns></returns>
  63. public ActionResult GetDeptEfficiency1(DateTime? start, DateTime? end, bool isExport = false)
  64. {
  65. if (start == null)
  66. {
  67. start = DateTime.Now;
  68. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  69. }
  70. if (end == null)
  71. {
  72. end = DateTime.Now;
  73. }
  74. Dictionary<string, string> paras = new Dictionary<string, string>();
  75. paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
  76. paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
  77. var obj = DbHelperSQL.RunProcedure("P_DeptEfficiencyReport", paras, "DeptEfficiencyReport");
  78. if (isExport)
  79. {
  80. string[] cols = new string[] { "单位名称", "处理总量", "及时量", "超时量", "处理及时率" };
  81. NPOIHelper npoi = new NPOIHelper();
  82. if (npoi.ExportToExcel("处理效率统计报表", obj.Tables[0], cols) == "")
  83. {
  84. return Success("导出成功");
  85. }
  86. else
  87. {
  88. return Error("导出失败");
  89. }
  90. }
  91. return Success("成功", obj);
  92. }
  93. public ActionResult GetDeptEfficiency(DateTime? start, DateTime? end, bool isExport = false,string source="")
  94. {
  95. if (start == null)
  96. {
  97. start = DateTime.Now;
  98. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  99. }
  100. if (end == null)
  101. {
  102. end = DateTime.Now;
  103. }
  104. Dictionary<string, string> paras = new Dictionary<string, string>();
  105. paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
  106. paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
  107. paras.Add("@source", source);
  108. var obj = DbHelperSQL.RunProcedure("P_DeptEfficiencyReport_1", paras, "DeptEfficiencyReport");
  109. var newSet = new DataSet();
  110. if (obj != null && obj.Tables[0] != null && obj.Tables[0].Rows.Count > 0)
  111. {
  112. obj.Tables[0].Columns.Add("rate", typeof(decimal));
  113. for (int i = 0; i < obj.Tables[0].Rows.Count; i++)
  114. {
  115. int completedcount = 0, timelycount = 0, timeoutcount = 0; double timelyrate = 0;
  116. int.TryParse(obj.Tables[0].Rows[i]["completedcount"].ToString(), out completedcount);
  117. int.TryParse(obj.Tables[0].Rows[i]["timelycount"].ToString(), out timelycount);
  118. int.TryParse(obj.Tables[0].Rows[i]["timeoutcount"].ToString(), out timeoutcount);
  119. timeoutcount = completedcount - timelycount;
  120. obj.Tables[0].Rows[i]["timeoutcount"] = timeoutcount;
  121. if (completedcount > 0)
  122. {
  123. timelyrate = double.Parse((timelycount * 100).ToString()) / completedcount;
  124. obj.Tables[0].Rows[i]["timelyrate"] = timelyrate.ToString("f") + "%";
  125. obj.Tables[0].Rows[i]["rate"] = timelyrate;
  126. }
  127. }
  128. obj.Tables[0].DefaultView.Sort = "rate desc";
  129. newSet.Tables.Add(obj.Tables[0].DefaultView.ToTable());
  130. newSet.Tables[0].Columns.Remove("rate");
  131. //obj.Tables[0] = obj.Tables[0].DefaultView.ToTable();
  132. }
  133. if (isExport)
  134. {
  135. string[] cols = new string[] { "单位名称", "处理总量", "及时量", "超时量", "处理及时率" };
  136. NPOIHelper npoi = new NPOIHelper();
  137. if (npoi.ExportToExcel("处理效率统计报表", newSet.Tables[0], cols) == "")
  138. {
  139. return Success("导出成功");
  140. }
  141. else
  142. {
  143. return Error("导出失败");
  144. }
  145. }
  146. return Success("成功", newSet);
  147. }
  148. /// <summary>
  149. /// 市民满意度评价
  150. /// </summary>
  151. /// <returns></returns>
  152. public ActionResult GetDeptSatisfied(DateTime? start, DateTime? end,int source=0, bool isExport = false)
  153. {
  154. if (start == null)
  155. {
  156. start = DateTime.Now;
  157. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  158. }
  159. if (end == null)
  160. {
  161. end = DateTime.Now;
  162. }
  163. Dictionary<string, string> paras = new Dictionary<string, string>();
  164. paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
  165. paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
  166. paras.Add("@source", source.ToString());
  167. var obj = DbHelperSQL.RunProcedure("P_DeptSatisfied", paras, "DeptSatisfied");
  168. if (isExport)
  169. {
  170. string[] cols = new string[] { "单位名称", "受理总量", "处理总量", "满意总量", "基本满意总量", "不满意总量", "满意度" };
  171. new NPOIHelper().ExportToExcel($"满意度统计报表{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
  172. return Success("导出excel");
  173. }
  174. var ob = new
  175. {
  176. state = "success",
  177. message = "成功",
  178. DeptSatisfiedReport = obj ,
  179. };
  180. return Success("成功", ob );
  181. }
  182. /// <summary>
  183. /// 市民满意度评价台账
  184. /// </summary>
  185. /// <returns></returns>
  186. public ActionResult GetDeptSatisfiedList(string start, string end,int deptId=0,int myd=-1, int page = 1, int pagesize = 10, bool isExport = false)
  187. {
  188. 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 !=''";
  189. if (!string.IsNullOrEmpty(start)&&start.Trim() != "" && start != "undefined")
  190. {
  191. sql += " and F_CreateTime>='" + start + "' ";
  192. }
  193. if (!string.IsNullOrEmpty(end) && end.Trim() != "" && end != "undefined")
  194. {
  195. sql += " and F_CreateTime<='" + end + "' ";
  196. }
  197. if (deptId > 0)
  198. {
  199. sql += " and F_MainDeptId= " + deptId;
  200. }
  201. if (myd > -1)
  202. {
  203. sql += " and MYD= " + myd;
  204. }
  205. if (isExport)
  206. {
  207. 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];
  208. string[] dccols = new string[] { "工单编号", "述求标题", "工单内容", "承办单位", "受理人", "时限", "办理结果", "满意度" };
  209. new NPOIHelper().ExportToExcel($"满意度台账报表{DateTime.Now.ToString("yyyyMMddHHmmssfff")}", dtdc, dccols);
  210. return Success("导出excel");
  211. }
  212. 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";
  213. int recordCount = 0;
  214. DataTable dt = BLL.PagerBLL.GetListPager(
  215. "(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",
  216. "F_Id",
  217. cols,
  218. sql,
  219. "ORDER BY F_CreateTime DESC",
  220. pagesize,
  221. page,
  222. true,
  223. out recordCount);
  224. var obj = new
  225. {
  226. state = "success",
  227. message = "成功",
  228. rows = dt,
  229. total = recordCount
  230. };
  231. return Content(obj.ToJson());
  232. }
  233. /// <summary>
  234. /// 县区满意度评价
  235. /// </summary>
  236. /// <returns></returns>
  237. #region 20191022 调整多主办单位需调整
  238. public ActionResult GetAreaSatisfied(DateTime? start, DateTime? end, bool isExport = false)
  239. {
  240. if (start == null)
  241. {
  242. start = DateTime.Now;
  243. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  244. }
  245. if (end == null)
  246. {
  247. end = DateTime.Now;
  248. }
  249. //var sql = "F_IsDelete=0 and F_IsSure=1 and F_State=1 and isnull(F_FeedbackTime,'')<>'' "
  250. // + "and datediff(day, F_FeedbackTime, @sdate) <= 0 and datediff(day, F_FeedbackTime, @edate) >= 0"
  251. // + "and F_WorkOrderId in (select F_WorkOrderId from T_Bus_WorkOrder where F_WorkState = 9)";
  252. //var assignedInfoList = assignedInfoBLL.GetModelList(sql);
  253. //var workorderList = workOrderBLL.GetModelList("");
  254. //var deptList = departmentBLL.GetModelList(" F_State=0 AND F_PartentId=0 ");
  255. //foreach (var item in deptList)
  256. //{
  257. // 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 + ") ");
  258. //}
  259. Dictionary<string, string> paras = new Dictionary<string, string>();
  260. paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
  261. paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
  262. var obj = DbHelperSQL.RunProcedure("P_AreaSatisfiedReport", paras, "AreaSatisfiedReport");
  263. if (isExport)
  264. {
  265. string[] cols = new string[] { "县/区", "处理总量", "满意总量", "不满意总量", "满意度" };
  266. new NPOIHelper().ExportToExcel($"满意度统计报表{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
  267. return Success("导出excel");
  268. }
  269. return Success("成功", obj);
  270. }
  271. //public ActionResult GetAreaSatisfied(DateTime? start, DateTime? end, bool isExport = false)
  272. //{
  273. // if (start == null)
  274. // {
  275. // start = DateTime.Now;
  276. // start = new DateTime(start.Value.Year, start.Value.Month, 1);
  277. // }
  278. // if (end == null)
  279. // {
  280. // end = DateTime.Now;
  281. // }
  282. // //string sql = $"select * from dbo.GetDeptSatisfied('{start.Value.ToString("yyyy-MM-dd")}','{end.Value.ToString("yyyy-MM-dd")}') ORDER BY rate DESC";
  283. // //var dtall = DbHelperSQL.Query(sql).Tables[0];
  284. // Dictionary<string, string> paras = new Dictionary<string, string>();
  285. // paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
  286. // paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
  287. // var obj = DbHelperSQL.RunProcedure("P_AreaSatisfiedReport", paras, "AreaSatisfiedReport");
  288. // if (isExport)
  289. // {
  290. // string[] cols = new string[] { "县/区", "处理总量", "满意总量", "不满意总量", "满意度" };
  291. // new NPOIHelper().ExportToExcel($"满意度统计报表{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
  292. // return Success("导出excel");
  293. // }
  294. // return Success("成功", obj);
  295. // //int recordCount = 0;
  296. // //var dt = BLL.PagerBLL.GetListPager(
  297. // // "("+sql+") as v",
  298. // // "deptname",
  299. // // "*",
  300. // // "",
  301. // // "ORDER BY rate DESC",
  302. // // pageSize,
  303. // // pageIndex,
  304. // // true,
  305. // // out recordCount);
  306. // //var obj = new
  307. // //{
  308. // // state = "success",
  309. // // message = "成功",
  310. // // rows = dt,
  311. // // total = recordCount
  312. // //};
  313. // //return Content(obj.ToJson());
  314. //}
  315. #endregion
  316. /// <summary>
  317. /// 单位绩效考核
  318. /// </summary>
  319. /// <param name="start"></param>
  320. /// <param name="end"></param>
  321. /// <returns></returns>
  322. public ActionResult GetDeptAssessment(DateTime? start, DateTime? end, bool isExport = false,string source="")
  323. {
  324. StringBuilder sb1 = new StringBuilder();
  325. StringBuilder sb2 = new StringBuilder();
  326. if (start == null)
  327. {
  328. start = DateTime.Now;
  329. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  330. }
  331. if (end == null)
  332. {
  333. end = DateTime.Now;
  334. }
  335. Dictionary<string, string> paras = new Dictionary<string, string>();
  336. paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
  337. paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
  338. paras.Add("@source", source);
  339. var obj = DbHelperSQL.RunProcedure("P_DeptAssessmentReport", paras, "DeptAssessmentReport");
  340. if (isExport)
  341. {
  342. string[] cols = new string[] { "单位名称", "已办总量", "及时量", "超时量", "超时时长(小时)", "延时量", "处理时长(小时)", "平均处理时长(小时)", "最大处理时长(小时)", "回访量", "市民满意", "市民不满意" };
  343. NPOIHelper npoi = new NPOIHelper();
  344. if (npoi.ExportToExcel("单位绩效考核报表", obj.Tables[0], cols) == "")
  345. {
  346. return Success("导出成功");
  347. }
  348. else
  349. {
  350. return Error("导出失败");
  351. }
  352. }
  353. return Success("成功", obj);
  354. }
  355. /// <summary>
  356. /// 坐席工作统计
  357. /// </summary>
  358. /// <param name="start"></param>
  359. /// <param name="end"></param>
  360. /// <returns></returns>
  361. public ActionResult GetUserAccountAssessment1(DateTime? start, DateTime? end, bool isExport = false)
  362. {
  363. StringBuilder sb1 = new StringBuilder();
  364. StringBuilder sb2 = new StringBuilder();
  365. if (start == null)
  366. {
  367. start = DateTime.Now;
  368. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  369. }
  370. if (end == null)
  371. {
  372. end = DateTime.Now;
  373. }
  374. Dictionary<string, string> paras = new Dictionary<string, string>();
  375. paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  376. paras.Add("@edate", end.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  377. var obj = DbHelperSQL.RunProcedure("P_UserAssessmentReport", paras, "UserAssessmentReport");
  378. if (isExport)
  379. {
  380. string[] cols = new string[] { "姓名", "接听量", "通话成单量", "手动录单量", "当即办理量", "网络转办量", "回访量"};
  381. NPOIHelper npoi = new NPOIHelper();
  382. if (npoi.ExportToExcel("坐席工作统计报表", obj.Tables[0], cols) == "")
  383. {
  384. return Success("导出成功");
  385. }
  386. else
  387. {
  388. return Error("导出失败");
  389. }
  390. }
  391. return Success("成功", obj);
  392. }
  393. public ActionResult GetUserAccountAssessment(DateTime? start, DateTime? end, bool isExport = false,string source="",string name="")
  394. {
  395. StringBuilder sb1 = new StringBuilder();
  396. StringBuilder sb2 = new StringBuilder();
  397. if (start == null)
  398. {
  399. start = DateTime.Now;
  400. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  401. }
  402. if (end == null)
  403. {
  404. end = DateTime.Now;
  405. }
  406. Dictionary<string, string> paras = new Dictionary<string, string>();
  407. paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  408. paras.Add("@edate", end.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  409. paras.Add("@source", source);
  410. paras.Add("@name", name);
  411. var obj = DbHelperSQL.RunProcedure("P_UserAssessmentReport_1", paras, "UserAssessmentReport");
  412. if (isExport)
  413. {
  414. string[] cols = new string[] { "姓名", "接听量", "通话成单量", "手动录单量", "当即办理量", "网络转办量", "回访量","呼出量" ,"回拨量"};
  415. NPOIHelper npoi = new NPOIHelper();
  416. if (npoi.ExportToExcel("坐席工作统计报表", obj.Tables[0], cols) == "")
  417. {
  418. return Success("导出成功");
  419. }
  420. else
  421. {
  422. return Error("导出失败");
  423. }
  424. }
  425. return Success("成功", obj);
  426. }
  427. public ActionResult GetUserReturn(DateTime? start, DateTime? end, bool isExport = false)
  428. {
  429. StringBuilder sb1 = new StringBuilder();
  430. StringBuilder sb2 = new StringBuilder();
  431. if (start == null)
  432. {
  433. start = DateTime.Now;
  434. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  435. }
  436. if (end == null)
  437. {
  438. end = DateTime.Now;
  439. }
  440. Dictionary<string, string> paras = new Dictionary<string, string>();
  441. paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  442. paras.Add("@edate", end.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  443. var obj = DbHelperSQL.RunProcedure("P_UserReturn", paras, "UserReturn");
  444. if (isExport)
  445. {
  446. string[] cols = new string[] { "姓名", "工单量", "回访量", "未回访量", "回访率" };
  447. NPOIHelper npoi = new NPOIHelper();
  448. if (npoi.ExportToExcel("坐席回访统计报表", obj.Tables[0], cols) == "")
  449. {
  450. return Success("导出成功");
  451. }
  452. else
  453. {
  454. return Error("导出失败");
  455. }
  456. }
  457. return Success("成功", obj);
  458. }
  459. public ActionResult WorkOrdrList(int isdc=0)
  460. {
  461. DataTable dt = new DataTable();
  462. string sql = " and F_IsDelete=0 ";
  463. int sourceArea = RequestString.GetInt("sourceArea", 0);
  464. int keyid = RequestString.GetInt("keyid", 0);
  465. int deptid = RequestString.GetInt("deptid", 0);
  466. int key = RequestString.GetInt("key", 0);
  467. int timetype = RequestString.GetInt("timetype", 0);
  468. int ishf = RequestString.GetInt("ishf", 0);
  469. int area = RequestString.GetInt("area", 0);
  470. int state = RequestString.GetInt("state", -1);
  471. int type = RequestString.GetInt("type", 0);
  472. int source = RequestString.GetInt("source", 0);
  473. string mobile = RequestString.GetQueryString("mobile");
  474. int dbdb = RequestString.GetInt("dbdb", 0);
  475. int db = RequestString.GetInt("db", 0);
  476. string dbusercode = RequestString.GetQueryString("dbusercode");
  477. string strpageindex = RequestString.GetQueryString("page");
  478. string strpagesize = RequestString.GetQueryString("pagesize");
  479. string usercode = RequestString.GetQueryString("usercode");
  480. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  481. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  482. int isRelease = RequestString.GetInt("isRelease", 0);
  483. int name= RequestString.GetInt("name", 0);
  484. int handling = RequestString.GetInt("handling", 0);
  485. int pageindex = 1;
  486. int pagesize = 10;
  487. if (strpageindex.Trim() != "")
  488. {
  489. pageindex = Convert.ToInt32(strpageindex);
  490. }
  491. if (strpagesize.Trim() != "")
  492. {
  493. pagesize = Convert.ToInt32(strpagesize);
  494. }
  495. if (!string .IsNullOrEmpty (usercode))
  496. {
  497. sql += " and F_CreateUser='"+ usercode + "' ";
  498. }
  499. string value = "";
  500. if (string .IsNullOrEmpty (strstarttime)&& string.IsNullOrEmpty(strendtime))
  501. {
  502. if (db > 0 || dbdb>0)
  503. {
  504. DateTime start;
  505. start = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
  506. if (dbdb==5)
  507. {
  508. value += "and datediff(SS ,F_CreateTime,'" + start.ToString("yyyy-MM-dd HH:mm:ss") + "')<=0 ";
  509. value += " and datediff(SS ,F_CreateTime,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')>=0";
  510. }
  511. else
  512. {
  513. value += "and datediff(SS ,SupervisorTime,'" + start.ToString("yyyy-MM-dd HH:mm:ss") + "')<=0 ";
  514. value += " and datediff(SS ,SupervisorTime,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')>=0";
  515. }
  516. }
  517. else
  518. {
  519. if (timetype == 1)
  520. {
  521. sql += "and datediff(DAY ,a.F_CreateTime ,getdate())=0 ";
  522. }
  523. else if (timetype == 2)
  524. {
  525. sql += "and datediff(WEEK ,a.F_CreateTime ,getdate())=0 ";
  526. }
  527. else if (timetype == 4)
  528. {
  529. }
  530. else
  531. {
  532. sql += " and datediff(MONTH ,a.F_CreateTime ,getdate())=0 ";
  533. }
  534. }
  535. }
  536. else
  537. {
  538. if (db>0 || dbdb > 0)
  539. {
  540. if (dbdb == 5)
  541. {
  542. if (!string.IsNullOrEmpty(strstarttime))
  543. {
  544. value += "and datediff(SS ,F_CreateTime,'" + strstarttime + "')<=0 ";
  545. }
  546. if (!string.IsNullOrEmpty(strendtime))
  547. {
  548. value += " and datediff(SS ,F_CreateTime,'" + strendtime + "')>=0";
  549. }
  550. }
  551. else
  552. {
  553. if (!string.IsNullOrEmpty(strstarttime))
  554. {
  555. value += "and datediff(SS ,SupervisorTime,'" + strstarttime + "')<=0 ";
  556. }
  557. if (!string.IsNullOrEmpty(strendtime))
  558. {
  559. value += " and datediff(SS ,SupervisorTime,'" + strendtime + "')>=0";
  560. }
  561. }
  562. }
  563. else
  564. {
  565. if (!string.IsNullOrEmpty(strstarttime))
  566. {
  567. sql += "and datediff(SS ,F_CreateTime,'" + strstarttime + "')<=0 ";
  568. }
  569. if (!string.IsNullOrEmpty(strendtime))
  570. {
  571. sql += " and datediff(SS ,F_CreateTime,'" + strendtime + "')>=0";
  572. }
  573. }
  574. }
  575. if (dbdb>0)
  576. {
  577. 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'";
  578. }
  579. if(db>0)
  580. {
  581. if (!string .IsNullOrEmpty (dbusercode))
  582. {
  583. value += "and Supervisor='" + dbusercode + "'";
  584. }
  585. if (db==1)
  586. {
  587. 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 )";
  588. }
  589. else if (db == 2)
  590. {
  591. sql += " and a.F_WorkOrderID in(select F_WorkOrderID from T_Bus_RemindRecord WITH(NOLOCK) where F_Type= 1 and F_State = 1 " + value + " )";
  592. }
  593. else if (db == 3)
  594. {
  595. sql += " and a.F_WorkOrderID in(select F_WorkOrderID from T_Bus_RemindRecord WITH(NOLOCK) where F_Type= 1 and F_State = 2 " + value + " ) ";
  596. }
  597. else if (db == 4)
  598. {
  599. sql += " and a.F_WorkOrderID in(select F_WorkOrderID from T_Bus_RemindRecord WITH(NOLOCK) where F_Type= 1 " + value + " ) and F_WorkState = '9'";
  600. }
  601. }
  602. if (!string .IsNullOrEmpty (mobile ))
  603. {
  604. sql += "and a.F_CusPhone = '" + mobile + "'";
  605. }
  606. if (area > 0)
  607. {
  608. sql += "and a.F_SourceArea='" + area + "'";
  609. }
  610. if (state>-1)
  611. {
  612. sql += "and a.F_WorkState='" + state + "'";
  613. }
  614. if (type > 0)
  615. {
  616. sql += "and a.F_InfoType='" + type + "'";
  617. }
  618. if (source > 0)
  619. {
  620. sql += "and a.F_InfoSource='" + source + "'";
  621. }
  622. if (isRelease>0)
  623. {
  624. if (isRelease==2)
  625. sql += " and (F_IsRelease =2 or F_IsRelease is null or F_IsRelease ='')";
  626. else
  627. sql += "and F_IsRelease ='"+ isRelease + "'";
  628. }
  629. if (ishf>0)
  630. {
  631. if (string.IsNullOrEmpty(strstarttime) && string.IsNullOrEmpty(strendtime))
  632. {
  633. value += " and datediff(MONTH ,a.F_CreateTime ,getdate())=0 ";
  634. }
  635. else
  636. {
  637. if (!string.IsNullOrEmpty(strstarttime))
  638. {
  639. value += "and datediff(SS ,F_CreateTime,'" + strstarttime + "')<=0 ";
  640. }
  641. }
  642. if (ishf==1)
  643. {
  644. sql += "and F_WorkOrderId in (select F_WorkOrderId from T_Bus_VisitResult WITH(NOLOCK) " +
  645. " where F_IsDelete =0 "+ value + " ) ";
  646. }
  647. else
  648. {
  649. sql += "and F_WorkOrderId not in (select F_WorkOrderId from T_Bus_VisitResult WITH(NOLOCK) " +
  650. "where F_IsDelete =0 " + value + " and F_IsSms !=1 ) ";
  651. }
  652. }
  653. if (handling>0)
  654. {
  655. if (deptid <= 0)
  656. return Error("请选择部门");
  657. if (string.IsNullOrEmpty(strstarttime) && string.IsNullOrEmpty(strendtime))
  658. {
  659. sql += " and datediff(MONTH ,a.F_CreateTime ,getdate())=0 ";
  660. }
  661. sql += "F_MainDeptId='" + deptid + "' and F_IsResult=0";
  662. switch (handling)
  663. {
  664. case 2:
  665. break;
  666. }
  667. }
  668. string cols = "";
  669. string order = "ORDER BY a.F_CreateTime DESC";
  670. if (name >0)
  671. {
  672. cols = "distinct F_CusName";
  673. order = "";
  674. }
  675. else if (db>0)
  676. {
  677. 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";
  678. }
  679. else
  680. {
  681. 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";
  682. }
  683. if (isdc > 0)
  684. {
  685. var top = " "; var orderby = " order by F_CreateTime desc";
  686. if (sql == " and F_IsDelete=0 ")
  687. {
  688. top = " top 1000 "; orderby += " desc ";
  689. }
  690. if (db == 1)
  691. {
  692. var dtdc = DbHelperSQL.Query(" select ROW_NUMBER() OVER(ORDER BY F_CreateTime desc) 编号, F_WorkOrderId 事项单号, dbo.GetDeptNames(F_MainDeptId ) 承办单位, "
  693. + "(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 ) 督办方式"
  694. + " from T_Bus_WorkOrder a WITH(NOLOCK) where 1=1 " + sql + order).Tables[0];
  695. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  696. if (msg == "")
  697. {
  698. return Success("导出成功");
  699. }
  700. else
  701. {
  702. return Error("导出失败");
  703. }
  704. }
  705. else
  706. {
  707. 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) 反映类别, "
  708. + " dbo.GetDeptNames(F_MainDeptId ) 主办单位, "
  709. + " (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) 办理结果, "
  710. + " F_CusName 来电人姓名 ,F_CusPhone 来电人手机号 "
  711. + " from T_Bus_WorkOrder a WITH(NOLOCK) where 1=1 " + sql + orderby).Tables[0];
  712. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  713. if (msg == "")
  714. {
  715. return Success("导出成功");
  716. }
  717. else
  718. {
  719. return Error("导出失败");
  720. }
  721. }
  722. }
  723. else
  724. {
  725. int recordCount = 0;
  726. dt = BLL.PagerBLL.GetListPager(
  727. "T_Bus_WorkOrder a WITH(NOLOCK)",
  728. "a.F_WorkOrderId",
  729. cols,
  730. sql,
  731. order,
  732. pagesize,
  733. pageindex,
  734. true,
  735. out recordCount);
  736. var obj = new
  737. {
  738. state = "success",
  739. message = "成功",
  740. rows = dt,
  741. total = recordCount
  742. };
  743. return Content(obj.ToJson());
  744. }
  745. }
  746. public ActionResult IncomingCalls (string date,int isdc=0)
  747. {
  748. if (string.IsNullOrEmpty(date))
  749. date = DateTime.Now.ToString("yyyy-MM-dd");
  750. var modelcalllist = new BLL
  751. .T_Call_CallRecords().GetModelList(" CallType =0 and DATEDIFF(DAY, BeginTime, '"+ date + "') = 0");
  752. var userlist = new BLL.T_Sys_UserAccount().GetModelList(" F_SeatFlag =1");
  753. int ldcount = 0;int jtcount = 0; int newldcount = 0; int newjtcount = 0;
  754. List<Incoming> incomings = new List<Incoming>();
  755. //incoming.time = "00:00-08:00";
  756. //incoming.IncomingCount = modelcalllist.Where(x => x.BeginTime.Value.Hour >= 0 && x.BeginTime.Value.Hour <= 8
  757. //).Count();
  758. //ldcount += incoming.IncomingCount;
  759. //incoming.Oncapacity = modelcalllist.Where(x => x.BeginTime.Value.Hour >= 0 && x.BeginTime.Value.Hour <= 8
  760. //&&x.CallState ==1 ).Count();
  761. //jtcount += incoming.Oncapacity;
  762. //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
  763. // ();
  764. //if (modelcalllists!=null&& modelcalllists.Count() >0)
  765. //{
  766. // incoming.seatsCount = modelcalllists.Count();
  767. // foreach (var it in modelcalllists)
  768. // {
  769. // var user = userlist.Where(x => x.F_UserCode == it);
  770. // if (user != null && user.Count() > 0)
  771. // incoming.seats += "," + user.FirstOrDefault().F_UserName;
  772. // else
  773. // incoming.seats += "," + it;
  774. // }
  775. // if (!string .IsNullOrEmpty(incoming.seats))
  776. // incoming.seats = incoming.seats.TrimStart(',');
  777. //}
  778. //else
  779. //{
  780. // incoming.seatsCount =0;
  781. // incoming.seats = "";
  782. //}
  783. //incomings.Add(incoming);
  784. int v = 24;
  785. if (DateTime .Parse (date ).Year ==DateTime .Now .Year &&
  786. DateTime.Parse(date).Month == DateTime.Now.Month && DateTime.Parse(date).Day == DateTime.Now.Day)
  787. {
  788. v = DateTime.Now.Hour;
  789. }
  790. for (int i=0;i < v; i ++)
  791. {
  792. Incoming incomin = new Incoming();
  793. int t = i + 1;
  794. string iss=i.ToString () ,tss=t .ToString ();
  795. if (i < 10)
  796. iss = "0" + i;
  797. if (t < 10)
  798. tss = "0" + t;
  799. incomin.time = iss + ":00" + "-" + tss + ":00";
  800. incomin.IncomingCount = modelcalllist.Where(x => x.BeginTime.Value.Hour ==i &&x.PhoneType =="12345"
  801. ).Count();
  802. ldcount += incomin.IncomingCount;
  803. incomin.Oncapacity = modelcalllist.Where(x => x.BeginTime.Value.Hour ==i
  804. && x.CallState == 1 && x.PhoneType == "12345").Count();
  805. jtcount += incomin.Oncapacity;
  806. incomin.newIncomingCount = modelcalllist.Where(x => x.BeginTime.Value.Hour == i && x.PhoneType == "12345"
  807. ).Count();
  808. newldcount += incomin.newIncomingCount;
  809. incomin.newOncapacity = modelcalllist.Where(x => x.BeginTime.Value.Hour == i
  810. && x.CallState == 1 && x.PhoneType == "12345").Count();
  811. newjtcount += incomin.newOncapacity;
  812. var modelcalllistss = modelcalllist.Where(x => x.UserCode != null&& x.UserCode != "" && x.BeginTime.Value.Hour==i&&x.PhoneType =="12345").Select(x => x.UserCode).Distinct
  813. ();
  814. if (modelcalllistss != null && modelcalllistss.Count() > 0)
  815. {
  816. incomin.seatsCount = modelcalllistss.Count();
  817. foreach (var it in modelcalllistss)
  818. {
  819. var user = userlist.Where(x => x.F_UserCode == it);
  820. if (user != null && user.Count() > 0)
  821. incomin.seats += "," + user.FirstOrDefault().F_UserName;
  822. else
  823. incomin.seats += "," + it;
  824. }
  825. if (!string.IsNullOrEmpty(incomin.seats))
  826. incomin.seats= incomin.seats.TrimStart(',');
  827. }
  828. else
  829. {
  830. incomin.seatsCount = 0;
  831. incomin.seats = "";
  832. }
  833. var modelcalllists = modelcalllist.Where(x => x.UserCode != null && x.UserCode != "" && x.BeginTime.Value.Hour == i && x.PhoneType != "12345").Select(x => x.UserCode).Distinct
  834. ();
  835. if (modelcalllists != null && modelcalllists.Count() > 0)
  836. {
  837. incomin.newseatsCount = modelcalllists.Count();
  838. foreach (var it in modelcalllists)
  839. {
  840. var user = userlist.Where(x => x.F_UserCode == it);
  841. if (user != null && user.Count() > 0)
  842. incomin.newseats += "," + user.FirstOrDefault().F_UserName;
  843. else
  844. incomin.newseats += "," + it;
  845. }
  846. if (!string.IsNullOrEmpty(incomin.newseats))
  847. incomin.newseats = incomin.newseats.TrimStart(',');
  848. }
  849. else
  850. {
  851. incomin.newseatsCount = 0;
  852. incomin.newseats = "";
  853. }
  854. incomings.Add(incomin);
  855. }
  856. Incoming incomint = new Incoming();
  857. incomint.time = "共计";
  858. incomint.IncomingCount = ldcount;
  859. incomint.Oncapacity = jtcount;
  860. incomint.newIncomingCount = newldcount;
  861. incomint.newOncapacity = newjtcount;
  862. incomings.Add(incomint);
  863. if (isdc >0)
  864. {
  865. new NPOIHelper().IncomingCalls(incomings);
  866. return Success("导出excel");
  867. }
  868. return Success("获取成功", incomings);
  869. }
  870. /// <summary>
  871. /// 逾期未回复统计
  872. /// </summary>
  873. /// <param name="date"></param>
  874. /// <param name="deptId"></param>
  875. /// <param name="pageIndex"></param>
  876. /// <param name="pageSize"></param>
  877. /// <returns></returns>
  878. public ActionResult GetOutTimeNotApply(DateTime? start, DateTime? end, int deptId = -1, int pageIndex = 1, int pageSize = 10, bool isExport = false)
  879. {
  880. if (start == null)
  881. {
  882. start = DateTime.Now;
  883. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  884. }
  885. if (end == null)
  886. {
  887. end = DateTime.Now;
  888. }
  889. var where = "";
  890. if (deptId > 0)
  891. {
  892. where = " AND F_MainDeptId=" + deptId;
  893. }
  894. 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;
  895. if (isExport)
  896. {
  897. string[] cols = new string[] { "工单编号", "承办单位", "工单内容", "转派时间", "回复时限", "超时时间" };
  898. var dtall = DbHelperSQL.Query("select * from V_Bus_OverNoBack where 1=1 "+sql).Tables[0];
  899. dtall.Columns.Remove("F_MainDeptId");
  900. dtall.Columns.Remove("F_CreateTime");
  901. new NPOIHelper().ExportToExcel($"逾期未回复统计报表{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", dtall, cols);
  902. return Success("导出excel");
  903. }
  904. int recordCount = 0;
  905. var dt = BLL.PagerBLL.GetListPager(
  906. "V_Bus_OverNoBack",
  907. "F_WorkOrderId",
  908. "*",
  909. sql,
  910. "ORDER BY F_CreateTime DESC",
  911. pageSize,
  912. pageIndex,
  913. true,
  914. out recordCount);
  915. var obj = new
  916. {
  917. state = "success",
  918. message = "成功",
  919. rows = dt,
  920. total = recordCount
  921. };
  922. return Content(obj.ToJson());
  923. }
  924. /// <summary>
  925. /// 重办不满意统计
  926. /// </summary>
  927. /// <param name="date"></param>
  928. /// <param name="pageIndex"></param>
  929. /// <param name="pageSize"></param>
  930. /// <returns></returns>
  931. public ActionResult GetNotSatisfied(DateTime? start, DateTime? end, int pageIndex = 1, int pageSize = 10, bool isExport = false)
  932. {
  933. if (start == null)
  934. {
  935. start = DateTime.Now;
  936. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  937. }
  938. if (end == null)
  939. {
  940. end = DateTime.Now;
  941. }
  942. string sql = $" and datediff(day,cjTime,'{start.Value.ToString("yyyy-MM-dd")}')<=0 and datediff(day,cjTime,'{end.Value.ToString("yyyy-MM-dd")}')>=0 ";
  943. if (isExport)
  944. {
  945. string[] cols = new string[] { "工单编号", "承办单位", "工单内容", "创建时间", "处理结果", "处理时间", "回访结果", "回访时间" };
  946. var dtall = DbHelperSQL.Query("select * from V_Bus_ReloadNoSatisfie where 1=1 " + sql + " order by cjTime DESC ").Tables[0];
  947. dtall.Columns.Remove("F_Id");
  948. new NPOIHelper().ExportToExcel($"重办不满意统计报表{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", dtall, cols);
  949. return Success("导出excel");
  950. }
  951. int recordCount = 0;
  952. var dt = BLL.PagerBLL.GetListPager(
  953. "V_Bus_ReloadNoSatisfie",
  954. "F_Id",
  955. "*",
  956. sql,
  957. "ORDER BY cjTime DESC",
  958. pageSize,
  959. pageIndex,
  960. true,
  961. out recordCount);
  962. var obj = new
  963. {
  964. state = "success",
  965. message = "成功",
  966. rows = dt,
  967. total = recordCount
  968. };
  969. return Content(obj.ToJson());
  970. }
  971. /// <summary>
  972. /// 延期统计
  973. /// </summary>
  974. /// <param name="start"></param>
  975. /// <param name="end"></param>
  976. /// <param name="pageIndex"></param>
  977. /// <param name="pageSize"></param>
  978. /// <param name="isExport"></param>
  979. /// <returns></returns>
  980. public ActionResult GetDelay(DateTime? start, DateTime? end, bool isExport = false)
  981. {
  982. if (start == null)
  983. {
  984. start = DateTime.Now;
  985. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  986. }
  987. if (end == null)
  988. {
  989. end = DateTime.Now;
  990. }
  991. Dictionary<string, string> paras = new Dictionary<string, string>();
  992. paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
  993. paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
  994. var obj = DbHelperSQL.RunProcedure("P_DeptDelayReport", paras, "DeptDelayReport");
  995. if (isExport)
  996. {
  997. string[] cols = new string[] { "单位名称", "办理数量", "延时数量", "延时率" };
  998. NPOIHelper npoi = new NPOIHelper();
  999. if (npoi.ExportToExcel("延时分析统计报表", obj.Tables[0], cols) == "")
  1000. {
  1001. return Success("导出成功");
  1002. }
  1003. else
  1004. {
  1005. return Error("导出失败");
  1006. }
  1007. }
  1008. return Success("成功", obj);
  1009. }
  1010. /// <summary>
  1011. /// 通报批评
  1012. /// </summary>
  1013. /// <param name="start"></param>
  1014. /// <param name="end"></param>
  1015. /// <param name="pageIndex"></param>
  1016. /// <param name="pageSize"></param>
  1017. /// <param name="isExport"></param>
  1018. /// <returns></returns>
  1019. public ActionResult GetNotice(DateTime? start, DateTime? end, bool isExport = false)
  1020. {
  1021. if (start == null)
  1022. {
  1023. start = DateTime.Now;
  1024. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  1025. }
  1026. if (end == null)
  1027. {
  1028. end = DateTime.Now;
  1029. }
  1030. //string sql = "select * from dbo.GetNoticeReport('"+ start.Value.ToString("yyyy-MM-dd") + "','" + end.Value.ToString("yyyy-MM-dd") + "') ORDER BY zbcount+xbcount DESC";
  1031. //var dt = DbHelperSQL.Query(sql).Tables[0];
  1032. Dictionary<string, string> paras = new Dictionary<string, string>();
  1033. paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
  1034. paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
  1035. var obj = DbHelperSQL.RunProcedure("P_DeptNoticeReport", paras, "DeptNoticeReport");
  1036. if (isExport)
  1037. {
  1038. var cols = new string[] { "承办单位", "主办受理数量", "主办通报批评数量", "主办通报批评率", "协办受理数量", "协办通报批评数量", "协办通报批评率" };
  1039. new NPOIHelper().ExportToExcel($"通报批评{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
  1040. return Success("导出excel");
  1041. }
  1042. return Success("成功", obj);
  1043. }
  1044. /// <summary>
  1045. /// 诉求受理对比
  1046. /// </summary>
  1047. /// <returns></returns>
  1048. public ActionResult GetAppeal1(DateTime? start, DateTime? end, bool isExport = false)
  1049. {
  1050. if (start == null)
  1051. {
  1052. start = DateTime.Now;
  1053. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  1054. }
  1055. if (end == null)
  1056. {
  1057. end = DateTime.Now;
  1058. }
  1059. Dictionary<string, string> paras = new Dictionary<string, string>();
  1060. paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
  1061. paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
  1062. var obj = DbHelperSQL.RunProcedure("P_UserAppealReport", paras, "UserAppealReport");
  1063. if (isExport)
  1064. {
  1065. var cols = new string[] { "坐席名称", "受理数量", "上月同期受理数量", "上月同期环比", "去年同期受理数量", "去年同期同比" };
  1066. new NPOIHelper().ExportToExcel($"诉求受理对比{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
  1067. return Success("导出excel");
  1068. }
  1069. return Success("成功", obj);
  1070. }
  1071. public ActionResult GetAppeal(DateTime? start, DateTime? end, bool isExport = false
  1072. , string source = "")
  1073. {
  1074. if (start == null)
  1075. {
  1076. start = DateTime.Now;
  1077. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  1078. }
  1079. if (end == null)
  1080. {
  1081. end = DateTime.Now;
  1082. }
  1083. Dictionary<string, string> paras = new Dictionary<string, string>();
  1084. paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
  1085. paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
  1086. paras.Add("@source", source);
  1087. var obj = DbHelperSQL.RunProcedure("P_UserAppealReport_1", paras, "UserAppealReport");
  1088. var newSet = new DataSet();var newtable = new DataTable("UserAppealReport");
  1089. #region
  1090. newtable.Columns.Add(new DataColumn("username"));
  1091. newtable.Columns.Add(new DataColumn("count", typeof(int)));
  1092. newtable.Columns.Add(new DataColumn("mcount", typeof(int)));
  1093. newtable.Columns.Add(new DataColumn("mom"));
  1094. newtable.Columns.Add(new DataColumn("ycount", typeof(int)));
  1095. newtable.Columns.Add(new DataColumn("yoy"));
  1096. #endregion
  1097. if (obj != null && obj.Tables[0] != null && obj.Tables[0].Rows.Count > 0)
  1098. {
  1099. for (int i = 0; i < obj.Tables[0].Rows.Count; i++)
  1100. {
  1101. int count = 0, mcount = 0, ycount = 0; double mom = 0, yoy = 0;
  1102. int.TryParse(obj.Tables[0].Rows[i]["count"].ToString(), out count);
  1103. int.TryParse(obj.Tables[0].Rows[i]["mcount"].ToString(), out mcount);
  1104. int.TryParse(obj.Tables[0].Rows[i]["ycount"].ToString(), out ycount);
  1105. if(mcount>0)
  1106. mom = double.Parse((count * 100).ToString()) / mcount;
  1107. if (ycount > 0)
  1108. yoy = double.Parse((count * 100).ToString()) / ycount;
  1109. #region
  1110. DataRow drNew = newtable.NewRow();
  1111. drNew["username"] = obj.Tables[0].Rows[i]["username"];
  1112. drNew["count"] = count;
  1113. drNew["mcount"] = mcount;
  1114. drNew["mom"] = mom > 0 ? mom.ToString("f") + "%" : "0";
  1115. drNew["ycount"] = ycount;
  1116. drNew["yoy"] = yoy > 0 ? yoy.ToString("f") + "%" : "0";
  1117. newtable.Rows.Add(drNew);
  1118. #endregion
  1119. }
  1120. newtable.DefaultView.Sort = "count desc";
  1121. newSet.Tables.Add(newtable.DefaultView.ToTable());
  1122. }
  1123. if (isExport)
  1124. {
  1125. var cols = new string[] { "坐席名称", "受理数量", "上月同期受理数量", "上月同期环比", "去年同期受理数量", "去年同期同比" };
  1126. new NPOIHelper().ExportToExcel($"诉求受理对比{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", newSet.Tables[0], cols);
  1127. return Success("导出excel");
  1128. }
  1129. return Success("成功", newSet);
  1130. }
  1131. /// <summary>
  1132. /// 获取督办报表
  1133. /// </summary>
  1134. /// <returns></returns>
  1135. public ActionResult GetDBReportform(string starttime,string endtime)
  1136. {
  1137. if (string .IsNullOrEmpty (starttime))
  1138. {
  1139. starttime = DateTime.Now.ToString("yyyy-MM") + "-01 00:00:00";
  1140. endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1141. }
  1142. else
  1143. {
  1144. if (string.IsNullOrEmpty(endtime))
  1145. {
  1146. endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1147. }
  1148. }
  1149. Dictionary<string, string> paras = new Dictionary<string, string>();
  1150. paras.Add("@sdate", starttime);
  1151. paras.Add("@edate", endtime);
  1152. var obj1 = DbHelperSQL.RunProcedure("P_DBReportform_1", paras, "DBReportform").Tables[0];
  1153. 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 +
  1154. "' AND '" + endtime + "')) and F_WorkState !='9'and F_IsDelete =0 ";
  1155. DataTable dttype = DbHelperSQL.Query(sqlarea).Tables[0];
  1156. var obj = new
  1157. {
  1158. obj1,
  1159. total = dttype
  1160. };
  1161. return Content(obj.ToJson());
  1162. }
  1163. /// <summary>
  1164. /// 坐席状态统计
  1165. /// </summary>
  1166. /// <param name="starttime"></param>
  1167. /// <param name="endtime"></param>
  1168. /// <returns></returns>
  1169. public ActionResult GetZuoXiState(string starttime, string endtime)
  1170. {
  1171. if (string.IsNullOrEmpty(starttime))
  1172. {
  1173. starttime = DateTime.Now.ToString("yyyy-MM") + "-01 00:00:00";
  1174. endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1175. }
  1176. else
  1177. {
  1178. if (string.IsNullOrEmpty(endtime))
  1179. {
  1180. endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1181. }
  1182. }
  1183. string sql = " a.OccurTime between '" + starttime + "' AND '" + endtime + "'";
  1184. string value = " TimeLogin between '" + starttime + "' AND '" + endtime + "'";
  1185. string value1 = " TimeLogout between '" + starttime + "' AND '" + endtime + "'";
  1186. 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" +
  1187. " 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 ";
  1188. DataTable obj = DbHelperSQL.Query(sqlarea).Tables[0];
  1189. return Content(obj.ToJson());
  1190. }
  1191. /// <summary>
  1192. /// 坐席时间
  1193. /// </summary>
  1194. /// <param name="starttime"></param>
  1195. /// <param name="endtime"></param>
  1196. /// <returns></returns>
  1197. public ActionResult GetZuoXiTime (string starttime, string endtime,string usercode,int state=0)
  1198. {
  1199. if (string.IsNullOrEmpty(starttime))
  1200. {
  1201. starttime = DateTime.Now.ToString("yyyy-MM") + "-01 00:00:00";
  1202. endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1203. }
  1204. else
  1205. {
  1206. if (string.IsNullOrEmpty(endtime))
  1207. {
  1208. endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1209. }
  1210. }
  1211. if (string.IsNullOrEmpty(usercode))
  1212. return Error("请选择坐席");
  1213. string sqlzuoxi = "";
  1214. if (state==0)
  1215. {
  1216. sqlzuoxi = "select TimeLogin from rep_agent_detail where TimeLogin between '" + starttime + "' AND '" + endtime + "' and AgentId ='" + usercode + "'and TimeLogin is not null ";
  1217. }
  1218. else if (state == 1)
  1219. {
  1220. sqlzuoxi = "select TimeLogout from rep_agent_detail where TimeLogout between '" + starttime + "' AND '" + endtime + "' and AgentId ='" + usercode + "' and TimeLogout is not null ";
  1221. }
  1222. else if (state == 2)
  1223. {
  1224. sqlzuoxi = "select OccurTime from rep_agent_state where OccurTime between '" + starttime + "' AND '" + endtime + "' and AgentId ='" + usercode + "' and State = 2 ";
  1225. }
  1226. else if (state == 3)
  1227. {
  1228. sqlzuoxi = "select OccurTime from rep_agent_state where OccurTime between '" + starttime + "' AND '" + endtime + "' and AgentId ='" + usercode + "' and State = 5 ";
  1229. }
  1230. DataTable obj = DbHelperSQL.Query(sqlzuoxi).Tables[0];
  1231. return Content(obj.ToJson());
  1232. }
  1233. /// <summary>
  1234. /// 获取绩效
  1235. /// </summary>
  1236. /// <param name="date"></param>
  1237. /// <param name="isdc"></param>
  1238. /// <returns></returns>
  1239. public ActionResult GetEvaluation(string date, int deptid = 0,int isdc=0)
  1240. {
  1241. string sql = "F_IsDelete=0";
  1242. string message = "";string datemessage = "";
  1243. if (!string.IsNullOrEmpty(date))
  1244. {
  1245. message = "统计周期:" + DateTime.Parse(date).AddMonths(-1).ToString("yyyy年MM月") + "-25日--" + DateTime.Parse(date).ToString("yyyy年MM月") + "-24日";
  1246. datemessage = MonthtoUpper(DateTime.Parse(date).Month );
  1247. date = DateTime.Parse(date).ToString("yyyyMM");
  1248. }
  1249. else
  1250. {
  1251. message = "统计周期:" + DateTime.Now.AddMonths(-1).ToString("yyyy年MM月") + "-25日--" + DateTime.Now.ToString("yyyy年MM月") + "-24日";
  1252. date = DateTime .Now.AddMonths (-1).ToString("yyyyMM");
  1253. datemessage = MonthtoUpper(DateTime.Now .Month);
  1254. }
  1255. sql += "and F_Date='" + date + "'";
  1256. if (deptid>0)
  1257. {
  1258. sql += "and F_Deptid='" + deptid + "'";
  1259. }
  1260. if (isdc>0)
  1261. {
  1262. var dtdc = DbHelperSQL.Query(" select * from T_Sys_Evaluation a WITH(NOLOCK) where " + sql+ " " +
  1263. " and F_Undertake>0 and F_Deptid in (select F_DeptId from T_Sys_Department " +
  1264. "where F_DeptId in (SELECT F_DeptId FROM dbo.[GetDaptiD](155) where F_IsDept = 1) " +
  1265. "and F_PartentId =155 and F_IsDealDept = 1 and F_DeptName not like '%测试%') order by F_Total desc").Tables[0];
  1266. var dtdc1 = DbHelperSQL.Query(" select * from T_Sys_Evaluation a WITH(NOLOCK) where " + sql + " " +
  1267. "and F_Undertake>0 and F_Deptid in (select F_DeptId from T_Sys_Department " +
  1268. "where F_DeptId in (SELECT F_DeptId FROM dbo.[GetDaptiD](155) where F_IsDept = 1) " +
  1269. "and F_PartentId in(167, 169,170) and F_IsDealDept = 1 and F_DeptName not like '%测试%') order by F_Total desc").Tables[0];
  1270. var dtdc2 = DbHelperSQL.Query(" select * from T_Sys_Evaluation a WITH(NOLOCK) where " + sql + " " +
  1271. " and F_Undertake>0 and F_Deptid in (select F_DeptId from T_Sys_Department " +
  1272. "where F_DeptId in (SELECT F_DeptId FROM dbo.[GetDaptiD](155) where F_IsDept = 1) " +
  1273. "and F_PartentId in(171, 172) and F_IsDealDept = 1 and F_DeptName not like '%测试%') order by F_Total desc").Tables[0];
  1274. var dtdc3 = DbHelperSQL.Query(" select * from T_Sys_Evaluation a WITH(NOLOCK) where " + sql + " " +
  1275. " and F_Undertake=0 order by F_Total desc").Tables[0];
  1276. var msg = new NPOIHelper().ExportEvaluation ( dtdc, dtdc1, dtdc2, dtdc3, message, datemessage);
  1277. if (msg == "")
  1278. {
  1279. return Success("导出成功");
  1280. }
  1281. else
  1282. {
  1283. return Error("导出失败");
  1284. }
  1285. }
  1286. else
  1287. {
  1288. string Evaluation = "select * from T_Sys_Evaluation where " + sql + "order by F_Total desc ";
  1289. DataTable obj = DbHelperSQL.Query(Evaluation).Tables[0];
  1290. return Content(obj.ToJson());
  1291. }
  1292. }
  1293. private static string MonthtoUpper(int month)
  1294. {
  1295. if (month < 10)
  1296. {
  1297. return NumtoUpper(month) ;
  1298. }
  1299. else
  1300. if (month == 10) { return "十" ; }
  1301. else
  1302. {
  1303. return "十" + NumtoUpper(month - 10) ;
  1304. }
  1305. }
  1306. private static string NumtoUpper(int num)
  1307. {
  1308. String str = num.ToString();
  1309. string rstr = "";
  1310. int n;
  1311. for (int i = 0; i < str.Length; i++)
  1312. {
  1313. n = Convert.ToInt16(str[i].ToString());//char转数字,转换为字符串,再转数字
  1314. switch (n)
  1315. {
  1316. case 0: rstr = rstr + "〇"; break;
  1317. case 1: rstr = rstr + "一"; break;
  1318. case 2: rstr = rstr + "二"; break;
  1319. case 3: rstr = rstr + "三"; break;
  1320. case 4: rstr = rstr + "四"; break;
  1321. case 5: rstr = rstr + "五"; break;
  1322. case 6: rstr = rstr + "六"; break;
  1323. case 7: rstr = rstr + "七"; break;
  1324. case 8: rstr = rstr + "八"; break;
  1325. default: rstr = rstr + "九"; break;
  1326. }
  1327. }
  1328. return rstr;
  1329. }
  1330. /// <summary>
  1331. /// 获取绩效
  1332. /// </summary>
  1333. /// <param name="date"></param>
  1334. /// <param name="isdc"></param>
  1335. /// <returns></returns>
  1336. public ActionResult GetDeptDeptAchievements(string starttime, string endtime
  1337. , int type=0,int deptid=0)
  1338. {
  1339. if (string.IsNullOrEmpty(starttime))
  1340. {
  1341. starttime = DateTime.Now.AddMonths (-1).ToString("yyyy-MM") + "-21 00:00:00";
  1342. endtime = DateTime.Now.ToString("yyyy-MM") + "-20 00:00:00";
  1343. }
  1344. else
  1345. {
  1346. if (string.IsNullOrEmpty(endtime))
  1347. {
  1348. endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1349. }
  1350. }
  1351. Dictionary<string, string> paras = new Dictionary<string, string>();
  1352. paras.Add("@sdate", starttime);
  1353. paras.Add("@edate", endtime);
  1354. paras.Add("@type", type.ToString ());
  1355. if (deptid>0)
  1356. paras.Add("@deptid", deptid.ToString ());
  1357. else
  1358. paras.Add("@deptid","");
  1359. var obj = DbHelperSQL.RunProcedure("P_DeptAchievements_1", paras, "DeptAchievements").Tables[0]; ;
  1360. return Content(obj.ToJson());
  1361. }
  1362. /// <summary>
  1363. /// 工单周报
  1364. /// 暂时无用,多主办单位不处理
  1365. /// </summary>
  1366. /// <param name="start"></param>
  1367. /// <param name="end"></param>
  1368. /// <param name="type"></param>
  1369. /// <param name="pageIndex"></param>
  1370. /// <param name="pageSize"></param>
  1371. /// <returns></returns>
  1372. public ActionResult GetWeaklyReport(DateTime? start, DateTime? end, int type = 0, int dateType = 0, int pageIndex = 1, int pageSize = 10, bool isExport = false)
  1373. {
  1374. StringBuilder sb1 = new StringBuilder();
  1375. StringBuilder sb2 = new StringBuilder();
  1376. StringBuilder sb3 = new StringBuilder();
  1377. var startDate = new DateTime();
  1378. var endDate = new DateTime();
  1379. var lastStartDate = new DateTime();
  1380. var lastEndDate = new DateTime();
  1381. var differ = 0;
  1382. var str = "";
  1383. switch (dateType)
  1384. {
  1385. //日
  1386. case 1:
  1387. if (start == null)
  1388. {
  1389. start = DateTime.Now.Date;
  1390. }
  1391. if (end == null)
  1392. {
  1393. end = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  1394. }
  1395. startDate = Convert.ToDateTime(start);
  1396. endDate = Convert.ToDateTime(end).AddDays(1).AddSeconds(-1);
  1397. differ = (endDate - startDate).Days + 1;
  1398. lastStartDate = startDate.AddDays(-differ);
  1399. lastEndDate = endDate.AddDays(-differ);
  1400. str = "日";
  1401. break;
  1402. //周
  1403. case 2:
  1404. if (start == null)
  1405. {
  1406. start = DateTime.Now.Date;
  1407. }
  1408. if (end == null)
  1409. {
  1410. end = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  1411. }
  1412. startDate = Convert.ToDateTime(start);
  1413. endDate = Convert.ToDateTime(end);
  1414. differ = 7 - (int)startDate.DayOfWeek;
  1415. startDate = DateTools.GetWeekFirstDayMon((DateTime)start);
  1416. endDate = DateTools.GetWeekLastDaySun((DateTime)end).AddDays(1).AddSeconds(-1);
  1417. differ = (endDate - startDate).Days + 1;
  1418. lastStartDate = DateTools.GetWeekFirstDayMon(startDate.AddDays(-1));
  1419. lastEndDate = DateTools.GetWeekLastDaySun(lastStartDate).AddDays(1).AddSeconds(-1);
  1420. str = "周";
  1421. break;
  1422. //月
  1423. case 3:
  1424. if (start == null)
  1425. {
  1426. start = DateTime.Now.Date;
  1427. }
  1428. if (end == null)
  1429. {
  1430. end = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  1431. }
  1432. startDate = Convert.ToDateTime(start);
  1433. endDate = Convert.ToDateTime(end);
  1434. differ = startDate.Day;
  1435. startDate = startDate.AddDays(-differ + 1);
  1436. endDate = endDate.AddDays(DateTime.DaysInMonth(startDate.Year, startDate.Month) - differ).AddDays(1).AddSeconds(-1);
  1437. //differ = (endDate - startDate). + 1;
  1438. lastStartDate = startDate.AddMonths(-1);
  1439. lastEndDate = lastStartDate.AddDays(DateTime.DaysInMonth(lastStartDate.Year, lastStartDate.Month) - 1).AddDays(1).AddSeconds(-1);
  1440. str = "月";
  1441. break;
  1442. default:
  1443. break;
  1444. }
  1445. //type 查询类型 type=1 按区域;type=2 按部门; type=3 按工单类型
  1446. switch (type)
  1447. {
  1448. case 1:
  1449. var areaList = areaBLL.DataTableToList(areaBLL.GetList(" F_State=0 ").Tables[0]);
  1450. 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]);
  1451. 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]);
  1452. List<DeptWeaklyReportDto> areaWeaklyReportDtoList = new List<DeptWeaklyReportDto>();
  1453. areaList.ForEach(x =>
  1454. {
  1455. var query = areaList1.Where(y => x.F_AreaId == y.FieldId).ToList();
  1456. var assignedCount = query.Count();
  1457. var lastAssignedcount = areaList2.Where(y => x.F_AreaId == y.FieldId).Count();
  1458. var countRate = lastAssignedcount == 0 ? "0%" : assignedCount == 0 ? "0%" : ((double)assignedCount / lastAssignedcount * 100).ToString("f2") + "%";
  1459. var completedCount = query.Where(y => y.WorkOrderState == 9).Count();
  1460. var completedRate = assignedCount == 0 ? "0%" : completedCount == 0 ? "0%" : ((double)completedCount / assignedCount * 100).ToString("f2") + "%";
  1461. areaWeaklyReportDtoList.Add(new DeptWeaklyReportDto
  1462. {
  1463. name = x.F_AreaName,
  1464. assignedcount = assignedCount,
  1465. countrate = countRate,
  1466. completedcount = completedCount,
  1467. completedrate = completedRate
  1468. });
  1469. });
  1470. if (isExport)
  1471. {
  1472. var dt = areaWeaklyReportDtoList.ToDataTable(new string[] { "name", "assignedcount", "countrate", "completedcount", "completedrate" });
  1473. new NPOIHelper().ExportToExcel($"按区域{str}报表{Convert.ToDateTime(startDate).ToString("yyyyMMdd")}-{Convert.ToDateTime(endDate).ToString("yyyyMMdd")}", dt, new string[] { "区域", "受理数量", "数量同比", "办结数量", "办结率" });
  1474. return Success("导出excel");
  1475. }
  1476. return Content(new
  1477. {
  1478. rows = areaWeaklyReportDtoList.Skip((pageIndex - 1) * pageSize).Take(pageSize),
  1479. total = areaWeaklyReportDtoList.Count
  1480. }.ToJson());
  1481. case 2:
  1482. var deptList = departmentBLL.DataTableToList(departmentBLL.GetList(" F_State=0 AND F_DeptNameSpell=3 ").Tables[0]);
  1483. 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
  1484. 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
  1485. List<DeptWeaklyReportDto> deptWeaklyReportDtoList = new List<DeptWeaklyReportDto>();
  1486. deptList.ForEach(x =>
  1487. {
  1488. var query = deptList1.Where(y => y.FieldId!=null && y.FieldId.Split(',').Contains(x.F_DeptId.ToString())).ToList();
  1489. //var query = deptList1.Where(y => y.FieldId == x.F_DeptId).ToList();
  1490. var assignedCount = query.Count();
  1491. var lastAssignedcount = deptList2.Where(y => y.FieldId != null && y.FieldId.Split(',').Contains(x.F_DeptId.ToString())).Count();
  1492. //var lastAssignedcount = deptList2.Where(y => y.FieldId == x.F_DeptId).Count();
  1493. var countRate = lastAssignedcount == 0 ? "0%" : assignedCount == 0 ? "0%" : ((double)assignedCount / lastAssignedcount * 100).ToString("f2") + "%";
  1494. var completedCount = query.Where(y => y.WorkOrderState == 9).Count();
  1495. var completedRate = assignedCount == 0 ? "0%" : completedCount == 0 ? "0%" : ((double)completedCount / assignedCount * 100).ToString("f2") + "%";
  1496. deptWeaklyReportDtoList.Add(new DeptWeaklyReportDto
  1497. {
  1498. name = x.F_DeptName,
  1499. assignedcount = assignedCount,
  1500. countrate = countRate,
  1501. completedcount = completedCount,
  1502. completedrate = completedRate
  1503. });
  1504. });
  1505. if (isExport)
  1506. {
  1507. var dt = deptWeaklyReportDtoList.ToDataTable(new string[] { "name", "assignedcount", "countrate", "completedcount", "completedrate" });
  1508. new NPOIHelper().ExportToExcel($"按单位{str}报表{Convert.ToDateTime(startDate).ToString("yyyyMMdd")}-{Convert.ToDateTime(endDate).ToString("yyyyMMdd")}", dt, new string[] { "单位", "受理数量", "数量同比", "办结数量", "办结率" });
  1509. return Success("导出excel");
  1510. }
  1511. return Content(new
  1512. {
  1513. rows = deptWeaklyReportDtoList.Skip((pageIndex - 1) * pageSize).Take(pageSize),
  1514. total = deptWeaklyReportDtoList.Count
  1515. }.ToJson());
  1516. case 3:
  1517. var typeList = dictValueBLL.DataTableToList(dictValueBLL.GetList(" F_State=0 and F_ItemId=2 ").Tables[0]);
  1518. 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]);
  1519. 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]);
  1520. List<DeptWeaklyReportDto> typeWeaklyReportDtoList = new List<DeptWeaklyReportDto>();
  1521. typeList.ForEach(x =>
  1522. {
  1523. var query = typeList1.Where(y => y.FieldId == x.F_ValueId);
  1524. var assignedCount = query.Count();
  1525. var lastAssignedcount = typeList2.Where(y => y.FieldId == x.F_ValueId).Count();
  1526. var countRate = lastAssignedcount == 0 ? "0%" : assignedCount == 0 ? "0%" : ((double)assignedCount / lastAssignedcount * 100).ToString("f2") + "%";
  1527. var completedCount = query.Where(y => y.WorkOrderState == 9).Count();
  1528. var completedRate = assignedCount == 0 ? "0%" : completedCount == 0 ? "0%" : ((double)completedCount / assignedCount * 100).ToString("f2") + "%";
  1529. typeWeaklyReportDtoList.Add(new DeptWeaklyReportDto
  1530. {
  1531. name = x.F_Value,
  1532. assignedcount = assignedCount,
  1533. countrate = countRate,
  1534. completedcount = completedCount,
  1535. completedrate = completedRate
  1536. });
  1537. });
  1538. if (isExport)
  1539. {
  1540. var dt = typeWeaklyReportDtoList.ToDataTable(new string[] { "name", "assignedcount", "countrate", "completedcount", "completedrate" });
  1541. new NPOIHelper().ExportToExcel($"按工单类型{str}报表{Convert.ToDateTime(startDate).ToString("yyyyMMdd")}-{Convert.ToDateTime(endDate).ToString("yyyyMMdd")}", dt, new string[] { "工单类型", "受理数量", "数量同比", "办结数量", "办结率" });
  1542. return Success("导出excel");
  1543. }
  1544. return Content(new
  1545. {
  1546. rows = typeWeaklyReportDtoList.Skip((pageIndex - 1) * pageSize).Take(pageSize),
  1547. total = typeWeaklyReportDtoList.Count
  1548. }.ToJson());
  1549. case 4:
  1550. var sourceList = dictValueBLL.DataTableToList(dictValueBLL.GetList(" F_State = 0 and F_ItemId = 1").Tables[0]);
  1551. 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]);
  1552. 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]);
  1553. List<DeptWeaklyReportDto> sourceWeaklyReportDtoList = new List<DeptWeaklyReportDto>();
  1554. sourceList.ForEach(x =>
  1555. {
  1556. var query = sourceList1.Where(y => y.FieldId == x.F_ValueId).ToList();
  1557. var assignedCount = query.Count();
  1558. var lastAssignedcount = sourceList2.Where(y => y.FieldId == x.F_ValueId).Count();
  1559. var countRate = lastAssignedcount == 0 ? "0%" : assignedCount == 0 ? "0%" : ((double)assignedCount / lastAssignedcount * 100).ToString("f2") + "%";
  1560. var completedCount = query.Where(y => y.WorkOrderState == 9).Count();
  1561. var completedRate = assignedCount == 0 ? "0%" : completedCount == 0 ? "0%" : ((double)completedCount / assignedCount * 100).ToString("f2") + "%";
  1562. sourceWeaklyReportDtoList.Add(new DeptWeaklyReportDto
  1563. {
  1564. name = x.F_Value,
  1565. assignedcount = assignedCount,
  1566. countrate = countRate,
  1567. completedcount = completedCount,
  1568. completedrate = completedRate
  1569. });
  1570. });
  1571. if (isExport)
  1572. {
  1573. var dt = sourceWeaklyReportDtoList.ToDataTable(new string[] { "name", "assignedcount", "countrate", "completedcount", "completedrate" });
  1574. new NPOIHelper().ExportToExcel($"按工单来源{str}报表{Convert.ToDateTime(startDate).ToString("yyyyMMdd")}-{Convert.ToDateTime(endDate).ToString("yyyyMMdd")}", dt, new string[] { "工单来源", "受理数量", "数量同比", "办结数量", "办结率" });
  1575. return Success("导出excel");
  1576. }
  1577. return Content(new
  1578. {
  1579. rows = sourceWeaklyReportDtoList.Skip((pageIndex - 1) * pageSize).Take(pageSize),
  1580. total = sourceWeaklyReportDtoList.Count
  1581. }.ToJson());
  1582. default:
  1583. return Error("参数错误");
  1584. }
  1585. }
  1586. /// <summary>
  1587. /// 工单日周月报
  1588. /// </summary>
  1589. /// <param name="start"></param>
  1590. /// <param name="end"></param>
  1591. /// <param name="type"></param>
  1592. /// <param name="pageIndex"></param>
  1593. /// <param name="pageSize"></param>
  1594. /// <returns></returns>
  1595. public ActionResult GetDayWeekMonthReport(DateTime? date, int type = 0, int dateType = 0, bool isExport = false,string source="")
  1596. {
  1597. if (date == null)
  1598. {
  1599. date = DateTime.Now.Date;
  1600. }
  1601. Dictionary<string, string> paras = new Dictionary<string, string>();
  1602. paras.Add("@date", date.Value.ToString("yyyy-MM-dd"));
  1603. paras.Add("@datatype", type.ToString());
  1604. paras.Add("@datetype", dateType.ToString());
  1605. paras.Add("@source", source);
  1606. var obj = DbHelperSQL.RunProcedure("P_DayWeekMonthReport", paras, "DayWeekMonthReport");
  1607. if (isExport)
  1608. {
  1609. var cols = new string[] { "名称", "受理数量", "数量同比", "结案数量", "结案率" };
  1610. var start = obj.Tables[1].Rows[0]["startdate"].ToString();
  1611. var end = obj.Tables[1].Rows[0]["enddate"].ToString();
  1612. new NPOIHelper().ExportToExcel($"工单报表{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
  1613. return Success("导出excel");
  1614. }
  1615. return Success("成功", obj);
  1616. }
  1617. /// <summary>
  1618. /// 电话中心受话情况统计表
  1619. /// </summary>
  1620. /// <param name="starttime/"></param>
  1621. /// <param name="endtime"></param>
  1622. /// <param name="usercode"></param>
  1623. /// <param name="group"></param>
  1624. /// <param name="isExport"></param>
  1625. /// <returns></returns>
  1626. public ActionResult CenterReception(DateTime? starttime, DateTime? endtime,string usercode="",string group="",
  1627. bool isExport = false)
  1628. {
  1629. DateTime date = DateTime.Now;
  1630. if (starttime == null)
  1631. {
  1632. starttime = new DateTime(date.Year, date.Month, 1);
  1633. }
  1634. if (endtime == null)
  1635. {
  1636. endtime = DateTime.Now;
  1637. }
  1638. Dictionary<string, string> paras = new Dictionary<string, string>();
  1639. paras.Add("@sdate", starttime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  1640. paras.Add("@edate", endtime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  1641. paras.Add("@usercode", usercode);
  1642. paras.Add("@group", group);
  1643. var obj = DbHelperSQL.RunProcedure("P_CenterReception", paras, "CenterReception");
  1644. if (isExport)
  1645. {
  1646. string message = new NPOIHelper().CenterReception(obj);
  1647. if (message == "")
  1648. return Success("导出excel");
  1649. else
  1650. return Error(message);
  1651. }
  1652. return Success("成功", obj);
  1653. }
  1654. /// <summary>
  1655. /// 局委办件统计
  1656. /// </summary>
  1657. /// <param name="starttime"></param>
  1658. /// <param name="endtime"></param>
  1659. /// <param name="deptid"></param>
  1660. /// <param name="source"></param>
  1661. /// <param name="isExport"></param>
  1662. /// <returns></returns>
  1663. public ActionResult BureauHandling(DateTime? starttime, DateTime? endtime,int deptid =0, int source=0, bool isExport = false)
  1664. {
  1665. DateTime date = DateTime.Now;
  1666. if (starttime == null)
  1667. {
  1668. starttime = new DateTime(date.Year, date.Month, 1);
  1669. }
  1670. if (endtime == null)
  1671. {
  1672. endtime = DateTime.Now;
  1673. }
  1674. string dept = "";
  1675. if (deptid>0)
  1676. dept= deptid.ToString();
  1677. string infosource = "";
  1678. if (source > 0)
  1679. infosource = source.ToString();
  1680. Dictionary<string, string> paras = new Dictionary<string, string>();
  1681. paras.Add("@sdate", starttime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  1682. paras.Add("@edate", endtime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  1683. paras.Add("@deptid", dept);
  1684. paras.Add("@source", infosource);
  1685. var obj = DbHelperSQL.RunProcedure("P_DeptBureauHandling", paras, "DeptBureauHandling");
  1686. if (isExport)
  1687. {
  1688. string message = new NPOIHelper().BureauHandling(obj);
  1689. if (message == "")
  1690. return Success("导出excel");
  1691. else
  1692. return Error(message);
  1693. }
  1694. return Success("成功", obj);
  1695. }
  1696. /// <summary>
  1697. /// 局委评议统计
  1698. /// </summary>
  1699. /// <param name="starttime"></param>
  1700. /// <param name="endtime"></param>
  1701. /// <param name="deptid"></param>
  1702. /// <param name="source"></param>
  1703. /// <param name="isExport"></param>
  1704. /// <returns></returns>
  1705. public ActionResult DeptReview(DateTime? starttime, DateTime? endtime, int deptid = 0, int source = 0, bool isExport = false)
  1706. {
  1707. DateTime date = DateTime.Now;
  1708. if (starttime == null)
  1709. {
  1710. starttime = new DateTime(date.Year, date.Month, 1);
  1711. }
  1712. if (endtime == null)
  1713. {
  1714. endtime = DateTime.Now;
  1715. }
  1716. string dept = "";
  1717. if (deptid > 0)
  1718. dept = deptid.ToString();
  1719. string infosource = "";
  1720. if (source > 0)
  1721. infosource = source.ToString();
  1722. Dictionary<string, string> paras = new Dictionary<string, string>();
  1723. paras.Add("@sdate", starttime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  1724. paras.Add("@edate", endtime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  1725. paras.Add("@deptid", dept);
  1726. paras.Add("@source", infosource);
  1727. var obj = DbHelperSQL.RunProcedure("P_DeptReview", paras, "DeptReview");
  1728. if (isExport)
  1729. {
  1730. var cols = new string[] { "序号", "承办单位", "办件总数", "评议率", "评议总数", "一次评议满意", "一次评议不满意"
  1731. , "一次评议满意率", "二次评议满意", "二次评议不满意", "二级评议满意率"};
  1732. new NPOIHelper().ExportToExcel("局委评议统计", obj.Tables[0], cols);
  1733. return Success("导出excel");
  1734. }
  1735. return Success("成功", obj);
  1736. }
  1737. /// <summary>
  1738. /// 政民互动综合统计
  1739. /// </summary>
  1740. /// <param name="starttime"></param>
  1741. /// <param name="endtime"></param>
  1742. /// <param name="deptid"></param>
  1743. /// <param name="source"></param>
  1744. /// <param name="isExport"></param>
  1745. /// <returns></returns>
  1746. public ActionResult Government(DateTime? starttime, DateTime? endtime, int deptid = 0, int source = 0, bool isExport = false)
  1747. {
  1748. DateTime date = DateTime.Now;
  1749. if (starttime == null)
  1750. {
  1751. starttime = new DateTime(date.Year, date.Month, 1);
  1752. }
  1753. if (endtime == null)
  1754. {
  1755. endtime = DateTime.Now;
  1756. }
  1757. string dept = "";
  1758. if (deptid > 0)
  1759. dept = deptid.ToString();
  1760. string infosource = "";
  1761. if (source > 0)
  1762. infosource = source.ToString();
  1763. Dictionary<string, string> paras = new Dictionary<string, string>();
  1764. paras.Add("@sdate", starttime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  1765. paras.Add("@edate", endtime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  1766. paras.Add("@deptid", dept);
  1767. paras.Add("@source", infosource);
  1768. var obj = DbHelperSQL.RunProcedure("P_Government", paras, "Government");
  1769. if (isExport)
  1770. {
  1771. string message = new NPOIHelper().Government(obj);
  1772. if (message == "")
  1773. return Success("导出excel");
  1774. else
  1775. return Error(message);
  1776. }
  1777. return Success("成功", obj);
  1778. }
  1779. /// <summary>
  1780. /// 归并热线每日数据统计
  1781. /// </summary>
  1782. /// <param name="starttime"></param>
  1783. /// <param name="endtime"></param>
  1784. /// <returns></returns>
  1785. public ActionResult MergerHotline(DateTime? starttime , DateTime ? endtime,bool isExport = false )
  1786. {
  1787. DateTime date = DateTime.Now;
  1788. if (starttime ==null )
  1789. {
  1790. starttime = new DateTime(date.Year, date.Month, 1);
  1791. }
  1792. if (endtime == null)
  1793. {
  1794. endtime = DateTime.Now;
  1795. }
  1796. List<MergerHot.MergerHotSource> MergerHotSource = new List<MergerHot.MergerHotSource>();
  1797. var source = new BLL.T_Sys_DictionaryValue().GetModelList
  1798. ("F_PrentId ='2498'");
  1799. string key = "";
  1800. foreach (var it in source)
  1801. {
  1802. key += ",'"+it.F_Value+"'" ;
  1803. }
  1804. 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 (',') + ")");
  1805. if (source !=null && source .Count >0)
  1806. {
  1807. for (DateTime dt = starttime.Value; dt <= endtime.Value; dt = dt.AddDays(1))
  1808. {
  1809. MergerHot.MergerHotSource mergerHotSources = new MergerHot.MergerHotSource();
  1810. mergerHotSources.Data = dt.ToString("MM月dd日");
  1811. mergerHotSources.MergerHot = new List<MergerHot.MergerHots>();
  1812. for (int i = 0; i < source.Count + 3; i++)
  1813. {
  1814. if (i < source.Count)
  1815. {
  1816. MergerHot.MergerHots mergerHot = new MergerHot.MergerHots();
  1817. if (source[i].F_Value == "12345")
  1818. {
  1819. mergerHot.sort = source.Count;
  1820. }
  1821. else
  1822. {
  1823. mergerHot.sort = i-1;
  1824. }
  1825. mergerHot.Source = source[i ].F_Value ;
  1826. mergerHot.Call = CallRecords.Where(x => x.BeginTime
  1827. .Value.Day ==dt .Day && x.PhoneType == source[i].F_Value).Count();
  1828. mergerHot.Connect = CallRecords.Where(x => x.BeginTime
  1829. .Value.Day == dt.Day && x.CallState == 1 && x.PhoneType == source[i].F_Value).Count();
  1830. mergerHot.Notconnected = CallRecords.Where(x => x.BeginTime
  1831. .Value.Day == dt.Day && x.CallState == 0 && x.PhoneType == source[i].F_Value && x.UserCode != ""
  1832. && x.UserCode != null).Count();
  1833. mergerHot.voluntarily = CallRecords.Where(x => x.BeginTime
  1834. .Value.Day == dt.Day && x.CallState == 0 && x.PhoneType == source[i].F_Value && (x.UserCode == ""
  1835. || x.UserCode == null)).Count();
  1836. if (mergerHot.Call > 0)
  1837. {
  1838. mergerHot.rate = string.Format("{0:f2}%", (float)mergerHot.Connect / (float)mergerHot.Call * 100);
  1839. }
  1840. else
  1841. {
  1842. mergerHot.rate = "100%";
  1843. }
  1844. mergerHotSources.MergerHot.Add(mergerHot);
  1845. }
  1846. else if (i == source.Count)
  1847. {
  1848. MergerHot.MergerHots mergerHot = new MergerHot.MergerHots();
  1849. mergerHot.Source = "当日小计";
  1850. mergerHot.sort = source.Count + 1;
  1851. mergerHot.Call = CallRecords.Where(x => x.BeginTime
  1852. .Value.Day == dt.Day).Count();
  1853. mergerHot.Connect = CallRecords.Where(x => x.BeginTime
  1854. .Value.Day == dt.Day && x.CallState == 1).Count();
  1855. mergerHot.Notconnected = CallRecords.Where(x => x.BeginTime
  1856. .Value.Day == dt.Day && x.CallState == 0 && x.UserCode != ""
  1857. && x.UserCode != null).Count();
  1858. mergerHot.voluntarily = CallRecords.Where(x => x.BeginTime
  1859. .Value.Day == dt.Day && x.CallState == 0 && (x.UserCode == ""
  1860. || x.UserCode == null)).Count();
  1861. if (mergerHot.Call>0)
  1862. {
  1863. mergerHot.rate = string.Format("{0:f2}%", (float)mergerHot.Connect / (float)mergerHot.Call * 100);
  1864. }
  1865. else
  1866. {
  1867. mergerHot.rate = "100%";
  1868. }
  1869. mergerHotSources.MergerHot.Add(mergerHot);
  1870. }
  1871. else if (i == source.Count+1)
  1872. {
  1873. MergerHot.MergerHots mergerHot = new MergerHot.MergerHots();
  1874. mergerHot.Source = "累计";
  1875. mergerHot.sort = source.Count+2;
  1876. mergerHot.Call = CallRecords.Where(x => x.BeginTime
  1877. .Value.Date >=starttime .Value.Date && x.BeginTime
  1878. .Value.Date <= dt.Date ).Count();
  1879. mergerHot.Connect = CallRecords.Where(x => x.BeginTime
  1880. .Value.Date >= starttime.Value.Date && x.BeginTime
  1881. .Value.Date <= dt.Date && x.CallState == 1 ).Count();
  1882. mergerHot.Notconnected = CallRecords.Where(x => x.BeginTime
  1883. .Value.Date >= starttime.Value.Date && x.BeginTime
  1884. .Value.Date <= dt.Date && x.CallState == 0 && x.UserCode != ""
  1885. && x.UserCode != null).Count();
  1886. mergerHot.voluntarily = CallRecords.Where(x => x.BeginTime
  1887. .Value.Date >= starttime.Value.Date && x.BeginTime
  1888. .Value.Date <= dt.Date && x.CallState == 0 && (x.UserCode == ""
  1889. || x.UserCode == null)).Count();
  1890. if (mergerHot.Call > 0)
  1891. {
  1892. mergerHot.rate = string.Format("{0:f2}%", (float)mergerHot.Connect / (float)mergerHot.Call * 100);
  1893. }
  1894. else
  1895. {
  1896. mergerHot.rate = "100%";
  1897. }
  1898. mergerHotSources.MergerHot.Add(mergerHot);
  1899. }
  1900. else if (i == source.Count+2)
  1901. {
  1902. MergerHot.MergerHots mergerHot = new MergerHot.MergerHots();
  1903. mergerHot.Source = "归并热线小计";
  1904. mergerHot.sort = source.Count-1;
  1905. mergerHot.Call = CallRecords.Where(x => x.BeginTime
  1906. .Value.Day == dt.Day&&x.PhoneType !="12345").Count();
  1907. mergerHot.Connect = CallRecords.Where(x => x.BeginTime
  1908. .Value.Day == dt.Day && x.CallState == 1 && x.PhoneType != "12345").Count();
  1909. mergerHot.Notconnected = CallRecords.Where(x => x.BeginTime
  1910. .Value.Day == dt.Day && x.CallState == 0 && x.UserCode != ""
  1911. && x.UserCode != null && x.PhoneType != "12345").Count();
  1912. mergerHot.voluntarily = CallRecords.Where(x => x.BeginTime
  1913. .Value.Day == dt.Day && x.CallState == 0 && (x.UserCode == ""
  1914. || x.UserCode == null) && x.PhoneType != "12345").Count();
  1915. mergerHot.callback = CallRecords.Where(x => x.BeginTime
  1916. .Value.Day == dt.Day &&x .PhoneType != "12345" && x.Callback == 1).Count();
  1917. if (mergerHot.Call > 0)
  1918. {
  1919. mergerHot.rate = string.Format("{0:f2}%", (float)mergerHot.Connect / (float)mergerHot.Call * 100);
  1920. }
  1921. else
  1922. {
  1923. mergerHot.rate = "100%";
  1924. }
  1925. mergerHotSources.MergerHot.Add(mergerHot);
  1926. }
  1927. }
  1928. mergerHotSources.MergerHot= mergerHotSources.MergerHot.OrderBy(x => x.sort).ToList ();
  1929. MergerHotSource.Add(mergerHotSources);
  1930. }
  1931. }
  1932. if (MergerHotSource!=null && MergerHotSource .Count >0)
  1933. {
  1934. MergerHot.MergerHotSource mergerHotSources = new MergerHot.MergerHotSource();
  1935. mergerHotSources.Data = "合计";
  1936. mergerHotSources.MergerHot = new List<MergerHot.MergerHots>();
  1937. for (int i = 0; i < source.Count + 2; i++)
  1938. {
  1939. if (i < source.Count)
  1940. {
  1941. MergerHot.MergerHots mergerHot = new MergerHot.MergerHots();
  1942. mergerHot.Source = source[i].F_Value;
  1943. mergerHot.Call = CallRecords.Where(x=> x.PhoneType == source[i].F_Value).Count();
  1944. mergerHot.Connect = CallRecords.Where(x => x.CallState == 1 && x.PhoneType == source[i].F_Value).Count();
  1945. mergerHot.Notconnected = CallRecords.Where(x => x.CallState == 0 && x.PhoneType == source[i].F_Value && x.UserCode != ""
  1946. && x.UserCode != null).Count();
  1947. mergerHot.voluntarily = CallRecords.Where(x => x.CallState == 0 && x.PhoneType == source[i].F_Value && (x.UserCode == ""
  1948. || x.UserCode == null)).Count();
  1949. if (source[i].F_Value=="12345")
  1950. {
  1951. mergerHot.sort = source.Count ;
  1952. }
  1953. else
  1954. {
  1955. mergerHot.sort =i -1;
  1956. }
  1957. if (mergerHot.Call > 0)
  1958. {
  1959. mergerHot.rate = string.Format("{0:f2}%", (float)mergerHot.Connect / (float)mergerHot.Call * 100);
  1960. }
  1961. else
  1962. {
  1963. mergerHot.rate = "100%";
  1964. }
  1965. mergerHotSources.MergerHot.Add(mergerHot);
  1966. }
  1967. else if (i == source.Count)
  1968. {
  1969. MergerHot.MergerHots mergerHot = new MergerHot.MergerHots();
  1970. mergerHot.Source ="当日小计";
  1971. mergerHot.sort = source.Count + 1;
  1972. mergerHot.Call = CallRecords.Count();
  1973. mergerHot.Connect = CallRecords.Where(x =>x.CallState == 1).Count();
  1974. mergerHot.Notconnected = CallRecords.Where(x => x.CallState == 0 && x.UserCode != ""
  1975. && x.UserCode != null).Count();
  1976. mergerHot.voluntarily = CallRecords.Where(x => x.CallState == 0 && (x.UserCode == ""
  1977. || x.UserCode == null)).Count();
  1978. if (mergerHot.Call > 0)
  1979. {
  1980. mergerHot.rate = string.Format("{0:f2}%", (float)mergerHot.Connect / (float)mergerHot.Call * 100);
  1981. }
  1982. else
  1983. {
  1984. mergerHot.rate = "100%";
  1985. }
  1986. mergerHotSources.MergerHot.Add(mergerHot);
  1987. }
  1988. else if (i == source.Count+1)
  1989. {
  1990. MergerHot.MergerHots mergerHot = new MergerHot.MergerHots();
  1991. mergerHot.Source = "归并热线小计";
  1992. mergerHot.sort = source.Count - 1;
  1993. mergerHot.Call = CallRecords.Where(x => x.PhoneType != "12345").Count();
  1994. mergerHot.Connect = CallRecords.Where(x => x.PhoneType != "12345").Count();
  1995. mergerHot.Notconnected = CallRecords.Where(x =>x.CallState == 0 && x.UserCode != ""
  1996. && x.UserCode != null && x.PhoneType != "12345").Count();
  1997. mergerHot.voluntarily = CallRecords.Where(x => x.CallState == 0 && (x.UserCode == ""
  1998. || x.UserCode == null && x.PhoneType != "12345")).Count();
  1999. mergerHot.callback = CallRecords.Where(x => x.PhoneType != "12345" && x.Callback == 1).Count();
  2000. if (mergerHot.Call > 0)
  2001. {
  2002. mergerHot.rate = string.Format("{0:f2}%", (float)mergerHot.Connect / (float)mergerHot.Call * 100);
  2003. }
  2004. else
  2005. {
  2006. mergerHot.rate = "100%";
  2007. }
  2008. mergerHotSources.MergerHot.Add(mergerHot);
  2009. }
  2010. }
  2011. mergerHotSources.MergerHot = mergerHotSources.MergerHot.OrderBy(x => x.sort).ToList();
  2012. MergerHotSource.Add(mergerHotSources);
  2013. }
  2014. if (isExport)
  2015. {
  2016. new NPOIHelper().ExportMergerToExcel(MergerHotSource);
  2017. return Success("导出excel");
  2018. }
  2019. return Success("获取成功", MergerHotSource);
  2020. }
  2021. /// <summary>
  2022. /// 调度工作量统计
  2023. /// </summary>
  2024. /// <param name="start"></param>
  2025. /// <param name="end"></param>
  2026. /// <param name="pageIndex"></param>
  2027. /// <param name="pageSize"></param>
  2028. /// <param name="isExport"></param>
  2029. /// <returns></returns>
  2030. public ActionResult GetWorkLoad1(DateTime? start, DateTime? end, bool isExport = false)
  2031. {
  2032. if (start == null)
  2033. {
  2034. start = DateTime.Now;
  2035. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  2036. }
  2037. if (end == null)
  2038. {
  2039. end = DateTime.Now;
  2040. }
  2041. Dictionary<string, string> paras = new Dictionary<string, string>();
  2042. paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
  2043. paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
  2044. var obj = DbHelperSQL.RunProcedure("P_LeaderAssessmentReport", paras, "LeaderAssessmentReport");
  2045. if (isExport)
  2046. {
  2047. var cols = new string[] { "姓名", "回退量", "交办量", "退回审核量", "延时审核量", "重办量", "结案量" };
  2048. new NPOIHelper().ExportToExcel($"调度工作量统计{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
  2049. return Success("导出excel");
  2050. }
  2051. return Success("成功", obj);
  2052. }
  2053. public ActionResult GetWorkLoad(DateTime? start, DateTime? end, bool isExport = false, string source = "")
  2054. {
  2055. if (start == null)
  2056. {
  2057. start = DateTime.Now;
  2058. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  2059. }
  2060. if (end == null)
  2061. {
  2062. end = DateTime.Now;
  2063. }
  2064. Dictionary<string, string> paras = new Dictionary<string, string>();
  2065. paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
  2066. paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
  2067. paras.Add("@source", source);
  2068. var obj = DbHelperSQL.RunProcedure("P_LeaderAssessmentReport_1", paras, "LeaderAssessmentReport");
  2069. if (isExport)
  2070. {
  2071. var cols = new string[] { "姓名", "回退量", "交办量", "退回审核量", "延时审核量", "重办量", "结案量" };
  2072. new NPOIHelper().ExportToExcel($"调度工作量统计{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
  2073. return Success("导出excel");
  2074. }
  2075. return Success("成功", obj);
  2076. }
  2077. /// <summary>
  2078. /// 获取未处理报表
  2079. /// </summary>
  2080. /// <param name="date"></param>
  2081. /// <param name="isdc"></param>
  2082. /// <returns></returns>
  2083. public ActionResult GetNoDealReport(DateTime? start, DateTime? end, int deptid = 0, int pageIndex = 1, int pageSize = 10, int isdc = 0)
  2084. {
  2085. if (start == null)
  2086. {
  2087. start = DateTime.Now;
  2088. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  2089. }
  2090. if (end == null)
  2091. {
  2092. end = DateTime.Now;
  2093. }
  2094. var where = "";
  2095. if (deptid > 0)
  2096. {
  2097. where = " AND F_MainDeptId=" + deptid;
  2098. }
  2099. 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;
  2100. if (isdc > 0)
  2101. {
  2102. string[] cols = new string[] { "工单编号", "承办单位", "工单内容", "转派时间", "回复时限", "超时/剩余", "工单状态" };
  2103. var dtall = DbHelperSQL.Query("select * from V_Bus_NoDeal where 1=1 " + sql).Tables[0];
  2104. dtall.Columns.Remove("F_MainDeptId");
  2105. dtall.Columns.Remove("F_CreateTime");
  2106. dtall.Columns.Remove("F_WorkState");
  2107. new NPOIHelper().ExportToExcel($"单位未处理统计报表{start.Value.ToString("yyyyMMdd")}-{end.Value.ToString("yyyyMMdd")}", dtall, cols);
  2108. return Success("导出excel");
  2109. }
  2110. int recordCount = 0;
  2111. var dt = BLL.PagerBLL.GetListPager(
  2112. "V_Bus_NoDeal",
  2113. "F_WorkOrderId",
  2114. "*",
  2115. sql,
  2116. "ORDER BY F_CreateTime DESC",
  2117. pageSize,
  2118. pageIndex,
  2119. true,
  2120. out recordCount);
  2121. var obj = new
  2122. {
  2123. state = "success",
  2124. message = "成功",
  2125. rows = dt,
  2126. total = recordCount
  2127. };
  2128. return Content(obj.ToJson());
  2129. }
  2130. #region 20190618 zhengbingbing 新增处理量统计按照时间筛选
  2131. /// <summary>
  2132. /// 处理量统计
  2133. /// </summary>
  2134. /// <param name="sdate"></param>
  2135. /// <param name="edate"></param>
  2136. /// <param name="isExport"></param>
  2137. /// <returns></returns>
  2138. public ActionResult GetDeptDayReport1(string sdate, string edate,int isdept=1, bool isExport = false)
  2139. {
  2140. if (string.IsNullOrEmpty(sdate))
  2141. {
  2142. sdate = DateTime.Now.Date.ToString("yyyy-MM-01");
  2143. }
  2144. if (string.IsNullOrEmpty(edate))
  2145. {
  2146. edate = DateTime.Now.Date.ToString("yyyy-MM-dd");
  2147. }
  2148. if (User.F_RoleCode == "GLY" || User.F_RoleCode == "SPZ" || User.F_RoleCode == "SPZJZ")
  2149. {
  2150. var maindeptid = 0;
  2151. if (User.F_RoleCode == "WLDW")
  2152. {
  2153. maindeptid = User.F_DeptId;
  2154. }
  2155. else if (User.F_RoleCode == "EJWLDW")
  2156. {
  2157. maindeptid = User.F_DeptId;
  2158. isdept = 2;
  2159. }
  2160. }
  2161. Dictionary<string, string> paras = new Dictionary<string, string>();
  2162. paras.Add("@sdate", sdate);
  2163. paras.Add("@edate", edate);
  2164. paras.Add("@isdept", isdept.ToString ());
  2165. var obj = DbHelperSQL.RunProcedure("P_DeptDayReport", paras, "DeptDayReport");
  2166. if (isExport)
  2167. {
  2168. var cols = new string[] { "名称", "受理数量", "处理量", "延期量", "重办量", "结案量", "办理率", "办结率" };
  2169. new NPOIHelper().ExportToExcel($"工单报表{sdate}-{edate}", obj.Tables[0], cols);
  2170. return Success("导出excel");
  2171. }
  2172. return Success("成功", obj);
  2173. }
  2174. public ActionResult GetDeptDayReport(string sdate, string edate, int isdept = 0, bool isExport = false,string source="",int deptid=0 )
  2175. {
  2176. if (string.IsNullOrEmpty(sdate))
  2177. {
  2178. sdate = DateTime.Now.Date.ToString("yyyy-MM-01");
  2179. }
  2180. if (string.IsNullOrEmpty(edate))
  2181. {
  2182. edate = DateTime.Now.Date.ToString("yyyy-MM-dd");
  2183. }
  2184. if (User.F_RoleCode != "GLY" && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ")
  2185. {
  2186. if (User.F_RoleCode == "WLDW")
  2187. {
  2188. isdept = User.F_DeptId;
  2189. }
  2190. else if (User.F_RoleCode == "EJWLDW")
  2191. {
  2192. isdept = User.F_DeptId;
  2193. }
  2194. }
  2195. string dept = "";
  2196. if (isdept > 0)
  2197. dept = isdept.ToString();
  2198. Dictionary<string, string> paras = new Dictionary<string, string>();
  2199. paras.Add("@sdate", sdate);
  2200. paras.Add("@edate", edate);
  2201. paras.Add("@isdept", dept);
  2202. paras.Add("@source", source);
  2203. var obj = DbHelperSQL.RunProcedure("P_DeptDayReport_1", paras, "DeptDayReport");
  2204. if (obj!=null && obj.Tables[0]!=null && obj.Tables[0].Rows.Count > 0) {
  2205. for (int i = 0; i < obj.Tables[0].Rows.Count; i++)
  2206. {
  2207. int acceptcount = 0, dealcount = 0, endcount = 0;double dealrate = 0, endrate = 0;
  2208. int.TryParse(obj.Tables[0].Rows[i]["acceptcount"].ToString(),out acceptcount);
  2209. int.TryParse(obj.Tables[0].Rows[i]["dealcount"].ToString(), out dealcount);
  2210. int.TryParse(obj.Tables[0].Rows[i]["endcount"].ToString(), out endcount);
  2211. if(acceptcount>0)
  2212. {
  2213. dealrate = double.Parse((dealcount * 100).ToString()) / acceptcount;
  2214. endrate = double.Parse((endcount * 100).ToString()) / acceptcount;
  2215. obj.Tables[0].Rows[i]["dealrate"] = dealrate.ToString("f") + "%";
  2216. obj.Tables[0].Rows[i]["endrate"] = endrate.ToString("f") + "%";
  2217. }
  2218. }
  2219. }
  2220. if (isExport)
  2221. {
  2222. var cols = new string[] { "名称", "受理数量", "处理量", "延期量", "重办量", "结案量", "办理率", "办结率" };
  2223. new NPOIHelper().ExportToExcel($"处理数量统计报表{sdate.Substring(0, 10)}-{edate.Substring(0, 10)}", obj.Tables[0], cols);
  2224. return Success("导出excel");
  2225. }
  2226. return Success("成功", obj);
  2227. }
  2228. #endregion
  2229. #region 20191104 zhengbingbing 增加三级单位统计项
  2230. /// <summary>
  2231. /// 三级单位处理量统计
  2232. /// </summary>
  2233. /// <param name="sdate"></param>
  2234. /// <param name="edate"></param>
  2235. /// <param name="isExport"></param>
  2236. /// <returns></returns>
  2237. public ActionResult GetDept3DayReport1(string sdate, string edate, bool isExport = false)
  2238. {
  2239. if (string.IsNullOrEmpty(sdate))
  2240. {
  2241. sdate = DateTime.Now.Date.ToString("yyyy-MM-01");
  2242. }
  2243. if (string.IsNullOrEmpty(edate))
  2244. {
  2245. edate = DateTime.Now.Date.ToString("yyyy-MM-dd");
  2246. }
  2247. int deptid = 0;
  2248. if (User.F_RoleCode != "GLY" && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ")
  2249. {
  2250. if (User.F_RoleCode == "WLDW" || User.F_RoleCode == "EJWLDW")
  2251. {
  2252. deptid = User.F_DeptId;
  2253. }
  2254. }
  2255. Dictionary<string, string> paras = new Dictionary<string, string>();
  2256. paras.Add("@sdate", sdate);
  2257. paras.Add("@edate", edate);
  2258. paras.Add("@deptid", deptid.ToString());
  2259. var obj = DbHelperSQL.RunProcedure("P_Dept3DayReport", paras, "Dept3DayReport");
  2260. if (isExport)
  2261. {
  2262. var cols = new string[] { "单位名称", "受理数量", "处理量", "结案量", "办理率", "办结率" };
  2263. new NPOIHelper().ExportToExcel($"工单报表{sdate}-{edate}", obj.Tables[0], cols);
  2264. return Success("导出excel");
  2265. }
  2266. return Success("成功", obj);
  2267. }
  2268. public ActionResult GetDept3DayReport(string sdate, string edate, bool isExport = false,string source = "")
  2269. {
  2270. if (string.IsNullOrEmpty(sdate))
  2271. {
  2272. sdate = DateTime.Now.Date.ToString("yyyy-MM-01");
  2273. }
  2274. if (string.IsNullOrEmpty(edate))
  2275. {
  2276. edate = DateTime.Now.Date.ToString("yyyy-MM-dd");
  2277. }
  2278. int deptid = 0;
  2279. if (User.F_RoleCode != "GLY" && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ")
  2280. {
  2281. if (User.F_RoleCode == "WLDW" || User.F_RoleCode == "EJWLDW")
  2282. {
  2283. deptid = User.F_DeptId;
  2284. }
  2285. }
  2286. Dictionary<string, string> paras = new Dictionary<string, string>();
  2287. paras.Add("@sdate", sdate);
  2288. paras.Add("@edate", edate);
  2289. paras.Add("@deptid", deptid.ToString());
  2290. paras.Add("@source", source);
  2291. var obj = DbHelperSQL.RunProcedure("P_Dept3DayReport_1", paras, "Dept3DayReport");
  2292. if (obj != null && obj.Tables[0] != null && obj.Tables[0].Rows.Count > 0)
  2293. {
  2294. for (int i = 0; i < obj.Tables[0].Rows.Count; i++)
  2295. {
  2296. int acceptcount = 0, dealcount = 0, endcount = 0; double dealrate = 0, endrate = 0;
  2297. int.TryParse(obj.Tables[0].Rows[i]["acceptcount"].ToString(), out acceptcount);
  2298. int.TryParse(obj.Tables[0].Rows[i]["dealcount"].ToString(), out dealcount);
  2299. int.TryParse(obj.Tables[0].Rows[i]["endcount"].ToString(), out endcount);
  2300. if (acceptcount > 0)
  2301. {
  2302. dealrate = double.Parse((dealcount * 100).ToString()) / acceptcount;
  2303. endrate = double.Parse((endcount * 100).ToString()) / acceptcount;
  2304. obj.Tables[0].Rows[i]["dealrate"] = dealrate.ToString("f") + "%";
  2305. obj.Tables[0].Rows[i]["endrate"] = endrate.ToString("f") + "%";
  2306. }
  2307. }
  2308. }
  2309. if (isExport)
  2310. {
  2311. var cols = new string[] { "单位名称", "受理数量", "处理量", "结案量", "办理率", "办结率" };
  2312. new NPOIHelper().ExportToExcel($"工单报表{sdate}-{edate}", obj.Tables[0], cols);
  2313. return Success("导出excel");
  2314. }
  2315. return Success("成功", obj);
  2316. }
  2317. /// <summary>
  2318. /// 三级单位满意度统计
  2319. /// </summary>
  2320. /// <param name="sdate"></param>
  2321. /// <param name="edate"></param>
  2322. /// <param name="isExport"></param>
  2323. /// <returns></returns>
  2324. public ActionResult GetDept3SatisfiedReport(string sdate, string edate, bool isExport = false, string source = "")
  2325. {
  2326. if (string.IsNullOrEmpty(sdate))
  2327. {
  2328. sdate = DateTime.Now.Date.ToString("yyyy-MM-01");
  2329. }
  2330. if (string.IsNullOrEmpty(edate))
  2331. {
  2332. edate = DateTime.Now.Date.ToString("yyyy-MM-dd");
  2333. }
  2334. int deptid = 0;
  2335. if (User.F_RoleCode != "GLY" && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ")
  2336. {
  2337. if (User.F_RoleCode == "WLDW" || User.F_RoleCode == "EJWLDW")
  2338. {
  2339. deptid = User.F_DeptId;
  2340. }
  2341. }
  2342. Dictionary<string, string> paras = new Dictionary<string, string>();
  2343. paras.Add("@sdate", sdate);
  2344. paras.Add("@edate", edate);
  2345. paras.Add("@deptid", deptid.ToString());
  2346. paras.Add("@source", source);
  2347. var obj = DbHelperSQL.RunProcedure("P_Dept3SatisfiedReport", paras, "Dept3SatisfiedReport");
  2348. if (isExport)
  2349. {
  2350. string[] cols = new string[] { "单位名称", "处理总量", "满意总量", "不满意总量", "满意度" };
  2351. new NPOIHelper().ExportToExcel($"满意度统计报表{Convert.ToDateTime(sdate).ToString("yyyyMMdd")}-{Convert.ToDateTime(edate).ToString("yyyyMMdd")}", obj.Tables[0], cols);
  2352. return Success("导出excel");
  2353. }
  2354. return Success("成功", obj);
  2355. }
  2356. /// <summary>
  2357. /// 三级单位处理效率统计
  2358. /// </summary>
  2359. /// <param name="sdate"></param>
  2360. /// <param name="edate"></param>
  2361. /// <param name="isExport"></param>
  2362. /// <returns></returns>
  2363. public ActionResult GetDept3EfficiencyReport(string sdate, string edate, bool isExport = false, string source = "")
  2364. {
  2365. if (string.IsNullOrEmpty(sdate))
  2366. {
  2367. sdate = DateTime.Now.Date.ToString("yyyy-MM-01");
  2368. }
  2369. if (string.IsNullOrEmpty(edate))
  2370. {
  2371. edate = DateTime.Now.Date.ToString("yyyy-MM-dd");
  2372. }
  2373. int deptid = 0;
  2374. if (User.F_RoleCode != "GLY" && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ")
  2375. {
  2376. if (User.F_RoleCode == "WLDW" || User.F_RoleCode == "EJWLDW")
  2377. {
  2378. deptid = User.F_DeptId;
  2379. }
  2380. }
  2381. Dictionary<string, string> paras = new Dictionary<string, string>();
  2382. paras.Add("@sdate", sdate);
  2383. paras.Add("@edate", edate);
  2384. paras.Add("@deptid", deptid.ToString());
  2385. paras.Add("@source", source);
  2386. var obj = DbHelperSQL.RunProcedure("P_Dept3EfficiencyReport", paras, "Dept3EfficiencyReport");
  2387. if (isExport)
  2388. {
  2389. string[] cols = new string[] { "单位名称", "处理总量", "及时量", "超时量", "处理及时率" };
  2390. NPOIHelper npoi = new NPOIHelper();
  2391. if (npoi.ExportToExcel("处理效率统计报表", obj.Tables[0], cols) == "")
  2392. {
  2393. return Success("导出成功");
  2394. }
  2395. else
  2396. {
  2397. return Error("导出失败");
  2398. }
  2399. }
  2400. return Success("成功", obj);
  2401. }
  2402. public ActionResult GetDept3EfficiencyReport1(string sdate, string edate, bool isExport = false)
  2403. {
  2404. if (string.IsNullOrEmpty(sdate))
  2405. {
  2406. sdate = DateTime.Now.Date.ToString("yyyy-MM-01");
  2407. }
  2408. if (string.IsNullOrEmpty(edate))
  2409. {
  2410. edate = DateTime.Now.Date.ToString("yyyy-MM-dd");
  2411. }
  2412. int deptid = 0;
  2413. if (User.F_RoleCode != "GLY" && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ")
  2414. {
  2415. if (User.F_RoleCode == "WLDW" || User.F_RoleCode == "EJWLDW")
  2416. {
  2417. deptid = User.F_DeptId;
  2418. }
  2419. }
  2420. Dictionary<string, string> paras = new Dictionary<string, string>();
  2421. paras.Add("@sdate", sdate);
  2422. paras.Add("@edate", edate);
  2423. paras.Add("@deptid", deptid.ToString());
  2424. var obj = DbHelperSQL.RunProcedure("P_Dept3EfficiencyReport_1", paras, "Dept3EfficiencyReport");
  2425. var newSet = new DataSet();
  2426. if (obj != null && obj.Tables[0] != null && obj.Tables[0].Rows.Count > 0)
  2427. {
  2428. obj.Tables[0].Columns.Add("rate", typeof(decimal));
  2429. for (int i = 0; i < obj.Tables[0].Rows.Count; i++)
  2430. {
  2431. int completedcount = 0, timelycount = 0, timeoutcount = 0; double timelyrate = 0;
  2432. int.TryParse(obj.Tables[0].Rows[i]["completedcount"].ToString(), out completedcount);
  2433. int.TryParse(obj.Tables[0].Rows[i]["timelycount"].ToString(), out timelycount);
  2434. int.TryParse(obj.Tables[0].Rows[i]["timeoutcount"].ToString(), out timeoutcount);
  2435. timeoutcount = completedcount - timelycount;
  2436. obj.Tables[0].Rows[i]["timeoutcount"] = timeoutcount;
  2437. if (completedcount > 0)
  2438. {
  2439. timelyrate = double.Parse((timelycount * 100).ToString()) / completedcount;
  2440. obj.Tables[0].Rows[i]["timelyrate"] = timelyrate.ToString("f") + "%";
  2441. obj.Tables[0].Rows[i]["rate"] = timelyrate;
  2442. }
  2443. }
  2444. obj.Tables[0].DefaultView.Sort = "rate desc";
  2445. newSet.Tables.Add(obj.Tables[0].DefaultView.ToTable());
  2446. newSet.Tables[0].Columns.Remove("rate");
  2447. }
  2448. if (isExport)
  2449. {
  2450. string[] cols = new string[] { "单位名称", "处理总量", "及时量", "超时量", "处理及时率" };
  2451. NPOIHelper npoi = new NPOIHelper();
  2452. if (npoi.ExportToExcel("处理效率统计报表", newSet.Tables[0], cols) == "")
  2453. {
  2454. return Success("导出成功");
  2455. }
  2456. else
  2457. {
  2458. return Error("导出失败");
  2459. }
  2460. }
  2461. return Success("成功", newSet);
  2462. }
  2463. #endregion
  2464. /// <summary>
  2465. /// 单位月统计
  2466. /// </summary>
  2467. /// <param name="date"></param>
  2468. /// <param name="isExport"></param>
  2469. /// <returns></returns>
  2470. public ActionResult GetDeptMonthReport(string date, bool isExport = false)
  2471. {
  2472. if (string.IsNullOrEmpty(date))
  2473. {
  2474. date = DateTime.Now.Date.ToString("yyyy-MM");
  2475. }
  2476. Dictionary<string, string> paras = new Dictionary<string, string>();
  2477. paras.Add("@date", date);
  2478. var obj = DbHelperSQL.RunProcedure("P_DeptMonthReport", paras, "DeptMonthReport");
  2479. if (isExport)
  2480. {
  2481. var cols = new string[] { "名称", "当月受理数量", "当月处理量", "往月处理量", "当月延期量", "往月延期量", "当月重办量", "往月重办量", "当月结案量", "当月办理率", "当月办结率" };
  2482. new NPOIHelper().ExportToExcel($"工单报表{date}", obj.Tables[0], cols);
  2483. return Success("导出excel");
  2484. }
  2485. return Success("成功", obj);
  2486. }
  2487. /// <summary>
  2488. /// 单位办理率统计
  2489. /// </summary>
  2490. /// <param name="start"></param>
  2491. /// <param name="end"></param>
  2492. /// <param name="pageIndex"></param>
  2493. /// <param name="pageSize"></param>
  2494. /// <param name="isExport"></param>
  2495. /// <returns></returns>
  2496. public ActionResult GetDeptEndRate(string month, int type = 0, bool isExport = false)
  2497. {
  2498. string start = "", end = "";
  2499. if (month != null)
  2500. {
  2501. var date = DateTime.Parse(month + "-01");
  2502. start = date.ToString("yyyy-MM-dd"); ;
  2503. end = date.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd");
  2504. }
  2505. Dictionary<string, string> paras = new Dictionary<string, string>();
  2506. paras.Add("@sdate", start);
  2507. paras.Add("@edate", end);
  2508. paras.Add("@type", type.ToString());
  2509. var obj = DbHelperSQL.RunProcedure("P_DeptEndRateReport", paras, "DeptEndRateReport");
  2510. if (isExport)
  2511. {
  2512. var cols = new string[] { "单位", "受理数量", "办理数量", "结案数量", "结案率" };
  2513. new NPOIHelper().ExportToExcel($"单位办理率统计{month}", obj.Tables[0], cols, 1);
  2514. return Success("导出excel");
  2515. }
  2516. return Success("成功", obj);
  2517. }
  2518. /// <summary>
  2519. /// 工单热点分布
  2520. /// </summary>
  2521. /// <param name="start"></param>
  2522. /// <param name="end"></param>
  2523. /// <param name="deptid"></param>
  2524. /// <param name="keyid"></param>
  2525. /// <param name="sourcearea"></param>
  2526. /// <param name="source"></param>
  2527. /// <returns></returns>
  2528. public ActionResult GetHotspotMap(DateTime? start, DateTime? end, int deptid = 0, int keyid = 0,int sourcearea = 0, int source=0)
  2529. {
  2530. if (start == null)
  2531. {
  2532. start = DateTime.Now;
  2533. //start = new DateTime(start.Value.Year, start.Value.Month, 1);
  2534. start = DateTime.Now.AddDays(-3);
  2535. }
  2536. if (end == null)
  2537. {
  2538. end = DateTime.Now;
  2539. }
  2540. var where = " and ISNUMERIC(F_Longitude)>0 and ISNUMERIC(F_Latitude)>0 ";
  2541. if (deptid > 0)
  2542. 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 )";
  2543. if (keyid > 0)
  2544. where += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  2545. if (sourcearea > 0)
  2546. where += " and F_SourceArea='" + sourcearea+"' ";
  2547. if (source > 0)
  2548. where += " and F_InfoSource = '" + source + "' ";
  2549. 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;
  2550. var orderlist = workOrderBLL.GetList(" 1=1 "+sql).Tables[0];
  2551. var list = new List<string[]>();
  2552. foreach (DataRow dr in orderlist.Rows)
  2553. {
  2554. var longitude = dr["F_Longitude"].ToString();
  2555. var latitude = dr["F_Latitude"].ToString();
  2556. var title= dr["F_ComTitle"].ToString();
  2557. var content= dr["F_ComContent"].ToString();
  2558. var strobj = new string[] { longitude, latitude, title, content };
  2559. list.Add(strobj);
  2560. }
  2561. return Success("",list);
  2562. }
  2563. #region 20191121 zhengbingbing 新增质检工作统计:工单回访量、回访量、结案量、工单重办量、重办量
  2564. public ActionResult GetQualityAssessment(DateTime? start, DateTime? end, bool isExport = false)
  2565. {
  2566. if (start == null)
  2567. {
  2568. start = DateTime.Now;
  2569. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  2570. }
  2571. if (end == null)
  2572. {
  2573. end = DateTime.Now;
  2574. }
  2575. Dictionary<string, string> paras = new Dictionary<string, string>();
  2576. paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
  2577. paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
  2578. 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") + "'";
  2579. 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") + "'";
  2580. string sql = "select '('+F_UserCode+')'+F_UserName 姓名" +
  2581. ",(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) 工单回访量" +
  2582. ",(select COUNT(1) from T_Bus_VisitResult where F_IsDelete = 0 " + wherevi + " and F_CreateUser = F_UserCode and F_IsDelete = 0) 回访量" +
  2583. ",(select COUNT(1) from T_Bus_WorkOrder where F_WorkState = 9 and F_IsDelete = 0 and F_CloseUser = F_UserCode "+ whereja + ") 结案量" +
  2584. ",(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) 工单重办量" +
  2585. ",(select COUNT(1) from T_Bus_Operation where F_IsDelete = 0 and F_State = 11 and F_CreateUser = F_UserCode " + wherevi + ") 重办量" +
  2586. " from T_Sys_UserAccount where F_RoleId = 18 and F_DeleteFlag = 0 order by F_UserCode";
  2587. var obj = DbHelperSQL.Query(sql);
  2588. if (isExport)
  2589. {
  2590. string[] cols = new string[] { "姓名", "工单回访量", "回访量", "结案量", "工单重办量", "重办量" };
  2591. NPOIHelper npoi = new NPOIHelper();
  2592. if (npoi.ExportToExcel("质检工作统计报表", obj.Tables[0], cols) == "")
  2593. {
  2594. return Success("导出成功");
  2595. }
  2596. else
  2597. {
  2598. return Error("导出失败");
  2599. }
  2600. }
  2601. return Success("成功", obj);
  2602. }
  2603. #endregion
  2604. /// <summary>
  2605. ///
  2606. /// </summary>
  2607. /// <param name="start"></param>
  2608. /// <param name="end"></param>
  2609. /// <param name="isExport"></param>
  2610. /// <returns></returns>
  2611. public ActionResult GetAudithandling(DateTime? start, DateTime? end, bool isExport = false)
  2612. {
  2613. if (start == null)
  2614. {
  2615. start = DateTime.Now;
  2616. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  2617. }
  2618. if (end == null)
  2619. {
  2620. end = DateTime.Now;
  2621. }
  2622. Dictionary<string, string> paras = new Dictionary<string, string>();
  2623. paras.Add("@sdate", start.Value.ToString("yyyy-MM-dd"));
  2624. paras.Add("@edate", end.Value.ToString("yyyy-MM-dd"));
  2625. var obj = DbHelperSQL.RunProcedure("P_Audithandling", paras, "Audithandling");
  2626. if (isExport)
  2627. {
  2628. var cols = new string[] { "单位名称", "办理件数量", "退回件数量", "延时件数量","超期未果数量" };
  2629. new NPOIHelper().ExportToExcel($"审核办理工单统计{Convert.ToDateTime(start).ToString("yyyyMMdd")}-{Convert.ToDateTime(end).ToString("yyyyMMdd")}", obj.Tables[0], cols);
  2630. return Success("导出excel");
  2631. }
  2632. return Success("成功", obj);
  2633. }
  2634. }
  2635. }