市长热线演示版

OneUserAPI.ashx.cs 37KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.SessionState;
  6. using System.Text;
  7. using System.Data;
  8. namespace HySoft.BaseCallCenter.Web.reportmanage.operationdata.controls
  9. {
  10. /// <summary>
  11. /// OneUserAPI 的摘要说明
  12. /// </summary>
  13. public class OneUserAPI : IHttpHandler
  14. {
  15. public void ProcessRequest(HttpContext context)
  16. {
  17. context.Response.ContentType = "text/plain";
  18. string action = context.Request.QueryString["action"];
  19. switch (action)
  20. {
  21. case "getlist":
  22. context.Response.Write(GetDataListHtml(context));//读取数据
  23. break;
  24. }
  25. }
  26. public string GetDataListHtml(HttpContext context)
  27. {
  28. StringBuilder htmlReport = new StringBuilder();//存储生成的HTML
  29. //拼接表头
  30. htmlReport.Append("<table cellspacing='0' cellpadding='0' border='1' width='100%'><tr height='35'>");
  31. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>部门名称</td>");
  32. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>工程师姓名</td>");
  33. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>事件总数</td>");
  34. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>一般事件响应及时数</td>");
  35. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>紧急事件响应及时数</td>");
  36. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>事件响应及时率</td>");
  37. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>一般事件解决及时数</td>");
  38. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>紧急事件解决及时数</td>");
  39. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>事件解决及时率</td>");
  40. //htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>紧急事件响应及时率</td>");
  41. //htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>紧急事件解决及时率</td>");
  42. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>事件解决数</td>");
  43. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>事件解决率</td>");
  44. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>事件平均解决时间(小时)</td>");
  45. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>回访评分总和</td>");
  46. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>回访事件总数</td>");
  47. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>客户评分</td>");
  48. htmlReport.Append("</tr>");
  49. try
  50. {
  51. //前台传来的开始时间结束时间
  52. string txtStartTime = context.Request.QueryString["txtStartTime"];
  53. string txtEndTime = context.Request.QueryString["txtEndTime"];
  54. //拼接时间查询语句
  55. string sqltimeHistory = "";
  56. if (txtStartTime != null && txtStartTime.Trim() != "")
  57. {
  58. sqltimeHistory += " and CONVERT(varchar , F_OPTDATE, 120)>=CONVERT(varchar , '" + txtStartTime.Trim() + " 00:00:01', 120) ";
  59. }
  60. if (txtEndTime != null && txtEndTime.Trim() != "")
  61. {
  62. sqltimeHistory += " and CONVERT(varchar , F_OPTDATE, 120)<=CONVERT(varchar , '" + txtEndTime.Trim() + " 23:59:59', 120) ";
  63. }
  64. string sqltimeTask = "";
  65. if (txtStartTime != null && txtStartTime.Trim() != "")
  66. {
  67. sqltimeTask += " and CONVERT(varchar , F_CREATEDATE, 120)>=CONVERT(varchar , '" + txtStartTime.Trim() + " 00:00:01', 120) ";
  68. }
  69. if (txtEndTime != null && txtEndTime.Trim() != "")
  70. {
  71. sqltimeTask += " and CONVERT(varchar , F_CREATEDATE, 120)<=CONVERT(varchar , '" + txtEndTime.Trim() + " 23:59:59', 120) ";
  72. }
  73. //定义总结时候的一些变量
  74. double zong1 = 0;
  75. double zong2 = 0;
  76. double zong3 = 0;
  77. double zong4 = 0;
  78. double zong5 = 0;
  79. double zong6 = 0;
  80. double zong7 = 0;
  81. double zong8 = 0;
  82. double zongtime = 0;
  83. int zongtimecount = 0;
  84. double zongfen = 0;
  85. int zongfencount = 0;
  86. int count = 0;
  87. int gerenfenshu = 0;
  88. int gerencount = 0;
  89. //定义是否及时处理的时间变量
  90. #region 查询在字典那块设置的时间
  91. string ybgdJDcaoshi = "15552000";
  92. string ybgdCLcaoshi = "15552000";
  93. string jjgdJDcaoshi = "15552000";
  94. string jjgdCLcaoshi = "15552000";
  95. string sqlybgd = "SELECT * from T_Sys_DictionaryValue where F_DictionaryFlag='ybgd' order by F_Sort ";
  96. DataTable dtybgd = DBUtility.DbHelperSQL.Query(sqlybgd).Tables[0];
  97. if (dtybgd.Rows.Count > 1)
  98. {
  99. ybgdJDcaoshi = (Convert.ToInt32(dtybgd.Rows[0]["F_Name"]) * 3600).ToString();
  100. ybgdCLcaoshi = (Convert.ToInt32(dtybgd.Rows[1]["F_Name"]) * 3600).ToString();
  101. }
  102. string sqljjgd = "SELECT * from T_Sys_DictionaryValue where F_DictionaryFlag='jjgd' order by F_Sort ";
  103. DataTable dtjjgd = DBUtility.DbHelperSQL.Query(sqljjgd).Tables[0];
  104. if (dtjjgd.Rows.Count > 1)
  105. {
  106. jjgdJDcaoshi = (Convert.ToInt32(dtybgd.Rows[0]["F_Name"]) * 3600).ToString();
  107. jjgdCLcaoshi = (Convert.ToInt32(dtybgd.Rows[1]["F_Name"]) * 3600).ToString();
  108. }
  109. #endregion
  110. #region 查询在告警超时那块设置的时间
  111. //string JDcaoshi = "15552000";
  112. //string CLcaoshi = "15552000";
  113. //string sqlCLcaoshi = "select * from T_Wo_StateAlarmDate where F_WorkOrderTypeId=16 and F_WorkOrderStateId=7";
  114. //DataTable dtCLcaoshi = DBUtility.DbHelperSQL.Query(sqlCLcaoshi).Tables[0];
  115. //if (dtCLcaoshi.Rows.Count > 0)
  116. //{
  117. // if (Convert.ToInt32(dtCLcaoshi.Rows[0]["F_Ccount"]) > 0)
  118. // {
  119. // if (Convert.ToInt32(dtCLcaoshi.Rows[0]["F_Cunit"]) == 1)
  120. // {
  121. // CLcaoshi = (Convert.ToInt32(dtCLcaoshi.Rows[0]["F_Ccount"]) * 3600).ToString();
  122. // }
  123. // else if (Convert.ToInt32(dtCLcaoshi.Rows[0]["F_Cunit"]) == 2)
  124. // {
  125. // CLcaoshi = (Convert.ToInt32(dtCLcaoshi.Rows[0]["F_Ccount"]) * 3600 * 24).ToString();
  126. // }
  127. // else
  128. // {
  129. // CLcaoshi = (Convert.ToInt32(dtCLcaoshi.Rows[0]["F_Ccount"]) * 60).ToString();
  130. // }
  131. // }
  132. //}
  133. //string sqlcaoshi = "select * from T_Wo_StateAlarmDate where F_WorkOrderTypeId=16 and F_WorkOrderStateId=6";
  134. //DataTable dtJDcaoshi = DBUtility.DbHelperSQL.Query(sqlcaoshi).Tables[0];
  135. //if (dtJDcaoshi.Rows.Count > 0)
  136. //{
  137. // if (Convert.ToInt32(dtJDcaoshi.Rows[0]["F_Ccount"]) > 0)
  138. // {
  139. // if (Convert.ToInt32(dtJDcaoshi.Rows[0]["F_Cunit"]) == 1)
  140. // {
  141. // JDcaoshi = (Convert.ToInt32(dtJDcaoshi.Rows[0]["F_Ccount"]) * 3600).ToString();
  142. // }
  143. // else if (Convert.ToInt32(dtJDcaoshi.Rows[0]["F_Cunit"]) == 2)
  144. // {
  145. // JDcaoshi = (Convert.ToInt32(dtJDcaoshi.Rows[0]["F_Ccount"]) * 3600 * 24).ToString();
  146. // }
  147. // else
  148. // {
  149. // JDcaoshi = (Convert.ToInt32(dtJDcaoshi.Rows[0]["F_Ccount"]) * 60).ToString();
  150. // }
  151. // }
  152. //}
  153. #endregion
  154. //查询出来所有部门,按照工单量的多少排序
  155. DataTable dtDept = new DataTable();
  156. string sqlDept = "SELECT distinct(F_DeptId),(select COUNT(*) from T_Wo_WorkOrderTask where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderBase where 1=1 " + sqltimeTask + " ) and F_WORKORDERSTATEID=6 and F_OWNERID in(SELECT F_UserId from T_Sys_UserAccount where F_DeptId=t.F_DeptId and F_RoleId=30)" + sqltimeTask + ") as counts,(SELECT F_DeptName from T_Sys_Department where F_DeptId=t.F_DeptId) as deptname from T_Sys_UserAccount t where F_RoleId=30 order by counts desc ";
  157. dtDept = DBUtility.DbHelperSQL.Query(sqlDept).Tables[0];
  158. for (int j = 0; j < dtDept.Rows.Count; j++)
  159. {
  160. //工单量是0的跳出
  161. if (dtDept.Rows[j]["counts"] == null || dtDept.Rows[j]["counts"].ToString() == "" || dtDept.Rows[j]["counts"].ToString() == "0")
  162. {
  163. continue;
  164. }
  165. DataTable dt = new DataTable();
  166. //查询出来部门下的所有人员,按照工单量多少排序
  167. string sql = "select t.* from (SELECT *,(select COUNT(*) from T_Wo_WorkOrderTask where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderBase where 1=1 " + sqltimeTask + " ) and F_WORKORDERSTATEID=6 and F_OWNERID=T_Sys_UserAccount.F_UserId " + sqltimeTask + ") as counts from T_Sys_UserAccount where F_RoleId=30 and F_DeptId=" + dtDept.Rows[j]["F_DeptId"].ToString() + " ) t where t.counts>0 order by counts desc ";
  168. dt = DBUtility.DbHelperSQL.Query(sql).Tables[0];
  169. int s = dt.Rows.Count + 1;
  170. htmlReport.AppendFormat("<td rowspan='" + s + "' align='center' style='width:120px; vertical-align: middle; border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px;height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", dtDept.Rows[j]["deptname"].ToString());
  171. for (int i = 0; i < dt.Rows.Count; i++)
  172. {
  173. //查出来该人员的总工单量,接收的工单量,处理的工单量,已处理完成的工单量
  174. //sql = " select (select COUNT(*) from T_Wo_WorkOrderTask where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderBase where 1=1 " + sqltimeTask + " ) and F_WORKORDERSTATEID=6 and F_OWNERID=" + dt.Rows[i]["F_UserId"].ToString() + "" + sqltimeTask + ") as counts,";
  175. //sql += "(select count(*) from T_Wo_WorkOrderHistory where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderBase where 1=1 " + sqltimeTask + " ) and F_WORKORDERSTATEID=6 and F_OPTUSERID=" + dt.Rows[i]["F_UserId"].ToString() + " and F_ELAPSEDTIME<" + JDcaoshi + "" + sqltimeHistory + ") as ybgdjiedan,";
  176. //sql += "(select count(*) from T_Wo_WorkOrderHistory where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderBase where 1=1 " + sqltimeTask + " ) and F_WORKORDERSTATEID=7 and F_OPTUSERID=" + dt.Rows[i]["F_UserId"].ToString() + " and F_ELAPSEDTIME<" + CLcaoshi + "" + sqltimeHistory + ") as ybgdchuli,";
  177. //sql += "(select count(*) from T_Wo_WorkOrderHistory where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderBase where 1=1 " + sqltimeTask + " ) and F_WORKORDERSTATEID=7 and F_OPTUSERID=" + dt.Rows[i]["F_UserId"].ToString() + " and F_ELAPSEDTIME is not null" + sqltimeHistory + ") as jiejue ";
  178. sql = " select (select COUNT(*) from T_Wo_WorkOrderTask where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderBase where 1=1 " + sqltimeTask + " ) and F_WORKORDERSTATEID=6 and F_OWNERID=" + dt.Rows[i]["F_UserId"].ToString() + "" + sqltimeTask + ") as counts,";
  179. sql += "(select count(*) from T_Wo_WorkOrderHistory where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderBase where 1=1 and F_REPAIRLEVEL is null or F_REPAIRLEVEL!=396 " + sqltimeTask + " ) and F_WORKORDERSTATEID=6 and F_OPTUSERID=" + dt.Rows[i]["F_UserId"].ToString() + " and F_ELAPSEDTIME<" + ybgdJDcaoshi + "" + sqltimeHistory + ") as ybgdjiedan,";
  180. sql += "(select count(*) from T_Wo_WorkOrderHistory where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderBase where 1=1 and F_REPAIRLEVEL is null or F_REPAIRLEVEL!=396 " + sqltimeTask + " ) and F_WORKORDERSTATEID=7 and F_OPTUSERID=" + dt.Rows[i]["F_UserId"].ToString() + " and F_ELAPSEDTIME<" + ybgdCLcaoshi + "" + sqltimeHistory + ") as ybgdchuli,";
  181. sql += "(select count(*) from T_Wo_WorkOrderHistory where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderBase where 1=1 and F_REPAIRLEVEL=396 " + sqltimeTask + " ) and F_WORKORDERSTATEID=6 and F_OPTUSERID=" + dt.Rows[i]["F_UserId"].ToString() + " and F_ELAPSEDTIME<" + jjgdJDcaoshi + "" + sqltimeHistory + ") as jjgdjiedan,";
  182. sql += "(select count(*) from T_Wo_WorkOrderHistory where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderBase where 1=1 and F_REPAIRLEVEL=396 " + sqltimeTask + " ) and F_WORKORDERSTATEID=7 and F_OPTUSERID=" + dt.Rows[i]["F_UserId"].ToString() + " and F_ELAPSEDTIME<" + jjgdCLcaoshi + "" + sqltimeHistory + ") as jjgdchuli,";
  183. sql += "(select count(*) from T_Wo_WorkOrderHistory where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderBase where 1=1 " + sqltimeTask + " ) and F_WORKORDERSTATEID=7 and F_OPTUSERID=" + dt.Rows[i]["F_UserId"].ToString() + " and F_ELAPSEDTIME is not null" + sqltimeHistory + ") as jiejue ";
  184. DataTable dt1 = new DataTable();
  185. dt1 = DBUtility.DbHelperSQL.Query(sql).Tables[0];
  186. if (dt1.Rows[0]["counts"] == null || dt1.Rows[0]["counts"].ToString() == "" || dt1.Rows[0]["counts"].ToString() == "0")
  187. {
  188. continue;
  189. }
  190. count = count + 1;
  191. //工单的处理时间,是接收时间加上处理的时间
  192. sql = @"select sum(F_ELAPSEDTIME) as sum1,(select sum(F_ELAPSEDTIME) from T_Wo_WorkOrderHistory where F_WORKORDERSTATEID=6 and F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderHistory where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderBase where 1=1 " + sqltimeTask + " ) and F_WORKORDERSTATEID=7 and F_OPTUSERID=" + dt.Rows[i]["F_UserId"].ToString() + ")" + sqltimeHistory + ") as sum2 from T_Wo_WorkOrderHistory where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderBase where 1=1 " + sqltimeTask + " ) and F_WORKORDERSTATEID=7 and F_OPTUSERID=" + dt.Rows[i]["F_UserId"].ToString() + "" + sqltimeHistory + "";
  193. DataTable dt2 = DBUtility.DbHelperSQL.Query(sql).Tables[0];
  194. string time = "0";
  195. if (dt2.Rows[0]["sum1"].ToString() == "" && dt2.Rows[0]["sum2"].ToString() != "")
  196. {
  197. time = (Convert.ToDouble(dt2.Rows[0]["sum2"]) / Convert.ToDouble(dt1.Rows[0]["counts"]) / 3600).ToString("f2");
  198. zongtime += Convert.ToDouble(dt2.Rows[0]["sum2"]);
  199. zongtimecount += Convert.ToInt32(dt1.Rows[0]["counts"]);
  200. }
  201. else if (dt2.Rows[0]["sum1"].ToString() != "" && dt2.Rows[0]["sum2"].ToString() == "")
  202. {
  203. time = (Convert.ToDouble(dt2.Rows[0]["sum1"]) / Convert.ToDouble(dt1.Rows[0]["counts"]) / 3600).ToString("f2");
  204. zongtime += Convert.ToDouble(dt2.Rows[0]["sum1"]);
  205. zongtimecount += Convert.ToInt32(dt1.Rows[0]["counts"]);
  206. }
  207. else if (dt2.Rows[0]["sum1"].ToString() != "" && dt2.Rows[0]["sum2"].ToString() != "")
  208. {
  209. time = ((Convert.ToDouble(dt2.Rows[0]["sum1"]) + Convert.ToDouble(dt2.Rows[0]["sum2"])) / Convert.ToDouble(dt1.Rows[0]["counts"]) / 3600).ToString("f2");
  210. zongtime += Convert.ToDouble(dt2.Rows[0]["sum1"]) + Convert.ToDouble(dt2.Rows[0]["sum2"]);
  211. zongtimecount += Convert.ToInt32(dt1.Rows[0]["counts"]);
  212. }
  213. //查出来客户评分
  214. sql = "select count(*) as counts from T_Wo_WorkOrderHistoryInfo where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderHistory where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderBase where 1=1 " + sqltimeTask + " ) and F_WORKORDERSTATEID=7 and F_OPTUSERID=" + dt.Rows[i]["F_UserId"].ToString() + ") and F_CUSTOMERSCORE is not null and F_CUSTOMERSCORE!=''" + sqltimeHistory + "";
  215. DataTable dt3 = DBUtility.DbHelperSQL.Query(sql).Tables[0];
  216. sql = "select SUM(convert(int,F_CUSTOMERSCORE)) as sums from T_Wo_WorkOrderHistoryInfo where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderHistory where F_INSTANCEID in(select F_INSTANCEID from T_Wo_WorkOrderBase where 1=1 " + sqltimeTask + " ) and F_WORKORDERSTATEID=7 and F_OPTUSERID=" + dt.Rows[i]["F_UserId"].ToString() + ") and F_CUSTOMERSCORE is not null and F_CUSTOMERSCORE!=''" + sqltimeHistory + "";
  217. DataTable dt4 = DBUtility.DbHelperSQL.Query(sql).Tables[0];
  218. string fenshu = "0";
  219. if (dt4.Rows[0]["sums"].ToString() != "")
  220. {
  221. fenshu = (Convert.ToInt32(dt4.Rows[0]["sums"]) / Convert.ToInt32(dt3.Rows[0]["counts"])).ToString();
  222. zongfen += Convert.ToDouble(dt4.Rows[0]["sums"]);
  223. zongfencount += Convert.ToInt32(dt3.Rows[0]["counts"]);
  224. gerenfenshu = Convert.ToInt32(dt4.Rows[0]["sums"]);
  225. gerencount = Convert.ToInt32(dt3.Rows[0]["counts"]);
  226. }
  227. else
  228. {
  229. gerenfenshu = 0;
  230. gerencount = 0;
  231. }
  232. //拼接表数据
  233. htmlReport.AppendFormat("<tr><td align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", dt.Rows[i]["F_UserName"].ToString());
  234. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", dt1.Rows[0]["counts"].ToString());
  235. zong1 += Convert.ToInt32(dt1.Rows[0]["counts"]);
  236. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", dt1.Rows[0]["ybgdjiedan"].ToString());
  237. zong2 += Convert.ToInt32(dt1.Rows[0]["ybgdjiedan"]);
  238. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", dt1.Rows[0]["jjgdjiedan"].ToString());
  239. zong7 += Convert.ToInt32(dt1.Rows[0]["jjgdjiedan"]);
  240. if (dt1.Rows[0]["ybgdjiedan"] == null || dt1.Rows[0]["jjgdjiedan"] == null|| dt1.Rows[0]["counts"] == null || dt1.Rows[0]["counts"].ToString() == "0")
  241. {
  242. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>0.00%</td>");
  243. }
  244. else
  245. {
  246. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", ((Convert.ToDouble(dt1.Rows[0]["ybgdjiedan"])+Convert.ToDouble(dt1.Rows[0]["jjgdjiedan"])) / Convert.ToDouble(dt1.Rows[0]["counts"]) * 100).ToString("f2") + "%");
  247. }
  248. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", dt1.Rows[0]["ybgdchuli"].ToString() + "&nbsp");
  249. zong3 += Convert.ToInt32(dt1.Rows[0]["ybgdchuli"]);
  250. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", dt1.Rows[0]["jjgdchuli"].ToString() + "&nbsp");
  251. zong8 += Convert.ToInt32(dt1.Rows[0]["jjgdchuli"]);
  252. if (dt1.Rows[0]["ybgdchuli"] == null || dt1.Rows[0]["jjgdchuli"] == null || dt1.Rows[0]["counts"] == null || dt1.Rows[0]["counts"].ToString() == "0")
  253. {
  254. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>0.00%</td>");
  255. }
  256. else
  257. {
  258. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", ((Convert.ToDouble(dt1.Rows[0]["ybgdchuli"])+Convert.ToDouble(dt1.Rows[0]["jjgdchuli"])) / Convert.ToDouble(dt1.Rows[0]["counts"]) * 100).ToString("f2") + "%");
  259. }
  260. //紧急请求开始
  261. //if (dt1.Rows[0]["jjgdjiedan"] == null || dt1.Rows[0]["jjgdjiedan"].ToString() == "0" || dt1.Rows[0]["counts"] == null || dt1.Rows[0]["counts"].ToString() == "0")
  262. //{
  263. // htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>0.00%</td>");
  264. //}
  265. //else
  266. //{
  267. // htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", (Convert.ToDouble(dt1.Rows[0]["jjgdjiedan"]) / Convert.ToDouble(dt1.Rows[0]["counts"]) * 100).ToString("f2") + "%");
  268. //}
  269. //if (dt1.Rows[0]["jjgdchuli"] == null || dt1.Rows[0]["jjgdchuli"].ToString() == "0" || dt1.Rows[0]["counts"] == null || dt1.Rows[0]["counts"].ToString() == "0")
  270. //{
  271. // htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>0.00%</td>");
  272. //}
  273. //else
  274. //{
  275. // htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", (Convert.ToDouble(dt1.Rows[0]["jjgdchuli"]) / Convert.ToDouble(dt1.Rows[0]["counts"]) * 100).ToString("f2") + "%");
  276. //}
  277. //紧急请求结束
  278. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", dt1.Rows[0]["jiejue"].ToString());
  279. zong4 += Convert.ToInt32(dt1.Rows[0]["jiejue"]);
  280. if (dt1.Rows[0]["jiejue"] == null || dt1.Rows[0]["jiejue"].ToString() == "0" || dt1.Rows[0]["counts"] == null || dt1.Rows[0]["counts"].ToString() == "0")
  281. {
  282. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>0.00%</td>");
  283. }
  284. else
  285. {
  286. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", (Convert.ToDouble(dt1.Rows[0]["jiejue"]) / Convert.ToDouble(dt1.Rows[0]["counts"]) * 100).ToString("f2") + "%");
  287. }
  288. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", time);
  289. zong5 += Convert.ToDouble(time);
  290. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", gerenfenshu);
  291. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", gerencount);
  292. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", fenshu);
  293. zong6 += Convert.ToInt32(fenshu);
  294. htmlReport.Append("</tr>");
  295. }
  296. }
  297. //拼接表下部的总计
  298. htmlReport.Append("<tr height='35'>");
  299. htmlReport.AppendFormat("<td colspan='2' style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", "总计");
  300. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", zong1);
  301. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", zong2);
  302. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", zong7);
  303. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", (Convert.ToDouble((zong2+zong7) / zong1) * 100).ToString("f2") + "%");
  304. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", zong3);
  305. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", zong8);
  306. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", (Convert.ToDouble((zong3+zong8) / zong1) * 100).ToString("f2") + "%");
  307. //htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", (Convert.ToDouble(zong7 / zong1) * 100).ToString("f2") + "%");
  308. //htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", (Convert.ToDouble(zong8 / zong1) * 100).ToString("f2") + "%");
  309. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", zong4);
  310. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", (Convert.ToDouble(zong4 / zong1) * 100).ToString("f2") + "%");
  311. if (zongtimecount == 0)
  312. {
  313. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>0.00%</td>");
  314. }
  315. else
  316. {
  317. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", Convert.ToDouble(zongtime / zongtimecount / 3600).ToString("f2"));
  318. }
  319. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", zongfen);
  320. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", zongfencount);
  321. if (zongfencount == 0)
  322. {
  323. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>0.00</td>");
  324. }
  325. else
  326. {
  327. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", (zongfen / zongfencount).ToString("f2"));
  328. }
  329. htmlReport.Append("</tr>");
  330. htmlReport.Append("</table>");
  331. }
  332. catch { }
  333. return htmlReport.ToString();
  334. }
  335. public bool IsReusable
  336. {
  337. get
  338. {
  339. return false;
  340. }
  341. }
  342. }
  343. }