南阳电信API

IndexBaseController.cs 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. using CallCenter.Utility;
  2. using CallCenterApi.Interface.Controllers.Base;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. namespace CallCenterApi.Interface.Controllers.quality
  10. {
  11. public class IndexBaseController : BaseController
  12. {
  13. //获取指标列表
  14. public ActionResult GetList()
  15. {
  16. string sql = "";
  17. DataTable dt = new DataTable();
  18. string categoryid = RequestString.GetQueryString("categoryid");
  19. string key = WebHelper.UrlDecode(RequestString.GetQueryString("key"));
  20. string strpageindex = RequestString.GetQueryString("page");
  21. int pageindex = 1;
  22. string strpagesize = RequestString.GetQueryString("pagesize");
  23. int pagesize = 10;
  24. if (categoryid.Trim() != "")
  25. {
  26. sql += " and (F_CategoryId=" + categoryid + " or F_CategoryId in (select F_CategoryId from T_QC_IndexCategory where F_ParentId=" + categoryid + " )) ";
  27. }
  28. if (key.Trim() != "")
  29. {
  30. sql += " and (F_Title like '%" + key.Trim() + "%' or F_Content like '%" + key.Trim() + "%') ";
  31. }
  32. if (strpageindex.Trim() != "")
  33. {
  34. pageindex = Convert.ToInt32(strpageindex);
  35. }
  36. if (strpagesize.Trim() != "")
  37. {
  38. pagesize = Convert.ToInt32(strpagesize);
  39. }
  40. int recordCount = 0;
  41. dt = BLL.PagerBLL.GetListPager(
  42. "vw_QC_IndexBase",
  43. "F_IndexId",
  44. "*",
  45. " and F_DeleteFlag=0 " + sql,
  46. "ORDER BY F_Sort",
  47. pagesize,
  48. pageindex,
  49. true,
  50. out recordCount);
  51. var obj = new
  52. {
  53. rows = dt,
  54. total = recordCount
  55. };
  56. return Content(obj.ToJson());
  57. }
  58. //获取指标
  59. public ActionResult GetIndexBase(string id)
  60. {
  61. if (id.Trim() != "")
  62. {
  63. BLL.T_QC_IndexBase dBLL = new BLL.T_QC_IndexBase();
  64. Model.T_QC_IndexBase dModel = dBLL.GetModel(int.Parse(id.Trim()));
  65. if (dModel != null)
  66. {
  67. return Success("获取指标成功", dModel);
  68. }
  69. else
  70. {
  71. return Error("获取指标失败");
  72. }
  73. }
  74. else
  75. {
  76. return Error("获取参数失败");
  77. }
  78. }
  79. //添加指标
  80. public ActionResult AddIndexBase(string cid, string score, string sort, string title, string remark)
  81. {
  82. Model.T_QC_IndexBase dModel = new Model.T_QC_IndexBase();
  83. if (!string.IsNullOrWhiteSpace(cid.Trim()))
  84. {
  85. dModel.F_CategoryId = int.Parse(cid.Trim());
  86. }
  87. if (!string.IsNullOrWhiteSpace(sort.Trim()))
  88. {
  89. dModel.F_Sort = Convert.ToInt32(sort.Trim());
  90. }
  91. //if (!string.IsNullOrWhiteSpace(sort.Trim()))
  92. //{
  93. // dModel.F_Score = Convert.ToInt32(sort.Trim());
  94. //}
  95. if (!string.IsNullOrWhiteSpace(title.Trim()))
  96. {
  97. dModel.F_Title = WebHelper.UrlDecode(title.Trim());
  98. }
  99. if (!string.IsNullOrWhiteSpace(remark.Trim()))
  100. {
  101. dModel.F_Remark = WebHelper.UrlDecode(remark.Trim());
  102. }
  103. if (!string.IsNullOrWhiteSpace(score))
  104. {
  105. dModel.F_Score = Convert.ToDouble( score.Trim());
  106. }
  107. dModel.F_CreateOn = DateTime.Now;
  108. dModel.F_CreateBy = CurrentUser.UserData.F_UserId;
  109. dModel.F_DeleteFlag = 0;
  110. bool b = new BLL.T_QC_IndexBase().Add(dModel) > 0;
  111. if (b)
  112. {
  113. return Success("添加成功");
  114. }
  115. else
  116. {
  117. return Success("添加失败");
  118. }
  119. }
  120. //编辑指标
  121. public ActionResult EditIndexBase(string id, string cid, string score, string sort, string title, string remark)
  122. {
  123. if (cid.Trim() != "")
  124. {
  125. BLL.T_QC_IndexBase dBLL = new BLL.T_QC_IndexBase();
  126. Model.T_QC_IndexBase dModel = dBLL.GetModel(int.Parse(id.Trim()));
  127. if (dModel != null)
  128. {
  129. if (!string.IsNullOrWhiteSpace(cid.Trim()))
  130. {
  131. dModel.F_CategoryId = int.Parse(cid.Trim());
  132. }
  133. if (!string.IsNullOrWhiteSpace(sort.Trim()))
  134. {
  135. dModel.F_Sort = Convert.ToInt32(sort.Trim());
  136. }
  137. if (!string.IsNullOrWhiteSpace(score.Trim()))
  138. {
  139. dModel.F_Score = Convert.ToDouble(score);
  140. }
  141. if (!string.IsNullOrWhiteSpace(title.Trim()))
  142. {
  143. dModel.F_Title = WebHelper.UrlDecode(title.Trim());
  144. }
  145. if (!string.IsNullOrWhiteSpace(remark.Trim()))
  146. {
  147. dModel.F_Remark = WebHelper.UrlDecode(remark.Trim());
  148. }
  149. bool b = dBLL.Update(dModel);
  150. if (b)
  151. {
  152. return Success("编辑成功");
  153. }
  154. else
  155. {
  156. return Success("编辑失败");
  157. }
  158. }
  159. else
  160. return Error("获取信息失败");
  161. }
  162. else
  163. {
  164. return Error("请选择要编辑的指标");
  165. }
  166. }
  167. //删除指标记录
  168. public ActionResult DelIndexBase(string id, string cid)
  169. {
  170. DataTable dt = new DataTable();
  171. if (!string.IsNullOrEmpty(id.Trim()))
  172. {
  173. if (new BLL.T_QC_IndexBase().Delete(Convert.ToInt32(id)))
  174. {
  175. SetScoreByCategory(cid);
  176. return Success("删除成功");
  177. }
  178. else
  179. {
  180. return Error("删除失败");
  181. }
  182. }
  183. else
  184. {
  185. return Error("请选择要删除的记录");
  186. }
  187. }
  188. //设置指标分数
  189. private void SetScoreByCategory(string categoryid)
  190. {
  191. DataTable dt = new DataTable();
  192. try
  193. {
  194. Model.T_QC_IndexCategory model = new BLL.T_QC_IndexCategory().GetModel(Convert.ToInt32(categoryid));
  195. if (model != null)
  196. {
  197. string parentid = model.F_ParentId.ToString();
  198. dt = new BLL.T_QC_IndexBase().GetList("F_DeleteFlag=0 and (F_CategoryId=" + model.F_CategoryId + " or F_CategoryId in (select F_CategoryId from T_QC_IndexCategory where F_ParentId=" + categoryid + " )) ").Tables[0];
  199. int score = 0;
  200. for (int i = 0; i < dt.Rows.Count; i++)
  201. {
  202. score += Convert.ToInt32(dt.Rows[i]["F_Score"].ToString().Trim());
  203. }
  204. model.F_Expand1 = score.ToString();
  205. if (new BLL.T_QC_IndexCategory().Update(model))
  206. {
  207. if (parentid != "0")
  208. {
  209. SetScoreByCategory(parentid);
  210. }
  211. }
  212. }
  213. }
  214. catch { }
  215. finally
  216. {
  217. dt.Clear();
  218. dt.Dispose();
  219. }
  220. }
  221. }
  222. }