| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- using CallCenter.Utility;
- using CallCenterApi.Interface.Controllers.Base;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers.quality
- {
- public class IndexBaseController : BaseController
- {
- //获取指标列表
- public ActionResult GetList()
- {
- string sql = "";
- DataTable dt = new DataTable();
- string categoryid = RequestString.GetQueryString("categoryid");
- string key = WebHelper.UrlDecode(RequestString.GetQueryString("key"));
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- if (categoryid.Trim() != "")
- {
- sql += " and (F_CategoryId=" + categoryid + " or F_CategoryId in (select F_CategoryId from T_QC_IndexCategory where F_ParentId=" + categoryid + " )) ";
- }
- if (key.Trim() != "")
- {
- sql += " and (F_Title like '%" + key.Trim() + "%' or F_Content like '%" + key.Trim() + "%') ";
- }
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- int recordCount = 0;
- dt = BLL.PagerBLL.GetListPager(
- "vw_QC_IndexBase",
- "F_IndexId",
- "*",
- " and F_DeleteFlag=0 " + sql,
- "ORDER BY F_Sort",
- pagesize,
- pageindex,
- true,
- out recordCount);
- var obj = new
- {
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- //获取指标
- public ActionResult GetIndexBase(string id)
- {
- if (id.Trim() != "")
- {
- BLL.T_QC_IndexBase dBLL = new BLL.T_QC_IndexBase();
- Model.T_QC_IndexBase dModel = dBLL.GetModel(int.Parse(id.Trim()));
- if (dModel != null)
- {
- return Success("获取指标成功", dModel);
- }
- else
- {
- return Error("获取指标失败");
- }
- }
- else
- {
- return Error("获取参数失败");
- }
- }
- //添加指标
- public ActionResult AddIndexBase(string cid, string score, string sort, string title, string remark)
- {
- Model.T_QC_IndexBase dModel = new Model.T_QC_IndexBase();
- if (!string.IsNullOrWhiteSpace(cid.Trim()))
- {
- dModel.F_CategoryId = int.Parse(cid.Trim());
- }
- if (!string.IsNullOrWhiteSpace(sort.Trim()))
- {
- dModel.F_Sort = Convert.ToInt32(sort.Trim());
- }
- //if (!string.IsNullOrWhiteSpace(sort.Trim()))
- //{
- // dModel.F_Score = Convert.ToInt32(sort.Trim());
- //}
- if (!string.IsNullOrWhiteSpace(title.Trim()))
- {
- dModel.F_Title = WebHelper.UrlDecode(title.Trim());
- }
- if (!string.IsNullOrWhiteSpace(remark.Trim()))
- {
- dModel.F_Remark = WebHelper.UrlDecode(remark.Trim());
- }
- if (!string.IsNullOrWhiteSpace(score))
- {
- dModel.F_Score = Convert.ToDouble( score.Trim());
- }
- dModel.F_CreateOn = DateTime.Now;
- dModel.F_CreateBy = CurrentUser.UserData.F_UserId;
- dModel.F_DeleteFlag = 0;
- bool b = new BLL.T_QC_IndexBase().Add(dModel) > 0;
- if (b)
- {
- return Success("添加成功");
- }
- else
- {
- return Success("添加失败");
- }
- }
- //编辑指标
- public ActionResult EditIndexBase(string id, string cid, string score, string sort, string title, string remark)
- {
- if (cid.Trim() != "")
- {
- BLL.T_QC_IndexBase dBLL = new BLL.T_QC_IndexBase();
- Model.T_QC_IndexBase dModel = dBLL.GetModel(int.Parse(id.Trim()));
- if (dModel != null)
- {
- if (!string.IsNullOrWhiteSpace(cid.Trim()))
- {
- dModel.F_CategoryId = int.Parse(cid.Trim());
- }
- if (!string.IsNullOrWhiteSpace(sort.Trim()))
- {
- dModel.F_Sort = Convert.ToInt32(sort.Trim());
- }
- if (!string.IsNullOrWhiteSpace(score.Trim()))
- {
- dModel.F_Score = Convert.ToDouble(score);
- }
- if (!string.IsNullOrWhiteSpace(title.Trim()))
- {
- dModel.F_Title = WebHelper.UrlDecode(title.Trim());
- }
- if (!string.IsNullOrWhiteSpace(remark.Trim()))
- {
- dModel.F_Remark = WebHelper.UrlDecode(remark.Trim());
- }
- bool b = dBLL.Update(dModel);
- if (b)
- {
- return Success("编辑成功");
- }
- else
- {
- return Success("编辑失败");
- }
- }
- else
- return Error("获取信息失败");
- }
- else
- {
- return Error("请选择要编辑的指标");
- }
- }
- //删除指标记录
- public ActionResult DelIndexBase(string id, string cid)
- {
- DataTable dt = new DataTable();
- if (!string.IsNullOrEmpty(id.Trim()))
- {
- if (new BLL.T_QC_IndexBase().Delete(Convert.ToInt32(id)))
- {
- SetScoreByCategory(cid);
- return Success("删除成功");
- }
- else
- {
- return Error("删除失败");
- }
- }
- else
- {
- return Error("请选择要删除的记录");
- }
- }
- //设置指标分数
- private void SetScoreByCategory(string categoryid)
- {
- DataTable dt = new DataTable();
- try
- {
- Model.T_QC_IndexCategory model = new BLL.T_QC_IndexCategory().GetModel(Convert.ToInt32(categoryid));
- if (model != null)
- {
- string parentid = model.F_ParentId.ToString();
- 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];
- int score = 0;
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- score += Convert.ToInt32(dt.Rows[i]["F_Score"].ToString().Trim());
- }
- model.F_Expand1 = score.ToString();
- if (new BLL.T_QC_IndexCategory().Update(model))
- {
- if (parentid != "0")
- {
- SetScoreByCategory(parentid);
- }
- }
- }
- }
- catch { }
- finally
- {
- dt.Clear();
- dt.Dispose();
- }
- }
- }
- }
|