Nenhuma Descrição

BusinessController.cs 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. using CallCenter.Utility;
  2. using CallCenterApi.DB;
  3. using CallCenterApi.Interface.Controllers.Base;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Web;
  11. using System.Web.Mvc;
  12. namespace CallCenterApi.Interface.Controllers.report
  13. {
  14. //[Authority]
  15. public class BusinessController : BaseController
  16. {
  17. private BLL.T_Bus_WorkOrder WorkOrder = new BLL.T_Bus_WorkOrder();
  18. /// <summary>
  19. /// 投诉统计
  20. /// </summary>
  21. /// <returns></returns>
  22. public ActionResult GetTSCountList()
  23. {
  24. string year = RequestString.GetQueryString("year");
  25. string month = RequestString.GetQueryString("month");
  26. if (string.IsNullOrEmpty(year))
  27. {
  28. year = DateTime.Now.ToString("yyyy");
  29. }
  30. if (string.IsNullOrEmpty(month))
  31. {
  32. month = DateTime.Now.ToString("MM");
  33. }
  34. BLL.T_Sys_DictionaryValue DictionaryValue = new BLL.T_Sys_DictionaryValue();
  35. string day = DateTime.DaysInMonth(int.Parse(year), int.Parse(month)).ToString();
  36. string date = year + "." + month + "." + day;
  37. StringBuilder sb = new StringBuilder();
  38. sb.Append("<table id=\"month\" width =\"700px\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#4aadfb\">");
  39. sb.Append("<tr><td bgcolor=\"#FFFFFF\" align=\"center\" colspan =\"4\"><font color=\"black\" size=\"4px\" >" + year + "年" + month + "月" + "市长热线受理投诉统计表</font><br/><font color=\"black\" size=\"2px\" >" + DateTime.Now.ToLongDateString().ToString() + "</font></td></tr>");
  40. sb.Append("<tr bgcolor=\"#eef3f6\" height=\"20\" align=\"center\"><th colspan =\"2\" width=\"40%\">类别</th><th>当月数</th><th>累计数</th></tr>");
  41. DataSet ds = DictionaryValue.GetList(" F_ItemId=2");
  42. int T_Allcount = 0;
  43. int M_Allcount = 0;
  44. foreach (DataRow row in ds.Tables[0].Rows)
  45. {
  46. DataTable dt = DictionaryValue.GetList(" F_PrentId=" + row["F_ValueId"].ToString()).Tables[0];//获取列表
  47. if (dt != null && dt.Rows.Count > 1)
  48. {
  49. //第一个,“投诉”的
  50. sb.Append("<tr style=\"border:1px solid #E0EEFE\" align=\"center\"><td bgcolor=\"#FFFFFF\" rowspan =\"" + dt.Rows.Count.ToString() + "\">" + row["F_Value"].ToString() + "</td>");
  51. for (int n = 0; n < dt.Rows.Count; n++)
  52. {
  53. //内容大类
  54. //int T_count =WorkOrder.GetList(" F_InfoConBigType=" + dt.Rows[n]["F_ValueId"].ToString() + " and F_IsClosed=1 and DateDiff(yy,F_RegDate,'"+ date + "')=0 and DateDiff(d,F_RegDate,'"+ date + "')>=0").Tables[0].Rows.Count;//当年
  55. //int M_count = WorkOrder.GetList(" F_InfoConBigType=" + dt.Rows[n]["F_ValueId"].ToString() + " and F_IsClosed=1 and DateDiff(mm,F_RegDate,'" + date + "')=0").Tables[0].Rows.Count;//月
  56. int T_count = WorkOrder.GetList(" F_IsDelete=0 and F_InfoConBigType=" + dt.Rows[n]["F_ValueId"].ToString() + " and DateDiff(yy,F_RegDate,'" + date + "')=0 and DateDiff(d,F_RegDate,'" + date + "')>=0 and F_InfoConSmallType is not null ").Tables[0].Rows.Count;//当年
  57. int M_count = WorkOrder.GetList(" F_IsDelete=0 and F_InfoConBigType=" + dt.Rows[n]["F_ValueId"].ToString() + " and DateDiff(mm,F_RegDate,'" + date + "')=0 and F_InfoConSmallType is not null ").Tables[0].Rows.Count;//月
  58. if (n == 0)
  59. {
  60. sb.Append("<td bgcolor=\"#FFFFFF\">" + dt.Rows[n]["F_Value"] + "</td><td bgcolor=\"#FFFFFF\">" + M_count.ToString() + "</td><td bgcolor=\"#FFFFFF\">" + T_count.ToString() + "</td></tr>");
  61. }
  62. else
  63. {
  64. sb.Append("<tr style=\"border:1px solid #E0EEFE\" align=\"center\"><td bgcolor=\"#FFFFFF\">" + dt.Rows[n]["F_Value"] + "</td><td bgcolor=\"#FFFFFF\">" + M_count.ToString() + "</td><td bgcolor=\"#FFFFFF\">" + T_count.ToString() + "</td></tr>");
  65. }
  66. T_Allcount += T_count;//累积数
  67. M_Allcount += M_count;//当月数
  68. }
  69. }
  70. else
  71. {
  72. //只有一个的
  73. //int T_count = WorkOrder.GetList(" F_InfoType=" + row["F_ValueId"].ToString() + " and F_IsClosed=1 and DateDiff(yy,F_RegDate,'" + date + "')=0 and DateDiff(d,F_RegDate,'" + date + "')>=0").Tables[0].Rows.Count;
  74. //int M_count = WorkOrder.GetList(" F_InfoType=" + row["F_ValueId"].ToString() + " and F_IsClosed=1 and DateDiff(mm,F_RegDate,'" + date + "')=0").Tables[0].Rows.Count;
  75. int T_count = WorkOrder.GetList(" F_IsDelete=0 and F_InfoType=" + row["F_ValueId"].ToString() + " and DateDiff(yy,F_RegDate,'" + date + "')=0 and DateDiff(d,F_RegDate,'" + date + "')>=0 and F_InfoConSmallType is not null ").Tables[0].Rows.Count;
  76. int M_count = WorkOrder.GetList(" F_IsDelete=0 and F_InfoType=" + row["F_ValueId"].ToString() + " and DateDiff(mm,F_RegDate,'" + date + "')=0 and F_InfoConSmallType is not null ").Tables[0].Rows.Count;
  77. sb.Append("<tr style=\"border:1px solid #E0EEFE\" align=\"center\"><td bgcolor=\"#FFFFFF\" colspan=\"2\">" + row["F_Value"] + "</td><td bgcolor=\"#FFFFFF\">" + M_count.ToString() + "</td><td bgcolor=\"#FFFFFF\">" + T_count.ToString() + "</td></tr>");
  78. T_Allcount += T_count;
  79. M_Allcount += M_count;
  80. }
  81. }
  82. //sb.Append("<tr><td colspan =\"2\" bgcolor=\"#FFFFFF\" align=\"center\">合计</td><td bgcolor=\"#FFFFFF\" align=\"center\">" + M_Allcount + "</td><td bgcolor=\"#FFFFFF\" align=\"center\">" + T_Allcount + "</td></tr>");
  83. T_Allcount = 0;
  84. M_Allcount = 0;
  85. sb.Append("<tr style=\"border:1px solid #E0EEFE \" height=\"20px\" align=\"center\" ><td bgcolor=\"#FFFFFF\" colspan =\"4\"></td></tr>");
  86. DataSet _ds = DictionaryValue.GetList(" F_ItemId=6");
  87. foreach (DataRow row in _ds.Tables[0].Rows)
  88. {
  89. //int T_count = WorkOrder.GetList(" F_InfoSource=" + row["F_ValueId"].ToString() + " and F_IsClosed=1 and DateDiff(yy,F_RegDate,'" + date + "')=0 and DateDiff(d,F_RegDate,'" + date + "')>=0").Tables[0].Rows.Count;
  90. //int M_count = WorkOrder.GetList(" F_InfoSource=" + row["F_ValueId"].ToString() + " and F_IsClosed=1 and DateDiff(mm,F_RegDate,'" + date + "')=0").Tables[0].Rows.Count;
  91. int T_count = WorkOrder.GetList(" F_InfoSource=" + row["F_ValueId"].ToString() + " and DateDiff(yy,F_RegDate,'" + date + "')=0 and DateDiff(d,F_RegDate,'" + date + "')>=0").Tables[0].Rows.Count;
  92. int M_count = WorkOrder.GetList(" F_InfoSource=" + row["F_ValueId"].ToString() + " and DateDiff(mm,F_RegDate,'" + date + "')=0").Tables[0].Rows.Count;
  93. sb.Append("<tr style=\"border:1px solid #E0EEFE\" align=\"center\"><td bgcolor=\"#FFFFFF\" colspan=\"2\">" + row["F_Value"] + "</td><td bgcolor=\"#FFFFFF\">" + M_count.ToString() + "</td><td bgcolor=\"#FFFFFF\">" + T_count.ToString() + "</td></tr>");
  94. T_Allcount += T_count;
  95. M_Allcount += M_count;
  96. }
  97. sb.Append("<tr style=\"border:1px solid #E0EEFE\" align=\"center\"><td colspan =\"2\" bgcolor=\"#FFFFFF\">合计</td><td bgcolor=\"#FFFFFF\">" + M_Allcount + "</td><td bgcolor=\"#FFFFFF\">" + T_Allcount + "</td></tr>");
  98. sb.Append("<tr style=\"border:1px solid #E0EEFE \" height=\"20px\" align=\"center\" ><td bgcolor=\"#FFFFFF\" colspan =\"4\"></td></tr>");
  99. //int count1 = WorkOrder.GetList(" F_IsResult=1 and F_IsClosed=1 and DateDiff(yy,F_RegDate,'" + date + "')=0 and DateDiff(d,F_RegDate,'" + date + "')>=0").Tables[0].Rows.Count;
  100. //int countm1 = WorkOrder.GetList(" F_IsResult=1 and F_IsClosed=1 and DateDiff(m,F_RegDate,'" + date + "')=0").Tables[0].Rows.Count;
  101. //int count2 = WorkOrder.GetList(" F_IsResult=0 and F_IsClosed=1 and DateDiff(yy,F_RegDate,'" + date + "')=0 and DateDiff(d,F_RegDate,'" + date + "')>=0").Tables[0].Rows.Count;
  102. //int countm2 = WorkOrder.GetList(" F_IsResult=0 and F_IsClosed=1 and DateDiff(m,F_RegDate,'" + date + "')=0").Tables[0].Rows.Count;
  103. int count1 = WorkOrder.GetList(" F_IsResult=1 and DateDiff(yy,F_RegDate,'" + date + "')=0 and DateDiff(d,F_RegDate,'" + date + "')>=0").Tables[0].Rows.Count;
  104. int countm1 = WorkOrder.GetList(" F_IsResult=1 and DateDiff(m,F_RegDate,'" + date + "')=0").Tables[0].Rows.Count;
  105. int count2 = WorkOrder.GetList(" F_IsResult=0 and DateDiff(yy,F_RegDate,'" + date + "')=0 and DateDiff(d,F_RegDate,'" + date + "')>=0").Tables[0].Rows.Count;
  106. int countm2 = WorkOrder.GetList(" F_IsResult=0 and DateDiff(m,F_RegDate,'" + date + "')=0").Tables[0].Rows.Count;
  107. sb.Append("<tr style=\"border:1px solid #E0EEFE\" align=\"center\"><td bgcolor=\"#FFFFFF\" colspan =\"2\">直办</td><td bgcolor=\"#FFFFFF\">" + countm1 + "</td><td bgcolor=\"#FFFFFF\">" + count1 + "</td></tr>");
  108. sb.Append("<tr style=\"border:1px solid #E0EEFE\" align=\"center\"><td colspan =\"2\" bgcolor=\"#FFFFFF\">督办</td><td bgcolor=\"#FFFFFF\">" + countm2 + "</td><td bgcolor=\"#FFFFFF\">" + count2 + "</td></tr></table>");
  109. return Success("成功", sb.ToString());
  110. }
  111. /// <summary>
  112. /// 导出投诉统计
  113. /// </summary>
  114. /// <returns></returns>
  115. public ActionResult ExportTSCountList()
  116. {
  117. string year = RequestString.GetQueryString("year");
  118. string month = RequestString.GetQueryString("month");
  119. if (string.IsNullOrEmpty(year))
  120. {
  121. year = DateTime.Now.ToString("yyyy");
  122. }
  123. if (string.IsNullOrEmpty(month))
  124. {
  125. month = DateTime.Now.ToString("MM");
  126. }
  127. BLL.T_Sys_DictionaryValue DictionaryValue = new BLL.T_Sys_DictionaryValue();
  128. string day = DateTime.DaysInMonth(int.Parse(year), int.Parse(month)).ToString();
  129. string date = year + "." + month + "." + day;
  130. DataTable dtNew = new DataTable();
  131. DataColumn dc1 = new DataColumn("类别", Type.GetType("System.String"));
  132. DataColumn dc2 = new DataColumn("类别1", Type.GetType("System.String"));
  133. DataColumn dc3 = new DataColumn("当月数", Type.GetType("System.String"));
  134. DataColumn dc4 = new DataColumn("累计数", Type.GetType("System.String"));
  135. dtNew.Columns.Add(dc1);
  136. dtNew.Columns.Add(dc2);
  137. dtNew.Columns.Add(dc3);
  138. dtNew.Columns.Add(dc4);
  139. int tscount = 0;
  140. DataSet ds = DictionaryValue.GetList(" F_ItemId=2");
  141. foreach (DataRow row in ds.Tables[0].Rows)
  142. {
  143. DataTable dt = DictionaryValue.GetList(" F_PrentId=" + row["F_ValueId"].ToString()).Tables[0];//获取列表
  144. if (dt != null && dt.Rows.Count > 1)
  145. {
  146. tscount = dt.Rows.Count;
  147. for (int n = 0; n < dt.Rows.Count; n++)
  148. {
  149. //内容大类
  150. int T_count = WorkOrder.GetList(" F_IsDelete=0 and F_InfoConBigType=" + dt.Rows[n]["F_ValueId"].ToString() + " and DateDiff(yy,F_RegDate,'" + date + "')=0 and DateDiff(d,F_RegDate,'" + date + "')>=0 and F_InfoConSmallType is not null ").Tables[0].Rows.Count;//当年
  151. int M_count = WorkOrder.GetList(" F_IsDelete=0 and F_InfoConBigType=" + dt.Rows[n]["F_ValueId"].ToString() + " and DateDiff(mm,F_RegDate,'" + date + "')=0 and F_InfoConSmallType is not null ").Tables[0].Rows.Count;//月
  152. DataRow drNew = dtNew.NewRow();
  153. drNew["类别"] = row["F_Value"].ToString();
  154. drNew["类别1"] = dt.Rows[n]["F_Value"].ToString();
  155. drNew["当月数"] = M_count;
  156. drNew["累计数"] = T_count;
  157. dtNew.Rows.Add(drNew);
  158. }
  159. }
  160. else
  161. {
  162. //只有一个的
  163. int T_count = WorkOrder.GetList(" F_IsDelete=0 and F_InfoType=" + row["F_ValueId"].ToString() + " and DateDiff(yy,F_RegDate,'" + date + "')=0 and DateDiff(d,F_RegDate,'" + date + "')>=0 and F_InfoConSmallType is not null ").Tables[0].Rows.Count;
  164. int M_count = WorkOrder.GetList(" F_IsDelete=0 and F_InfoType=" + row["F_ValueId"].ToString() + " and DateDiff(mm,F_RegDate,'" + date + "')=0 and F_InfoConSmallType is not null ").Tables[0].Rows.Count;
  165. DataRow drNew = dtNew.NewRow();
  166. drNew["类别"] = row["F_Value"].ToString();
  167. drNew["类别1"] = row["F_Value"].ToString();
  168. drNew["当月数"] = M_count;
  169. drNew["累计数"] = T_count;
  170. dtNew.Rows.Add(drNew);
  171. }
  172. }
  173. DataSet _ds = DictionaryValue.GetList(" F_ItemId=6");
  174. foreach (DataRow row in _ds.Tables[0].Rows)
  175. {
  176. int T_count = WorkOrder.GetList(" F_InfoSource=" + row["F_ValueId"].ToString() + " and DateDiff(yy,F_RegDate,'" + date + "')=0 and DateDiff(d,F_RegDate,'" + date + "')>=0").Tables[0].Rows.Count;
  177. int M_count = WorkOrder.GetList(" F_InfoSource=" + row["F_ValueId"].ToString() + " and DateDiff(mm,F_RegDate,'" + date + "')=0").Tables[0].Rows.Count;
  178. DataRow drNew = dtNew.NewRow();
  179. drNew["类别"] = row["F_Value"].ToString();
  180. drNew["类别1"] = row["F_Value"].ToString();
  181. drNew["当月数"] = M_count;
  182. drNew["累计数"] = T_count;
  183. dtNew.Rows.Add(drNew);
  184. }
  185. int count1 = WorkOrder.GetList(" F_IsResult=1 and DateDiff(yy,F_RegDate,'" + date + "')=0 and DateDiff(d,F_RegDate,'" + date + "')>=0").Tables[0].Rows.Count;
  186. int countm1 = WorkOrder.GetList(" F_IsResult=1 and DateDiff(m,F_RegDate,'" + date + "')=0").Tables[0].Rows.Count;
  187. int count2 = WorkOrder.GetList(" F_IsResult=0 and DateDiff(yy,F_RegDate,'" + date + "')=0 and DateDiff(d,F_RegDate,'" + date + "')>=0").Tables[0].Rows.Count;
  188. int countm2 = WorkOrder.GetList(" F_IsResult=0 and DateDiff(m,F_RegDate,'" + date + "')=0").Tables[0].Rows.Count;
  189. DataRow drNew1 = dtNew.NewRow();
  190. drNew1["类别"] = "直办";
  191. drNew1["类别1"] = "直办";
  192. drNew1["当月数"] = countm1;
  193. drNew1["累计数"] = count1;
  194. dtNew.Rows.Add(drNew1);
  195. DataRow drNew2 = dtNew.NewRow();
  196. drNew2["类别"] = "督办";
  197. drNew2["类别1"] = "督办";
  198. drNew2["当月数"] = countm2;
  199. drNew2["累计数"] = count2;
  200. dtNew.Rows.Add(drNew2);
  201. NPOIHelper npoi = new NPOIHelper();
  202. if (npoi.TSExportToExcel(dtNew, tscount) == "")
  203. {
  204. return Success("导出成功");
  205. }
  206. else
  207. {
  208. return Error("导出失败");
  209. }
  210. }
  211. /// <summary>
  212. /// 逾期统计
  213. /// </summary>
  214. /// <returns></returns>
  215. [Authority]
  216. public ActionResult GetYQCountList(int isdc = 0, int deptid = 0)
  217. {
  218. string starttime = RequestString.GetQueryString("starttime");
  219. string endtime = RequestString.GetQueryString("endtime");
  220. if (string.IsNullOrEmpty(starttime))
  221. {
  222. starttime = DateTime.Now.ToString("yyyy-MM") + "-01";
  223. }
  224. if (string.IsNullOrEmpty(endtime))
  225. {
  226. endtime = DateTime.Now.ToString("yyyy-MM-dd");
  227. }
  228. starttime = starttime + " 00:00:00";
  229. endtime = endtime + " 23:59:59";
  230. string sqlwhere = "";
  231. if (User.F_RoleCode == "WLDW")
  232. {
  233. sqlwhere += "and a.F_MainDeptId='" + User.F_DeptId + "'";
  234. }
  235. else
  236. {
  237. if (deptid > 0)
  238. {
  239. sqlwhere += "and a.F_MainDeptId='" + deptid + "'";
  240. }
  241. }
  242. string sql = "select * from(select dbo.GetDeptNames(F_MainDeptId) F_DeptName,F_WorkOrderId,F_ComContent,F_AssignTime,F_LimitTime,F_DealTime,(SELECT COUNT(1) FROM T_Sys_WorkOFFDays WITH(NOLOCK) WHERE F_OffState = 1 AND F_OffDate<(case when a.F_DealTime is null then GETDATE() else a.F_DealTime end) AND F_OffDate> a.F_LimitTime) F_OverDay from T_Bus_WorkOrder a WITH(NOLOCK)where a.F_IsDelete=0 "+ sqlwhere + " and a.F_IsResult != 1 and a.F_CreateTime >= '" + starttime + "' and a.F_CreateTime <= '"+ endtime + "' and F_MainDeptId> 0) b where b.F_OverDay > 0 order by b.F_DeptName";
  243. var dt = DbHelperSQL.Query(sql).Tables[0];
  244. string[] cols = { "单位", "编号", "内容", "转办日期", "应反馈日期", "反馈日期", "逾期天数" };
  245. if (isdc > 0)
  246. {
  247. NPOIHelper npoi = new NPOIHelper();
  248. if (npoi.ExportToExcel("逾期报表", dt, cols) == "")
  249. {
  250. return Success("导出成功");
  251. }
  252. else
  253. {
  254. return Error("导出失败");
  255. }
  256. }
  257. var obj = new
  258. {
  259. cols = cols,
  260. data = dt
  261. };
  262. return Success("成功", obj);
  263. }
  264. /// <summary>
  265. /// 部门统计
  266. /// </summary>
  267. /// <returns></returns>
  268. public ActionResult GetDeptCountList()
  269. {
  270. string year = RequestString.GetQueryString("year");
  271. string month = RequestString.GetQueryString("month");
  272. if (string.IsNullOrEmpty(year))
  273. {
  274. year = DateTime.Now.ToString("yyyy");
  275. }
  276. if (string.IsNullOrEmpty(month))
  277. {
  278. month = DateTime.Now.ToString("MM");
  279. }
  280. string day = DateTime.Now.ToString("dd");
  281. if (year != DateTime.Now.ToString("yyyy") || month != DateTime.Now.ToString("MM"))
  282. {
  283. day = DateTime.DaysInMonth(int.Parse(year), int.Parse(month)).ToString();
  284. }
  285. string date = year + "." + month + "." + day;
  286. string bjmonth = DateTime.Now.AddMonths(-1).ToString("MM");
  287. string bjsdate = year + "-" + bjmonth + "-25 23:59:59";
  288. string bjedate = year + "-" + month + "-25 23:59:59";
  289. DataTable dt = new BLL.T_Sys_Department().GetAllList().Tables[0];
  290. dt.Columns.Add("slcount", typeof(int));
  291. dt.Columns.Add("cfjcount", typeof(int));
  292. dt.Columns.Add("yqcount", typeof(int));
  293. dt.Columns.Add("bjl", typeof(string));
  294. string regDate = new BLL.T_Sys_WorkCalendar().GetOverDay(date, "7", 0);
  295. foreach (DataRow dr in dt.Rows)
  296. {
  297. string did = dr["F_DeptId"].ToString();
  298. string sql = "select * from T_Bus_WorkOrder where F_IsDelete=0 and DateDiff(yy,F_RegDate,'" + date + "')=0 and DateDiff(m,F_RegDate,'" + date + "')=0 and F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedInfo where F_DeptId='" + did + "') ";
  299. var dtsl = DbHelperSQL.Query(sql).Tables[0];
  300. dr["slcount"] = dtsl.Rows.Count;
  301. dr["cfjcount"] = dtsl.Select(" F_InfoType='8'").Count();
  302. //dr["yqcount"] = WorkOrder.getOverDueWorkOrder(regDate, did).Rows.Count;
  303. string sql1 = "select * from T_Bus_WorkOrder where F_IsDelete=0 and F_RegDate>'" + bjsdate + "' and F_RegDate<='" + bjedate + "' and F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedInfo where F_DeptId='" + did + "') ";
  304. var dtsl1 = DbHelperSQL.Query(sql1).Tables[0];
  305. var bj = dtsl1.Select(" F_WorkState='22'");
  306. double percent = Convert.ToDouble(bj.Count()) / Convert.ToDouble(dtsl1.Rows.Count);
  307. dr["bjl"] = string.Format("{0:0.00%}", percent);//得到5.88%
  308. }
  309. return Success("成功", dt);
  310. }
  311. /// <summary>
  312. /// 逾期工单报表
  313. /// </summary>
  314. /// <returns></returns>
  315. public ActionResult GetDeptYiQiList(int isdc = 0)
  316. {
  317. string starttime = RequestString.GetQueryString("starttime");
  318. string endtime = RequestString.GetQueryString("endtime");
  319. if (string.IsNullOrEmpty(starttime))
  320. {
  321. starttime = DateTime.Now.ToString("yyyy-MM") + "-01";
  322. }
  323. if (string.IsNullOrEmpty(endtime))
  324. {
  325. endtime = DateTime.Now.ToString("yyyy-MM-dd");
  326. }
  327. starttime = starttime + " 00:00:00";
  328. endtime = endtime + " 23:59:59";
  329. string sql = "select F_DeptName DeptName,Count(1) [Count] from(select dbo.GetDeptNames(F_MainDeptId) F_DeptName,F_WorkOrderId,F_ComContent,F_AssignTime,F_LimitTime,F_DealTime,(SELECT COUNT(1) FROM T_Sys_WorkOFFDays WITH(NOLOCK) WHERE F_OffState = 1 AND F_OffDate<(case when a.F_DealTime is null then GETDATE() else a.F_DealTime end) AND F_OffDate> a.F_LimitTime) F_OverDay from T_Bus_WorkOrder a WITH(NOLOCK)where a.F_IsDelete=0 and a.F_IsResult != 1 and a.F_CreateTime >= '" + starttime + "' and a.F_CreateTime <= '" + endtime + "' and F_MainDeptId> 0) b where b.F_OverDay > 0 Group By F_DeptName order by Count(1) desc";
  330. var dt = DbHelperSQL.Query(sql).Tables[0];
  331. string[] cols = { "交办单位", "逾期统计" };
  332. if (isdc > 0)
  333. {
  334. NPOIHelper npoi = new NPOIHelper();
  335. if (npoi.ExportToExcel("逾期统计", dt, cols) == "")
  336. {
  337. return Success("导出成功");
  338. }
  339. else
  340. {
  341. return Error("导出失败");
  342. }
  343. }
  344. var obj = new
  345. {
  346. cols = cols,
  347. data = dt
  348. };
  349. return Success("成功", obj);
  350. }
  351. /// <summary>
  352. /// 办理情况统计(台账)
  353. /// </summary>
  354. /// <returns></returns>
  355. public ActionResult GetDealList(int isdc = 0)
  356. {
  357. int keyid = RequestString.GetInt("keyid", 0);
  358. string yearmonth = RequestString.GetQueryString("yearmonth");
  359. string month = RequestString.GetQueryString("month");
  360. if (string.IsNullOrEmpty(yearmonth))
  361. {
  362. yearmonth = DateTime.Now.ToString("yyyy-MM");
  363. }
  364. string sqlwhere = " and a.F_IsDelete=0 ";
  365. string sql = string.Empty;
  366. if (keyid != 0)
  367. {
  368. sql = " INNER JOIN [GetValueId]('" + keyid + "') Value on a.F_Key = Value.F_ValueId";
  369. }
  370. string starttime = yearmonth + "-01";
  371. string endtime = DateTime.Parse(starttime).AddMonths(1).ToString("yyyy-MM-dd");
  372. sqlwhere += " and a.F_CreateTime between '" + starttime + "' and '" + endtime + "'";
  373. string strpageindex = RequestString.GetQueryString("page");
  374. int pageindex = 1;
  375. string strpagesize = RequestString.GetQueryString("pagesize");
  376. int pagesize = 10;
  377. if (strpageindex.Trim() != "")
  378. {
  379. pageindex = Convert.ToInt32(strpageindex);
  380. }
  381. if (strpagesize.Trim() != "")
  382. {
  383. pagesize = Convert.ToInt32(strpagesize);
  384. }
  385. string[] colNames = { "序号", "受理编号", "办理部门", "办结时间", "内容摘要", "办理结果", "备注", "投诉人", "联系人" };
  386. if (isdc > 0)
  387. {
  388. string sqls = "select ROW_NUMBER() OVER (ORDER BY F_CreateTime asc) row,F_WorkOrderId, (case when F_IsResult=1 then '市长热线' else dbo.GetDeptNames(F_MainDeptId) end) F_DeptName,F_DealTime,F_ComContent,F_Result,dbo.GetDictionaryName(F_InfoSource) F_SourceName, F_CusPhone,F_ConPhone From T_Bus_WorkOrder a WITH(NOLOCK) " + sql + " where 1=1 " + sqlwhere;
  389. var dt = DbHelperSQL.Query(sqls).Tables[0];
  390. NPOIHelper npoi = new NPOIHelper();
  391. if (npoi.ExportToExcel(yearmonth + "台账", dt, colNames) == "")
  392. {
  393. return Success("导出成功");
  394. }
  395. else
  396. {
  397. return Error("导出失败");
  398. }
  399. }
  400. else
  401. {
  402. string cols = "F_WorkOrderId,(case when F_IsResult=1 then '市长热线' else dbo.GetDeptNames(F_MainDeptId) end ) F_DeptName,F_DealTime,F_ComContent,F_Result,dbo.GetDictionaryName(F_InfoSource) F_SourceName, F_CusPhone,F_ConPhone";
  403. int recordCount = 0;
  404. var dt = BLL.PagerBLL.GetListPager(
  405. "T_Bus_WorkOrder a WITH(NOLOCK)" + sql,
  406. "F_Id",
  407. cols,
  408. sqlwhere,
  409. "ORDER BY F_CreateTime DESC",
  410. pagesize,
  411. pageindex,
  412. true,
  413. out recordCount);
  414. var obj = new
  415. {
  416. state = "success",
  417. message = "成功",
  418. rows = dt,
  419. total = recordCount
  420. };
  421. return Content(obj.ToJson());
  422. }
  423. }
  424. }
  425. }